Skip to main content

User

This page describes the user-related endpoints of the Trading API, including authentication, profile, margins, and logout.


Login Flow

To start the login process, navigate the user to:

https://api.blinkx.in/connect/login?v=3&api_key=YOUR_API_KEY

Authentication and token exchange

curl https://api.blinkx.in/SmartApi/session/token \
-H "X-Version: 3" \
-d "api_key=xxx" \
-d "request_token=yyy" \
-d "checksum=zzz"
{
"status": "success",
"data": {
"user_type": "individual",
"email": "XXXXXX",
"user_name": "Trading API",
"user_shortname": "Trading",
"broker": "JM Financial",
"exchanges": [
"NSE",
"NFO",
"BFO",
"CDS",
"BSE",
"MCX",
"BCD",
"MF"
],
"products": [
"CNC",
"NRML",
"MIS",
"BO",
"CO"
],
"order_types": [
"LIMIT",
"SL"
],
"avatar_url": "abc",
"user_id": "XX0000",
"api_key": "XXXXXX",
"access_token": "XXXXXX",
"public_token": "XXXXXXXX",
"enctoken": "XXXXXX",
"refresh_token": '',
"silo": '',
"login_time": "2021-01-01 16:15:14",
"meta": {
"demat_consent": "physical"
}
}
}

Request parameters

ParameterDescription
api_keyThe public API key
request_tokenThe one-time token obtained after the login flow. This token's lifetime is only a few minutes and it is meant to be exchanged for an access_token immediately after being obtained
checksumSHA-256 hash of (api_key + request_token + api_secret)

Response attributes

AttributeTypeDescription
user_idstringThe unique, permanent user id registered with the broker and the exchanges
user_namestringUser's real name
user_shortnamestringShortened version of the user's real name
emailstringUser's email
user_typestringUser's registered role at the broker. This will be individual for all retail users
brokerstringThe broker ID
exchangesstring[]Exchanges enabled for trading on the user's account
productsstring[]Margin product types enabled for the user
order_typesstring[]Order types enabled for the user
api_keystringThe API key for which the authentication was performed
access_tokenstringThe authentication token that's used with every subsequent request. Unless this is invalidated using the API, or invalidated by a master-logout from the BlinkX Web trading terminal, it'll expire at 6 AM on the next day (regulatory requirement)
public_tokenstringA token for public session validation where requests may be exposed to the public
refresh_tokenstringA token for getting long-standing read permissions. This is only available to certain approved platforms
login_timestringUser's last login time
metamapdemat_consent: empty, consent or physical
avatar_urlstringFull URL to the user's avatar (PNG image) if there's one

Signing requests

Once the authentication is complete, all requests should be signed with the HTTP Authorization header with token as the authorisation scheme, followed by a space, and then the api_key:access_token combination. For example:


User profile

While a successful token exchange returns the full user profile, it's possible to retrieve it any point of time with the /user/profile API. Do note that the profile API does not return any of the tokens.

curl https://api.blinkx.in/SmartApi/user/profile \
-H "X-Version: 3" \
-H "Authorization: token api_key:access_token"
{
"status": "success",
"data": {
"user_id": "AB1234",
"user_type": "individual",
"email": "xxxyyy@gmail.com",
"user_name": "AxAx Bxx",
"user_shortname": "AxAx",
"broker": "JM Financial",
"exchanges": [
"BFO",
"MCX",
"NSE",
"CDS",
"BSE",
"BCD",
"MF",
"NFO"
],
"products": [
"CNC",
"NRML",
"MIS",
"BO",
"CO"
],
"order_types": [
"LIMIT",
"SL"
],
"avatar_url": null,
"meta": {
"demat_consent": "physical"
}
}
}

Response attributes

AttributeTypeDescription
user_idstringThe unique, permanent user id registered with the broker and the exchanges
user_namestringUser's real name
user_shortnamestringShortened version of the user's real name
emailstringUser's email
user_typestringUser's registered role at the broker. This will be individual for all retail users
brokerstringThe broker ID
exchangesstring[]Exchanges enabled for trading on the user's account
productsstring[]Margin product types enabled for the user
order_typesstring[]Order types enabled for the user
metamapdemat_consent: empty, consent or physical
avatar_urlstringFull URL to the user's avatar (PNG image) if there's one

Funds and margins

A GET request to /user/margins returns funds, cash, and margin information for the user for equity and commodity segments.

A GET request to /user/margins/:segment returns funds, cash, and margin information for the user. segment in the URI can be either equity or commodity.

curl "https://api.blinkx.in/SmartApi/user/margins" \
-H "X-Version: 3" \
-H "Authorization: token api_key:access_token"
{
"status": "success",
"data": {
"equity": {
"enabled": true,
"net": 99725.05000000002,
"available": {
"adhoc_margin": 0,
"cash": 245431.6,
"opening_balance": 245431.6,
"live_balance": 99725.05000000002,
"collateral": 0,
"intraday_payin": 0
},
"utilised": {
"debits": 145706.55,
"exposure": 38981.25,
"m2m_realised": 761.7,
"m2m_unrealised": 0,
"option_premium": 0,
"payout": 0,
"span": 101989,
"holding_sales": 0,
"turnover": 0,
"liquid_collateral": 0,
"stock_collateral": 0,
"delivery": 0
}
},
"commodity": {
"enabled": true,
"net": 100661.7,
"available": {
"adhoc_margin": 0,
"cash": 100661.7,
"opening_balance": 100661.7,
"live_balance": 100661.7,
"collateral": 0,
"intraday_payin": 0
},
"utilised": {
"debits": 0,
"exposure": 0,
"m2m_realised": 0,
"m2m_unrealised": 0,
"option_premium": 0,
"payout": 0,
"span": 0,
"holding_sales": 0,
"turnover": 0,
"liquid_collateral": 0,
"stock_collateral": 0,
"delivery": 0
}
}
}
}

Response attributes

AttributeTypeDescription
m2m_unrealisedfloat64Un-booked (open) intraday profits and losses
m2m_realisedfloat64Booked intraday profits and losses
debitsfloat64Sum of all utilised margins (unrealised M2M + realised M2M + SPAN + Exposure + Premium + Holding sales)
spanfloat64SPAN margin blocked for all open F&O positions
option_premiumfloat64Value of options premium received by shorting
holding_salesfloat64Value of holdings sold during the day
exposurefloat64Exposure margin blocked for all open F&O positions
liquid_collateralfloat64Margin utilised against pledged liquidbees ETFs and liquid mutual funds
deliveryfloat64Margin blocked when you sell securities (20% of the value of stocks sold) from your demat or T1 holdings
stock_collateralfloat64Margin utilised against pledged stocks/ETFs
turnoverfloat64Utilised portion of the maximum turnover limit (only applicable to certain clients)
payoutfloat64Funds paid out or withdrawn to bank account during the day

Logout

This call invalidates the access_token and destroys the API session. After this, the user should be sent through a new login flow before further interactions. This does not log the user out of the official BlinkX web or mobile applications.

curl --request DELETE \
-H "X-Version: 3" \
"https://api.blinkx.in/SmartApi/session/token?api_key=xxx&access_token=yyy"
{
"status": "success",
"data": true
}