Sunteți pe pagina 1din 30

Introduction

Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user
portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.

To use the APIs we provide SDKs in the following languages:

Language Docs Repository

Javascript NodeJS docs NodeJS source

Python Python docs Python source

We also have authorized third-party libraries that cover other languages:

Language Docs Library

.NET Library docs HowUTrade .NET Library

All requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as
JSON or CSV for a few API calls.

To be able to use these APIs you need to create an App in the Developer Console and generate your apiKey and apiSecret . You can use a redirect URL
which will be called after the login flow.

It is highly recommended that you do not embed the apiSecret in your frontend app. Create a remote backend which does the handshake on behalf of the
frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues.

Click here to create an app with Upstox

Create an app
Create an app with the App Type API Trading in the Developer Console. Give your app a name, a description and a redirect URI. This redirect URI is used
after login to pass an authorization code.

Note that if you are distributing your app to the public, please ensure that the redirect URI is stored in your server and not in your client-side application!
API key and secret
Once your app is created, you will get an API KEY and API SECRET. Your API KEY and API SECRET are used to identify the source of the connection and
ensure that it is really you. Your API KEY can be distributed on the client app but your API SECRET should be stored on your backend server.

Installation

pip install python

To facilitate easy use of the APIs, we have developed a set of libraries for different languages. If you are using one of those programming languages, you can
use the library functions for the calls/functions listed below.

Authorization

curl \
-u {your_api_key}:{your_api_secret} \
-H 'Content-Type: application/json' \
-H 'x-api-key: {your_api_key}' \
-d '{"code" : "{code_from_login_response}", "grant_type" : "authorization_code", "redirect_uri" : "{your_redirect_uri}"}' \
-X POST 'https://api.upstox.com/index/oauth/token'

code -- code generated on successful login


Authentication is done via oAuth process. Initial authentication requires access to a web browser as you would have to authorize the program using your client
ID (six digit UCC), trading password and year of birth. Whether your program runs on a GUI or a console, you would always have to access the web browser
to create an access token which then allows you to use the API. The access token has a validity of 24 hours so you only have to authenticate yourself once
during the day. (Note: All access tokens are cleared between 5 to 6 AM in the morning. We recommend you regenerate your access token after 6 AM). Once
you generate your access token, you can store it and bypass authentication for subsequent connects.

1. Open your web browser and go to the login URL. Your login URL is https://api.upstox.com/index/dialog/authorize?apiKey={your_api_key}&redirect_uri={y
our_redirect_uri}&response_type=code . On the libraries, you can get this URL by setting the apiKey and then calling the getLoginUri function with the red
irect_uri as a parameter. Note that the redirect_uri used here must match the redirect_uri specified in your App settings on the Developer Console.
2. Once redirected, it opens the Upstox login page where you enter your UCC, password and date of birth to authenticate yourself.
Login authentication screen. Your Year of Birth is your passcode.

3. After authentication it asks for your permission to allow the app to access your credentials.

Clicking Accept will then take you to the redirect URI with the authorization code as a parameter

4. Once you accept the permissions, Upstox redirects you to the redirectUri which was sent in step 1 with a parameter called code . This step should be
done in your backend app server.

5. With the newly generated code , you need to now generate an access token. To get the access token, you need to call the following URL https://api.u
pstox.com/index/oauth/token and pass the following parameters: api_key , redirect_uri , code , grant_type . This call is shown on the right side in the
code tab.

Note, the grant_type value must always be authorization_code . Do not change this value.

6. This returns you the accessToken to your backend app server.


7. You return this accessToken to your app via the response of your redirectUri . For future requests to the app, use the accessToken as your authorization
bearer token. If you are using the library, set the accessToken received to Upstox object by using the ‘setAccessToken’ method. This is enable all your
future requests to use this accessToken and provide the necessary permissions. The accessToken is valid until the next trading day.

Users

Profile

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/index/profile'

Sample response
{
"code":200,
"status":"OK",
"timestamp":"2017-07-18T10:32:02+05:30",
"message":"success",
"data":{
"client_id": "240001",
"name": "Raj Prakash",
"email": "raj.prakash@mymail.com",
"phone": "9820098200",
"exchanges_enabled":[
"BSE_EQ",
"NSE_EQ",
"NSE_FO",
"MCX_FO",
"NCD_FO",
"BCD_FO"
],
"products_enabled":[
"OCO",
"D",
"CO",
"I"
]
}
}

This allows to fetch the complete information of the user who is logged in.

RESPONSE ATTRIBUTES

attribute datatype description

client_id string Uniquely identifies the user

name string Name of the user

email string E-mail address of the user

phone string Phone number of the user

exchanges_enabled string Lists the exchanges to which the user has access

products_enabled array Lists the products types to which the user has access

Balance

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/profile/balance'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-05-15T14:35:57+05:30",
"message": "success",
"data": {
"equity": {
"used_margin": 67.2125,
"unrealized_mtm": 0,
"realized_mtm": 0,
"payin_amount": 0,
"span_margin": 0,
"adhoc_margin": 0,
"notional_cash": 0,
"available_margin": 99320.78,
"exposure_margin": 0
},
"commodity": {
"used_margin": 0,
"unrealized_mtm": 0,
"realized_mtm": 0,
"payin_amount": 0,
"span_margin": 0,
"adhoc_margin": 0,
"notional_cash": 0,
"available_margin": 5200.45,
"exposure_margin": 0
}
}
}

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/profile/balance/commodity'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-05-15T14:35:57+05:30",
"message": "success",
"data": {
"commodity": {
"used_margin": 0,
"unrealized_mtm": 0,
"realized_mtm": 0,
"payin_amount": 0,
"span_margin": 0,
"adhoc_margin": 0,
"notional_cash": 0,
"available_margin": 5200.45,
"exposure_margin": 0
}
}
}

Shows the balance of the user in equity and commodity market

Request Parameter

parameter

type of the users account

security
type
commodity

If type is not entered the users gets both the balances

RESPONSE ATTRIBUTES

attribute datatype description

Positive values denote the amount blocked into a Open order or position. Negative value denotes the amount being
used_margin number
released.

unrealized_mtm number Day PnL generated against open positions

realized_mtm number Day PnL generated against closed positions

payin_amount number Instant payin will reflect here


attribute datatype description

span_margin number Amount blocked on futures and options towards SPAN

adhoc_margin number Payin amount credited through a manual process

notional_cash number The amount maintained for withdrawal

available_margin number Total margin available for trading

exposure_margin number Amount blocked on futures and options towards Exposure

Positions

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/profile/positions'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-07-27T13:26:33+05:30",
"message": "success",
"data": [
{
"exchange": "NSE_FO",
"product": "D",
"symbol": "NIFTY17AUG10100CE",
"token": 66416,
"buy_amount": 0,
"sell_amount": 0,
"buy_quantity": 0,
"sell_quantity": 0,
"cf_buy_amount": 0,
"cf_sell_amount": 751548.75,
"cf_buy_quantity": 0,
"cf_sell_quantity": 75,
"avg_buy_price": "",
"avg_sell_price": 108.6,
"net_quantity": -75,
"close_price": 108.6,
"last_traded_price": 128,
"realized_profit": "",
"unrealized_profit": -1455.0000000000005,
"cf_avg_price": "72.00"
}
]
}

Fetches the current positions for the user for the current day

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the order is associated

product string Shows if the order was either Intraday, Delivery, CO or OCO

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

token number Token number of the order

buy_amount number Amount at which the qty is bought during the day

sell_amount number Amount at which the qty is sold during the day

buy_quantity number Qty bought during the day

sell_quantity number Qty sold during the day

cf_buy_amount number Amount at which the qty was bought in the previous session
attribute datatype description

cf_sell_amount number Amount at which the qty was sold in the previous session

cf_buy_quantity number Qty bought in the previous session

cf_sell_quantity number Qty sold short in the previous session

avg_buy_price number Average price at which the day qty was bought. Default is empty string

avg_sell_price number Average price at which the day qty was sold. Default is empty string

net_quantity number Quantity left after nullifying Day and CF buy quantity towards Day and CF sell quantity

close_price number Close price of the previous trading session

realized_profit number Day PnL generated against closed positions. Default is empty string

unrealized_profit number Day PnL generated against open positions. Default is empty string

It indicates the consolidated price across all the carry forward orders. (Note: Corporate actions are not taken into
cf_avg_price number
consideration)

Holdings

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/profile/holdings'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-07-27T13:06:03+05:30",
"message": "success",
"data": [
{
"instrument": [
{
"exchange": "NSE_EQ",
"symbol": "ASHOKLEY",
"token": 212
},
{
"exchange": "BSE_EQ",
"symbol": "ASHOKLEY",
"token": 500477
}
],
"product": "D",
"collateral_type": "WC",
"cnc_used_quantity": 0,
"quantity": 10,
"collateral_qty": 0,
"haircut": 25,
"avg_price": "76"
}
]
}

Fetches the holdings which the user has bought/sold in previous trading sessions

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the holding is associated

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

token number Unique identifier of a security in BSE and NSE

product string Shows if the order was either Intraday, Delivery, CO or OCO
attribute datatype description

collateral_type string Category of collateral assigned by RMS

cnc_used_quantity number Quantity either blocked towards open or completed order

quantity number The total holding qty

collateral_qty number Quantity marked as collateral by RMS on users request

haircut number This is the haircut percentage applied from RMS (applicable incase of collateral)

It indicates the consolidated price across all the orders placed for the scrip. (Note: Corporate actions are not taken into
avg_price number
consideration)

Master Contracts

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/index/master-contract/nse_eq'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-07-18T10:45:33+05:30",
"message": "success",
"data": [
"exchange,token,parent_token,symbol,name,closing_price,expiry,strike_price,tick_size,lot_size,instrument_type,isin",
"NSE_EQ,16921,,20MICRONS,20 MICRONS LTD,39.7,,,5,1,EQUITY,INE144J01027",
"NSE_EQ,11774,,3IINFOTECH,3I INFOTECH LTD.,4.45,,,5,1,EQUITY,INE748C01020",
"NSE_EQ,474,,3MINDIA,3M INDIA LIMITED,13686.2,,,5,1,EQUITY,INE470A01017",
"NSE_EQ,11868,,63MOONS,63 MOONS TECHNOLOGIES LTD,62.95,,,5,1,EQUITY,INE111B01023",
"NSE_EQ,11058,,8KMILES,8K MILES SOFT SERV LTD,541.6,,,5,1,EQUITY,INE650K01021",
"NSE_EQ,20906,,A2ZINFRA,A2Z INFRA ENGINEERING LTD,43.1,,,5,1,EQUITY,INE619I01012",
"NSE_EQ,11341,,AIFL,ASHAPURA INTI FASHION LTD,401.4,,,5,1,EQUITY,INE428O01016",....
]
}

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/index/master-contract/nse_index'

Sample response
{
"code":200,
"status":"OK",
"timestamp":"2017-07-19T10:46:26+05:30",
"message":"success",
"data":[
"exchange,token,parent_token,symbol,name,closing_price,expiry,strike_price,tick_size,lot_size,instrument_type,isin",
"NSE_INDEX,,,NIFTY_50,Nifty 50,9827.15,,,,,INDEX,",
"NSE_INDEX,,,NIFTY_IT,Nifty IT,10493.15,,,,,INDEX,",
"NSE_INDEX,,,NIFTY_NEXT_50,Nifty Next 50,27277.25,,,,,INDEX,",
"NSE_INDEX,,,NIFTY_BANK,Nifty Bank,24022.05,,,,,INDEX,",
"NSE_INDEX,,,NIFTY_MID100_FREE,Nifty MID100 Free,18216.6,,,,,INDEX,",
"NSE_INDEX,,,NIFTY_500,Nifty 500,8589.8,,,,,INDEX,",...
]
}

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/index/master-contract/nse_eq?token=2885'

Sample response

{
"code":200,
"status":"OK",
"timestamp":"2017-07-18T10:47:32+05:30",
"message":"success",
"data":{
"lower_circuit":1396.6,
"upper_circuit":1706.9,
"instrument_name":"EQUITY",
"gn":-1,
"gd":-1,
"pn":-1,
"pd":-1,
"circuit_limit":"1396.60-1706.90",
"status":"Eligible",
"yearly_low":930,
"yearly_high":1550,
"symbol":"RELIANCE",
"lot_size":1,
"exchange":"NSE_EQ",
"closing_price":1551.75,
"open_interest":"",
"tick_size":5,
"name":"RELIANCE INDUSTRIES LTD",
"token":2885,
"isin":"INE002A01018"
}
}

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/index/master-contract/nse_eq?symbol=infy'

Sample response

{
"code":200,
"status":"OK",
"timestamp":"2017-07-18T10:49:33+05:30",
"message":"success",
"data":{
"lower_circuit":885.65,
"upper_circuit":1082.45,
"instrument_name":"EQUITY",
"gn":-1,
"gd":-1,
"pn":-1,
"pd":-1,
"circuit_limit":"885.65-1082.45",
"status":"Eligible",
"yearly_low":901,
"yearly_high":1196.05,
"symbol":"INFY",
"lot_size":1,
"exchange":"NSE_EQ",
"closing_price":984.05,
"open_interest":"",
"tick_size":5,
"name":"INFOSYS LIMITED",
"token":1594,
"isin":"INE009A01021"
}
}

getMasterContract allows to download master contract as csv. The master contract contains all necessary information about all available contracts. Gets all
contracts or filter contracts by exchange segment. You can also get the details on a single scrip by sending the either symbol or token. Sending the exchange
is mandatory.

Request Parameter

parameter description

name of the exchange

bse_index - BSE Index


nse_index - NSE Index
bse_eq - BSE Equity
exchange optional bcd_fo - BSE Currency Futures & Options
nse_eq - NSE Equity
nse_fo - NSE Futures & Options
ncd_fo - NSE Currency Futures & Options
mcx_fo - MCX Futures

symbol optional Trading symbol which could be a combination of symbol name, instrument, expiry date etc

token optional Unique indentifier within an exchange


Symbol format
The trading symbol should be sent in the following format at the time of request

For BSE and NSE enter the scrip name as RELIANCE , AXISBANK etc
For NSE futures enter the symbol as NIFTY17JUNFUT where NIFTY is the scrip name, 17 [YY] is the year, JUN [MMM] is the month name, FUT is the
instrument
For NSE monthly options enter the symbol as NIFTY17JUN9500CE where NIFTY is the scrip name, 17[YY] is the year, JUN [MMM] is the month name,
9500 is the strike price and CE is the option type
For NSE weekly options it should be BANKNIFTY1750423200CE where BANKNIFTY is the scrip name, 17[YY] is the year, 5 [M] is the month, 04 [DD] is the
day, 23200 is the strike price and CE is the option type. The format of month will be different for October, November and December. It will show like this
BANKNIFTY17111623200CE where 11 is the month and 16 is the day.

Orders

Orders History

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/orders'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-03-28T17:01:02+05:30",
"message": "success",
"data": [
{
"exchange": "NSE_EQ",
"token": 2885,
"symbol": "RELIANCE",
"product": "I",
"order_type": "L",
"duration": "DAY",
"price": 1080,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 0,
"transaction_type": "B",
"average_price": 1080,
"traded_quantity": 1,
"message": "",
"exchange_order_id": "1100000000006972",
"parent_order_id": "NA",
"order_id": "170328000000030",
"exchange_time": "28-Mar-2017 12:42:42",
"time_in_micro": "1490697859120172",
"status": "complete",
"is_amo": false,
"valid_date": "--",
"order_request_id": "1"
}
]
}

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.

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the order is associated

token number Token number of the instrument

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

product string Shows if the order was either Intraday, Delivery, CoverOrder or OneCancelsOther
attribute datatype description

Type of order. It can be one of the following

M refers to market order


order_type string L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop loss market

It can be one of the following

DAY
duration string
IOC
GTD

price number Price at which the order was placed

trigger_price number If the order was a stop loss order then the trigger price set is mentioned here

quantity number Quantity with which the order was placed

disclosed_quantity number The quantity that should be disclosed in the market depth

transaction_type string Indicates whether the order was a buy or sell order

average_price string Average price at which the qty got traded

traded_quantity string The total quantity traded from this particular order

message string Indicates the reason when any order is rejected, not modified or cancelled

exchange_order_id string Unique order ID assigned by the exchange for the order placed

parent_order_id string In case the order is part of the second or third leg of a CO or OCO, the parent order ID is indicated here

order_id string Unique order ID assigned internally for the order placed

exchange_time string User readable time at which the order was placed or updated

time_in_micro string Time in microseconds (Unix Epoch) at which the order was placed or updated

status string Indicates the current status of the order. Valid order status’ are outlined in the table below

is_amo string Indicates whether the order is an AMO order or not

valid_date string If the order is GTD (Good-Till-Date), this shows the valid date

order_request_id string Apart from 1st order it shows the count of how many requests were sent

Orders Details

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/orders/{order_id}'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-08-03T15:16:38+05:30",
"message": "success",
"data": [
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"duration": "DAY",
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 0,
"transaction_type": "B",
"average_price": 299.4,
"traded_quantity": 1,
"message": "",
"exchange_order_id": "1100000000062530",
"parent_order_id": "NA",
"order_id": "170803000000038",
"exchange_time": "03-Aug-2017 15:03:42",
"time_in_micro": "1501752667641223",
"status": "complete",
"is_amo": false,
"valid_date": "",
"fill_leg": "111",
"order_request_id": "1",
"report": "",
"text": ""
},
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"duration": "DAY",
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 1,
"transaction_type": "B",
"average_price": 0,
"traded_quantity": 0,
"message": "",
"exchange_order_id": "1100000000062530",
"parent_order_id": "NA",
"order_id": "170803000000038",
"exchange_time": "03-Aug-2017 15:03:42",
"time_in_micro": "1501752667639709",
"status": "open",
"is_amo": false,
"valid_date": "",
"fill_leg": "0",
"order_request_id": "1",
"report": "",
"text": ""
},
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"duration": "DAY",
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 1,
"transaction_type": "B",
"average_price": 0,
"traded_quantity": 0,
"message": "",
"exchange_order_id": "",
"parent_order_id": "NA",
"order_id": "170803000000038",
"exchange_time": "",
"time_in_micro": "1501752667600392",
"status": "open pending",
"is_amo": false,
"valid_date": "",
"fill_leg": "0",
"order_request_id": "1",
"report": "",
"text": ""
},
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"duration": "DAY",
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 1,
"transaction_type": "B",
"average_price": 0,
"traded_quantity": 0,
"message": "",
"exchange_order_id": "",
"parent_order_id": "NA",
"order_id": "170803000000038",
"exchange_time": "",
"time_in_micro": "1501752667308275",
"status": "validation pending",
"is_amo": false,
"valid_date": "",
"fill_leg": "0",
"order_request_id": "1",
"report": "",
"text": ""
},
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"duration": "DAY",
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 1,
"transaction_type": "B",
"average_price": 0,
"traded_quantity": 0,
"message": "",
"exchange_order_id": "",
"parent_order_id": "NA",
"order_id": "170803000000038",
"exchange_time": "",
"time_in_micro": "1501752667303641",
"status": "put order req received",
"is_amo": false,
"valid_date": "",
"fill_leg": "0",
"order_request_id": "1",
"report": "",
"text": ""
}
]
}

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 is cleared by the end of the
trading session. This API returns all states of the orders, namely, open, pending, and filled ones.

REQUEST PARAMETERS

parameters

order_id the order id for which trade details are to be fetched

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the order is associated

token number Token number of the instrument

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

product string Shows if the order was either Intraday, Delivery, CoverOrder or OneCancelsOther

Type of order. It can be one of the following

M refers to market order


order_type string L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop loss market

It can be one of the following

DAY
duration string
IOC
GTD

price number Price at which the order was placed


attribute datatype description

trigger_price number If the order was a stop loss order then the trigger price set is mentioned here

quantity number Quantity with which the order was placed

disclosed_quantity number The quantity that should be disclosed in the market depth

transaction_type string Indicates whether the order was a buy or sell order

average_price string Average price at which the qty got traded

traded_quantity string The total quantity traded from this particular order

message string Indicates the reason when any order is rejected, not modified or cancelled

exchange_order_id string Unique order ID assigned by the exchange for the order placed

parent_order_id string In case the order is part of the second or third leg of a CO or OCO, the parent order ID is indicated here

order_id string Unique order ID assigned internally for the order placed

exchange_time string User readable time at which the order was placed or updated

time_in_micro string Time in microseconds (Unix Epoch) at which the order was placed or updated

status string Indicates the current status of the order. Valid order status’ are outlined in the table below

is_amo string Indicates whether the order is an AMO order or not

valid_date string If the order is GTD (Good-Till-Date), this shows the valid date

order_request_id string Apart from 1st order it shows the count of how many requests were sent

ORDER STATUS

An order can be in any of the following states

order status description

put order req received Order was received by our order management system successfully

validation pending Will get sent to the exchange after validating risk management rules

open pending Order was received by exchange and awaiting open confirmation

open Order is open having order type as limit. Can be modified or cancelled

trigger pending Order is open having order type as SL or SL-M. Can be modified or cancelled

complete Order is fully traded and closed. Cannot be modified or cancelled

rejected Order was rejected. Please check the message field for rejection reason

modify validation pending Will get sent to the exchange after validating risk management rules

modify pending Modify request received by exchange and modification pending

not modified Modification was rejected. Please check the message field for rejection reason

modified Modification was successful

cancel pending Cancel request received by exchange and cancellation pending

not cancelled Cancellation request was rejected. Please check the message field for rejection reason

cancelled Order was cancelled. Cannot be modified or cancelled

after market order req received AMO was received by our order management system successfully. Can be modified or cancelled

modify after market order req received AMO modification was sucessful

cancelled after market order AMO was cancelled


Trade Book

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/trade-book'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-08-03T15:24:06+05:30",
"message": "success",
"data": [
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"transaction_type": "B",
"traded_quantity": 1,
"exchange_order_id": "1100000000062530",
"order_id": "170803000000038",
"exchange_time": "03-Aug-2017 15:03:42",
"time_in_micro": "1501752667641223",
"traded_price": 299.4,
"trade_id": "50091502"
},
{
"exchange": "NSE_EQ",
"token": 3045,
"symbol": "SBIN",
"product": "I",
"order_type": "M",
"transaction_type": "B",
"traded_quantity": 1,
"exchange_order_id": "1100000000068410",
"order_id": "170803000000040",
"exchange_time": "03-Aug-2017 15:23:01",
"time_in_micro": "1501753826450445",
"traded_price": 294.55,
"trade_id": "50091780"
},
{
"exchange": "NSE_EQ",
"token": 694,
"symbol": "CIPLA",
"product": "I",
"order_type": "M",
"transaction_type": "B",
"traded_quantity": 1,
"exchange_order_id": "1000000000054988",
"order_id": "170803000000041",
"exchange_time": "03-Aug-2017 15:23:15",
"time_in_micro": "1501753840617453",
"traded_price": 559.7,
"trade_id": "75686"
}
]
}

Provides the trades for the current day

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the order is associated

token number Token number of the instrument

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

product string Shows if the order was either Intraday, Delivery, CO or OCO
attribute datatype description

Type of order. It can be one of the following

M refers to market order


order_type string L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop loss market

transaction_type string Indicates whether the order was a buy or sell order

traded_quantity string The total quantity traded from this particular order

exchange_order_id string Unique order ID assigned by the exchange for the order placed

order_id string Unique order ID assigned internally for the order placed

exchange_time string User readable time at when the trade occurred

time_in_micro string Time in microseconds (Unix Epoch) when the trade occurred

trade_id string Trade ID generated from exchange towards traded transaction

traded_price string Price at which the traded quantity is traded

Trade History

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/orders/{order_id}/trades'

Sample response
{
"code": 200,
"status": "OK",
"timestamp": "2017-05-15T14:48:52+05:30",
"message": "success",
"data": [
{
"exchange": "NSE_EQ",
"token": 2885,
"symbol": "RELIANCE",
"product": "I",
"order_type": "M",
"transaction_type": "B",
"traded_quantity": 1,
"exchange_order_id": "1200000003336976",
"order_id": "170515000047270",
"exchange_time": "15-May-2017 13:56:31",
"time_in_micro": "1494836825761723",
"traded_price": 0,
"trade_id": "51345784",
}
]
}

Provides the trades for the given order

REQUEST PARAMETERS

parameters

order_id the order id for which trade details are to be fetched

RESPONSE ATTRIBUTES

attribute datatype description

exchange string Exchange to which the order is associated

token number Token number of the instrument


attribute datatype description

symbol string Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

product string Shows if the order was either Intraday, Delivery, CO or OCO

Type of order. It can be one of the following

M refers to market order


order_type string L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop loss market

transaction_type string Indicates whether the order was a buy or sell order

traded_quantity string The total quantity traded from this particular order

exchange_order_id string Unique order ID assigned by the exchange for the order placed

order_id string Unique order ID assigned internally for the order placed

exchange_time string User readable time at when the trade occurred

time_in_micro string Time in microseconds (Unix Epoch) when the trade occurred

trade_id string Trade ID generated from exchange towards traded transaction

traded_price string Price at which the traded quantity is traded

Place Order

curl \
-H 'Content-type: application/json' \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-d '{order_object}' \
-X POST 'https://api.upstox.com/live/orders'

order_object - Specifies the order object eg. '{


"transaction_type":"b",
"exchange":"NSE_EQ",
"symbol": "RELIANCE",
"quantity": 100,
"order_type":"m",
"product": "I"
}'

This allows you to place an order to the exchange via Upstox

REQUEST PARAMETERS

parameters description

transaction_type required Indicates whether its a buy(b) or sell(s) order

exchange required Exchange to which the order is associated

symbol required Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

quantity required Quantity with which the order was placed

Type of order. It can be one of the following

M refers to market order


order_type required L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop loss market

product required Shows if the order was either Intraday, Delivery, CO or OCO

price optional Price at which the order will be placed


parameters description

trigger_price optional If the order is a stop loss order then the trigger price set is mentioned here

disclosed_quantity optional The quantity that should be disclosed in the market depth

It can be one of the following

duration optional DAY (default)


IOC

is_amo optional Indicates whether the order is an AMO order or not

stoploss optional Set a difference from the entry price for stoploss. Use in case the product is OCO

squareoff optional Set a difference from the entry price for profit. Use in case the product is OCO

trailing_ticks optional Indicates the number of ticks if the order placed was a trailing order. se in case the product is OCO

Response available at order update

Modify Order

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-d '{order_object}' \
-X PUT 'https://api.upstox.com/live/orders/{order_id}'

Modify the order by updating the order quantity. For modification order_id is mandatory. With order_id you need to send the optional parameter which needs to
be modified. In case the optional paramters aren’t sent, the default will be considered from the original order. Following are those:

REQUEST PARAMETERS

parameters description

order_id required the order id for which the order must be modified

quantity optional Quantity with which the order was placed

Type of order. It can be one of the following

M refers to market order


order_type optional L refers to Limit Order
SL refers to Stop Loss Limit
SL-M refers to Stop Loss Market

price optional Price at which the order was placed

trigger_price optional If the order was a stop loss order then the trigger price set is mentioned here

disclosed_quantity optional The quantity that should be disclosed in the market depth

Response available at order update

Cancel Order

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X DELETE 'https://api.upstox.com/live/orders/{list of comma separated open order(s) ID}'

Following will be the response

{
"code": 200,
"status": "OK",
"timestamp": "2017-08-31T06:06:00+00:00",
"message": "success",
"data": "Cancellation sent for [170831000041785,170831000041799,170831000041776,170831000041769]"
}

Cancel order can be used for two purposes:

1. Cancelling an open order which could be an AMO or a normal order


2. It is also used to EXIT a CO or OCO(bracket order)

REQUEST PARAMETERS

parameters description

order_id required comma separated order ID assigned internally for the order placed

CANCEL ALL ORDERS

This can be used to cancel all open orders at once.

#To cancel all orders

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X DELETE 'https://api.upstox.com/live/orders'

Following will be the response

{
"code": 200,
"status": "OK",
"timestamp": "2017-08-31T06:03:07+00:00",
"message": "Sent cancellation requests for all open order(s)",
"data": "170831000041521,170831000041591,170831000041539,170831000041553"
}

Feed

Live Feed

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/feed/now/{exchange}/{symbol}/{type}'

#If you request for LTP, the following will be the response

{
"code": 200,
"status": "OK",
"timestamp": "2017-05-15T16:45:12+05:30",
"message": "feed",
"data": {
"timestamp": 1494843956000,
"exchange": "NSE_EQ",
"symbol": "RELIANCE",
"ltp": 1344.1,
"close": 1350.45
}
}

#If you request for Full, the following will be the response for indexes

{
"code":200,
"status":"OK",
"timestamp":"2017-07-19T11:11:32+05:30",
"message":"feed",
"data":{
"timestamp":1454498203000,
"exchange":"NSE_INDEX",
"symbol":"NIFTY_100",
"ltp":7452.05,
"open":7482.5,
"high":7510.4,
"low":7441.5,
"close":7452.05,
"yearly_high":9105.4,
"yearly_low":7340.95
}
}

#If you request for Full, the following will be the response for other scrips

{
"code": 200,
"status": "OK",
"timestamp": "2017-05-15T15:10:42+05:30",
"message": "feed",
"data": {
"timestamp": 1494837991000,
"exchange": "NSE_FO",
"symbol": "NIFTY17MAYFUT",
"ltp": 9446.8,
"open": 9448,
"high": 9454.4,
"low": 9437,
"close": 9414.8,
"vtt": 2802525,
"atp": 9446.71,
"oi": 21256725,
"spot_price": 9442.15,
"total_buy_qty": 830925,
"total_sell_qty": 858375,
"lower_circuit": 8473.35,
"upper_circuit": 10356.3,
"bids": [
{
"quantity": 900,
"price": 9446.7,
"orders": 2
},
{
"quantity": 75,
"price": 9446.65,
"orders": 1
},
{
"quantity": 1050,
"price": 9446.6,
"orders": 4
},
{
"quantity": 150,
"price": 9446.55,
"orders": 1
},
{
"quantity": 75,
"price": 9446.1,
"orders": 1
}
],
"asks": [
{
"quantity": 450,
"price": 9447,
"orders": 1
},
{
"quantity": 450,
"price": 9447.3,
"orders": 1
},
{
"quantity": 900,
"price": 9447.4,
"orders": 1
},
{
"quantity": 75,
"price": 9447.45,
"orders": 1
},
{
"quantity": 75,
"price": 9447.55,
"orders": 1
}
],
"ltt": 1494837991000
}
}

Get live feed information about a single instrument

attribute description

Name of the exchange

bse_index - BSE Index


nse_index - NSE Index
bse_eq - BSE Equity
exchange bcd_fo - BSE Currency Futures & Options
nse_eq - NSE Equity
nse_fo - NSE Futures & Options
ncd_fo - NSE Currency Futures & Options
mcx_fo - MCX Futures

symbol Shows the trading symbol which could be a combination of symbol name, instrument, expiry date etc

There are two ways in which you can request for feeds.

type ltp (default)


full

RESPONSE ATTRIBUTES

For LTP

attribute datatype description

timestamp string Time in milliseconds at which the feeds was updated

exchange string Name of the exchange

symbol string Shows the trading symbol

ltp number LTP is the last traded price of symbol

close string Close is the close price of the symbol from the previous session of trading

For Full (indexes)

attribute datatype description

timestamp string Time in milliseconds at which the feeds was updated

exchange string Name of the exchange

symbol string Shows the trading symbol

ltp number LTP is the last traded price of symbol

open string It will show the open price of the trading session

high string This will show the high price of the trading session

low string This will show the low price of the trading session

close string Close is the close price of the symbol from the previous session of trading

yearly_high number Indicates the highest value of the index in the current year

yearly_low number Indicates the lowest value of the index in the current year

For Full (other scrips)

attribute datatype description

timestamp string Time in milliseconds at which the feeds was updated

exchange string Name of the exchange


attribute datatype description

symbol string Shows the trading symbol

ltp number LTP is the last traded price of symbol

open string It will show the open price of the trading session

high string This will show the high price of the trading session

low string This will show the low price of the trading session

close string Close is the close price of the symbol from the previous session of trading

vtt number VTT is the volume traded today on symbol

atp number It stands for average traded price for the entire quantity traded in the exchange

oi number OI stands for open interest. It is applicable on future and option segments

spot_price number It means the underlying price of a stock. It is applicable on future and option segments

total_buy_qty string This show the total nos of bid quantity available for trading

total_sell_qty string This show the total nos of ask quantity available for trading

bid quantity string Bid quantity available for trading

bid price string Price at which the Bid quantity is available

bid orders string Number of orders requesting bids at this price

ask quantity string Ask quantity available for trading

ask price string Price at which the Bid quantity is available

ask orders string Number of orders requesting bids ask at this price

ltt string Time in milliseconds at which last trade happened

Subscribe

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/feed/sub/{type}/{exchange}/?symbol={list of comma separated symbols}'

Subscribe to get the live feed of a particular instrument in real-time

attribute description

Name of the exchange

bse_index - BSE Index


nse_index - NSE Index
bse_eq - BSE Equity
exchange bcd_fo - BSE Currency Futures & Options
nse_eq - NSE Equity
nse_fo - NSE Futures & Options
ncd_fo - NSE Currency Futures & Options
mcx_fo - MCX Futures

Comma seperated list of trading symbols which could be a combination of symbol name, instrument, expiry date etc. Note: The symbols
symbol
should not contain any spaces eg. ‘reliance,mrf,niftymay17fut’

There are two ways in which you can request for feeds.

type ltp (default)


full
Unsubscribe

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/feed/unsub/{type}/{exchange}?symbol={list of comma seperated symbols}'

Unsubscribe for the live data feed for the instruments chosen

attribute description

Name of the exchange

bse_index - BSE Index


nse_index - NSE Index
bse_eq - BSE Equity
exchange bcd_fo - BSE Currency Futures & Options
nse_eq - NSE Equity
nse_fo - NSE Futures & Options
ncd_fo - NSE Currency Futures & Options
mcx_fo - MCX Futures

Comma seperated list of trading symbols which could be a combination of symbol name, instrument, expiry date etc. Note: The symbols
symbol
should not contain any spaces eg. ‘reliance,mrf,niftymay17fut’

There are two ways in which you can request for feeds.

type ltp (default)


full

Historical

OHLC

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/historical/ohlc/{exchange}/{symbol}?interval={interval}&start_date={start_date}&end_date={end_date}&format={format}'

# Sample response
{
"code": 200,
"status": "OK",
"timestamp": "",
"message": "ohlc",
"data": [
{
"timestamp": 1485973800000,
"open": 1050,
"high": 1050.8,
"low": 1038.25,
"close": 1043.5,
"volume": 2079908,
"cp": 1045.55
}
]
}

Get OHLC values for all instruments across various timeframes

attribute description
attribute description

Name of the exchange

bse_eq - BSE Equity


bcd_fo - BSE Currency Futures & Options
exchange required nse_eq - NSE Equity
nse_fo - NSE Futures & Options
ncd_fo - NSE Currency Futures & Options
mcx_fo - MCX Futures

symbol required The symbol of the instrument. This must match exactly as given in the master contract csv. eg:NIFTY17MARFUT

Default: 1day
Allowed Values:

1MINUTE

5MINUTE

10MINUTE

interval optional 30MINUTE

60MINUTE

1DAY

1WEEK

1MONTH

Default: 15 days before today


start_date optional Date format: DD-MM-YYYY
eg: 20-01-2017

Default: today
end_date optional Date format: DD-MM-YYYY
eg: 01-02-2017

The data format of the ohlc representation.

csv
format optional
json (default)

TradeButton
TradeButton is a JS plugin that lets you add Upstox branded order placement buttons to your webpage. The buttons can be preconfigured to place a certain
order, or dynamically assigned orders.

We offer three variants:

Buy - for single/basket buy orders


Sell - for single/basket sell orders
Trade - for mixed basket orders

Apart from the branded buttons, the TradeButton functionality can be invoked on any custom button or link on the page. More details on it below.

Getting Started
Include the following scripts at the end of body.

BRANDED BUTTONS

<upstox-tradebutton buy button-name=**buttonName** ></upstox-tradebutton>


<upstox-tradebutton sell button-name=**buttonName** ></upstox-tradebutton>
<upstox-tradebutton trade button-name=**buttonName** ></upstox-tradebutton>
For creating a branded button, start by adding one of the following custom HTML. Adding this to your page will render an Upstox branded TradeButton .

The orders linked to each button must be added to the upstoxTradesConfig object under the correct button-name . To add more orders to static buttons after
page load use UpstoxButton.addOrderTobutton .

CUSTOM BUTTONS

<button upstox-tradebutton button-name=**buttonName** >Buy Reliance</button>


<a upstox-tradebutton button-name=**buttonName** href="#"> Click here to buy </a>

You can also configure custom buttons and hyperlinks to function as TradeButtons. Add the attributes upstox-tradebutton and button-name , and assign a
unique buttonName .

API
The plugin also includes an extensive API to add/manage TradeButtons dynamically on your page. The following methods are available as part of the API:

CREATING A BUTTON

UPSTOXBUTTON.CREATEBUTTON( <BUTTONNAME>, <TYPE> )

Parameter Remarks

buttonName String - this will be assigned as an attribute to the TradeButton, must be unique in the page

type String - ( 'tradebutton' / 'a' / 'button' ) - specify the type of button, defaults to 'tradebutton'

Returns Remarks

TradeButton JS object - Button successfully created (refer docs below)

false Button already exists / Error

Use the addOrder() method present on the created TradeButton object for adding orders to it.

ADDING AN ORDER TO A BUTTON

UPSTOXBUTTON.ADDORDERTOBUTTON( <BUTTONNAME>, <ORDER> )

Parameter Remarks

buttonName String - The button to which the order needs to be added

order JS Object - format as below

Returns Remarks

true Order added successfully

false Order addition unsuccessful / Button not found

CHECKING FOR EXISTANCE OF BUTTON ON PAGE

UPSTOXBUTTON.BUTTONEXISTS( <BUTTONNAME> )

Parameter Remarks

buttonName String

Returns Remarks

true Button with buttonName exists on page

false Button with buttonName does not exist on page

Configuring your TradeButtons


The upstoxTradesConfig acts as the main config object for all the buttons on your page.

In order to earn a share of the brokerage generated by your TradeButtons, it is necessary to include either your API Key or Referral code as shown to the right.

Each order associated with a TradeButton, is available in upstoxTradesConfig object. The format of every order must be as shown to the right

Param Exp

token The scrip token as per the exchange

exchange Currently supporting 'NSE' , 'NCD' , 'BSE' , 'BCD' , 'MCX'

series 'EQ' , 'FO'

quantity The quantity to trade (Must be a multiple of lot size for the scrip)

price The price at which the order should be placed (To be set as 0 for market orders)

side 'buy' or 'sell'

orderType Supported types are limit ( 'l' ), market ( 'm' ), Stop-Loss Limit ( 'sl' ), Stop-Loss Market ( 'sl-m' )

position Specify either order is Delivery ( 'd' ) or Intraday ( 'i' )

tif Can be 'day' or 'ioc'

triggerPrice Needed only for Stop-Loss orders, can be blank otherwise

Webhook (Postback)

Sample response

{
exchange: 'NSE_EQ',
token: 2885,
symbol: 'RELIANCE',
product: 'I',
order_type: 'L',
duration: 'DAY',
price: 0,
trigger_price: 0,
quantity: 1,
disclosed_quantity: 0,
transaction_type: 'B',
average_price: 0,
traded_quantity: 0,
message: '',
exchange_order_id: '1200000001405029',
parent_order_id: 'NA',
order_id: '170516000022221',
exchange_time: '16-May-2017 10:16:54',
time_in_micro: '1494910048512349',
status: 'open',
is_amo: false,
valid_date: '',
order_request_id: '2',
checksum : '500ba8b198d21f7ecea08aa2eb7da4b0'
}

The Postback API sends a POST request with order update as JSON payload to the registered postback_url of your app when an order’s status changes. This
enables you to get real-time updates to your orders.

RESPONSE

Response is same as order update. One more field is added in this response as checksum.

CHECKSUM

Checksum is the md5 hash of ( order_id + time_in_micro + api_secret ). Every time you receive an update, you should compute this checksum at your end
and match it with the one in the payload.

Note: The md5 hash ensures that you can verify the authenticity of the message. Only Upstox API can generate the correct checksum. We use MD5 to
compute the checksum. You can find MD5 implementations in your programming language of choice.
The JSON payload is posted as a raw HTTP POST body. You will have to read the raw body and then validate it.

Postback API works even when you are not logged in.

Websocket
The Upstox API websocket channel can be used to receive various types of push updates from the Upstox server. These updates include:

Order Update
Trade Update (Fill Report)
Quote Update

Connection

#Sample cURL call - only use for testing


#Please note that you may get disconnected after some time
curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Key: {random-number}" \
-H "Sec-WebSocket-Version: 13" \
--include \
--no-buffer \
'https://ws-api.upstox.com/?apiKey={your_api_key}&token={your_access_token}'

The connectSocket function in the libraries will create an always-on socket connection to the Upstox API servers. If you are using cURL, please be sure to
pass your your_api_key and your_access_token as parameters in the URL.

Socket-Params

curl \
-H 'authorization: Bearer {your_access_token}' \
-H 'x-api-key: {your_api_key}' \
-X GET 'https://api.upstox.com/live/socket-params/'

In our quest to make our socket connection more stable or rather avoiding disconnection, we tried altering some connection parameter at the client level from
the server so both ends of the network have good knowledge of each other. Developers using their own WebSocket library can use these parameters to make
their sockets less prone to disconnections, these are generic parameters which can be found on most of the WebSocket libraries.

Here is a brief intro of them

parameter description

keepalive It forces the underlying TCP connection to remain alive even if there is no transfer of packets for a specific period of time.

keepaliveInterval the interval till which the underlying TCP connection will try to make the connection alive.

Nagle algorithm buffers the packet to a certain extent before sending them in a burst, it reduces the total number of packets by
disableNagleAlgorithm increasing their size but at times it makes the networks silent. This is not good for live feeds so we should disable it in libraries
that provide it

autoAcceptConnections This parameter is specific to the Web Socket library of NodeJS SDK

keepaliveGracePeriod This parameter is specific to the Web Socket library of NodeJS SDK
parameter description

Web sockets send ping pong messages back and forth between server and client to make the connection alive. This parameter
pythonPingInterval
tells the number of seconds after which the client should send ping message

pythonPingTimeout This time determines the amount of time the server should wait for the pong message before disconnecting the socket

For the techies who are using a different Web socket library to connect to us should use these parameters. You should fetch these values and use them in
your Web socket before connecting.

Note: The above change is applicable to third party libraries. Our Python and NodeJS SDK’s are built in with this update.

Disconnection
Upstox API libraries allow you to disconnect the socket with a method

Events
ORDER UPDATE

The order update event comes with the message value of order_update

The response for the order update event is the same as an individual response in the order history command

TRADE UPDATE

The trade update event comes with the message value of fill_report

The response for the trade update event is the same as an individual response in the trade history command

QUOTE UPDATE

Quote updates come as binary values. You need to first decode the binary into a string. Each quote update is separated by the semi-colon ; character. Within
each quote update, each field is separated by commas ,

ON DISCONNECT EVENT

The disconnect event is available on Upstox libraries

ON ERROR EVENT

The error event is available on Upstox libraries

Errors

Error Code Meaning

400 Bad Request – Your request parameters are incorrect

401 Unauthorized – Your API key is wrong

403 Forbidden – The requested resource is hidden for administrators only

404 Not Found – The specified resource could not be found

405 Method Not Allowed – You tried to access a resource with an invalid method

406 Not Acceptable – You requested a format that isn’t json

410 Gone – The resource requested has been removed from our servers

429 Too Many Requests – You’re requesting too many resources! Slow down!

500 Internal Server Error – We had a problem with our server. Try again later.

503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.
Release notes

Change Link

Added support for postback (Webhook) Read more

Added feature to cancel multiple/all open orders Read more

Added socket parameters while making connection Read more

Added LTT in feed Read more

Added trade book Read more

Added support for indices Read more

Introducing Trade button Read more

Added support to fetch details for individual order using order ID Read more

Search instrument by token or symbol Read more

S-ar putea să vă placă și