All URIs are relative to https://api.upstox.com
Method | HTTP request | Description |
---|---|---|
cancelMultiOrder | DELETE /v2/order/multi/cancel | Cancel multi order |
cancelOrder1 | DELETE /v2/order/cancel | Cancel order |
exitPositions | POST /v2/order/positions/exit | Exit all positions |
getOrderBook | GET /v2/order/retrieve-all | Get order book |
getOrderDetails | GET /v2/order/history | Get order history |
getOrderStatus | GET /v2/order/details | Get order details |
getTradeHistory | GET /v2/order/trades/get-trades-for-day | Get trades |
getTradesByOrder | GET /v2/order/trades | Get trades for order |
modifyOrder1 | PUT /v2/order/modify | Modify order |
placeMultiOrder | POST /v2/order/multi/place | Place multi order |
placeOrder1 | POST /v2/order/place | Place order |
CancelOrExitMultiOrderResponse cancelMultiOrder(opts)
Cancel multi order
API to cancel all the open or pending orders which can be applied to both AMO and regular orders.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let opts = {
'tag': "tag_example", // String | The tag associated with the orders for which the orders must be cancelled
'segment': "segment_example" // String | The segment for which the orders must be cancelled
};
apiInstance.cancelMultiOrder(opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
tag | String | The tag associated with the orders for which the orders must be cancelled | [optional] |
segment | String | The segment for which the orders must be cancelled | [optional] |
CancelOrExitMultiOrderResponse
CancelOrderResponse cancelOrder1(orderId)
Cancel order
Cancel order API can be used for two purposes: Cancelling an open order which could be an AMO or a normal order It is also used to EXIT a CO or OCO(bracket order)
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let orderId = "orderId_example"; // String | The order ID for which the order must be cancelled
let apiVersion = "apiVersion_example"; // String | API Version Header
apiInstance.cancelOrder(orderId, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | The order ID for which the order must be cancelled | |
apiVersion | String | API Version Header |
CancelOrExitMultiOrderResponse exitPositions(opts)
Exit all positions
This API provides the functionality to exit all the positions
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let opts = {
'tag': "tag_example", // String | The tag associated with the positions for which the positions must be exit
'segment': "segment_example" // String | The segment for which the positions must be exit
};
apiInstance.exitPositions(opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
tag | String | The tag associated with the positions for which the positions must be exit | [optional] |
segment | String | The segment for which the positions must be exit | [optional] |
CancelOrExitMultiOrderResponse
GetOrderBookResponse getOrderBook(apiVersion)
Get order book
This API provides the list of orders placed by the user. The orders placed by the user is transient for a day and is cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
apiInstance.getOrderBook((error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
This endpoint does not need any parameter.
GetOrderResponse getOrderDetails(opts)
Get order history
This API provides the details of the particular order the user has placed. The orders placed by the user is transient for a day and are cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones. The order history can be requested either using order_id or tag. If both the options are passed, the history of the order which precisely matches both the order_id and tag will be returned in the response. If only the tag is passed, the history of all the associated orders which matches the tag will be shared in the response.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let opts = {
'orderId': "orderId_example", // String | The order reference ID for which the order history is required
'tag': "tag_example" // String | The unique tag of the order for which the order history is being requested
};
apiInstance.getOrderDetails(opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
apiVersion | String | API Version Header |
GetOrderResponse getOrderDetails(apiVersion, opts)
Get order details
This API provides the details of the particular order the user has placed. The orders placed by the user is transient for a day and are cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones. The order history can be requested either using order_id or tag. If both the options are passed, the history of the order which precisely matches both the order_id and tag will be returned in the response. If only the tag is passed, the history of all the associated orders which matches the tag will be shared in the response.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let apiVersion = "apiVersion_example"; // String | API Version Header
let opts = {
'orderId': "orderId_example", // String | The order reference ID for which the order history is required
'tag': "tag_example" // String | The unique tag of the order for which the order history is being requested
};
apiInstance.getOrderDetails(apiVersion, opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
apiVersion | String | API Version Header | |
orderId | String | The order reference ID for which the order history is required | [optional] |
tag | String | The unique tag of the order for which the order history is being requested | [optional] |
GetTradeResponse getTradeHistory(apiVersion)
Get trades
Retrieve the trades executed for the day
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let apiVersion = "apiVersion_example"; // String | API Version Header
apiInstance.getTradeHistory(apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
apiVersion | String | API Version Header |
GetTradeResponse getTradesByOrder(orderId, apiVersion)
Get trades for order
Retrieve the trades executed for an order
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let orderId = "orderId_example"; // String | The order ID for which the order to get order trades
let apiVersion = "apiVersion_example"; // String | API Version Header
apiInstance.getTradesByOrder(orderId, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | The order ID for which the order to get order trades | |
apiVersion | String | API Version Header |
ModifyOrderResponse modifyOrder(body, apiVersion)
Modify order
This API allows you to modify an order. For modification orderId is mandatory. With orderId you need to send the optional parameter which needs to be modified. In case the optional parameters aren't sent, the default will be considered from the original order
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let body = new UpstoxClient.ModifyOrderRequest(); // ModifyOrderRequest |
let apiVersion = "apiVersion_example"; // String | API Version Header
apiInstance.modifyOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
body | ModifyOrderRequest | ||
apiVersion | String | API Version Header |
MultiOrderResponse placeMultiOrder(body)
Place multi order
This API allows you to place multiple orders to the exchange via Upstox.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let body = [new UpstoxClient.MultiOrderRequest()]; // [MultiOrderRequest] |
apiInstance.placeMultiOrder(body, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
body | [MultiOrderRequest] |
PlaceOrderResponse placeOrder1(body)
Place order
This API allows you to place an order to the exchange via Upstox.
import {UpstoxClient} from 'upstox-js-sdk';
let defaultClient = UpstoxClient.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAUTH2
let OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new UpstoxClient.OrderApi();
let body = new UpstoxClient.PlaceOrderRequest(); // PlaceOrderRequest |
let apiVersion = "apiVersion_example"; // String | API Version Header
apiInstance.placeOrder(body, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
body | PlaceOrderRequest | ||
apiVersion | String | API Version Header |