Get Order Details
Get order details 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/details?order_id=240108010445130' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/order/details'
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/details';
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/details";
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/details?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))
try:
api_response = api_instance.get_order_status(order_id="2410170106208487")
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->get order status: %s\n" % e.body)
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 optsOrderStatus = {
orderId: "241017010620465"
};
apiInstance.getOrderStatus(optsOrderStatus,(error,data,response) => {
if (error) {
console.error(error.response.text);
} 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.GetOrderDetailsResponse;
import com.upstox.auth.OAuth;
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();
try {
GetOrderDetailsResponse result = apiInstance.getOrderStatus("241017010620466");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#cancelMultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}