Get Order History
Get order history for an order number
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/order/history?order_id=240108010445130' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/order/history'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
params = {'order_id': '240108010445130'}
response = requests.get(url, headers=headers, params=params)
print(response.text)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/order/history';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access}'
};
const params = {
order_id: '240108010445130'
};
axios.get(url, { headers, params })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/order/history";
String accept = "application/json";
String authorization = "Bearer {your_access_token}";
String orderId = "240108010445130";
try {
HttpClient httpClient = HttpClient.newHttpClient();
// Build the URI with query parameters
URI uri = URI.create(url + "?order_id=" + orderId);
// Build the request
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.header("Accept", accept)
.header("Authorization", authorization)
.GET()
.build();
// Send the request and get the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Print the response
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/order/history?order_id=240108010445130';
$headers = array(
'Accept: application/json',
'Authorization: Bearer {your_access_token}'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Response Code: " . $httpCode . PHP_EOL;
echo "Response: " . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
api_version = '2.0'
order_id = '240112010371054'
try:
api_response = api_instance.get_order_details(api_version, order_id=order_id)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->get_order_details: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApi();
let apiVersion = "2.0";
let opts = {
'orderId': "240112010371054"
};
apiInstance.getOrderDetails(apiVersion, opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetOrderResponse;
import com.upstox.auth.*;
import io.swagger.client.api.OrderApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OrderApi apiInstance = new OrderApi();
String apiVersion = "2.0";
String orderId = "240125010587640";
String tag = "string";
try {
GetOrderResponse result = apiInstance.getOrderDetails(apiVersion, orderId, tag);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#getOrderDetails");
e.printStackTrace();
}
}
}