NAV Navbar
json

Introduction

Welcome to the Web API documentation for AliceBlue

Base URL

Base URL for the API will be: https://ant.aliceblueonline.com

Authentication

We are using oauth2 authentication protocol for our apis. You have to use an oauth2 client library in a language of your choice.
Grant type: Authorization Authorization endpoint: /oauth2/auth Access token endpoint: /oauth2/token You will also need client id and client secret which will be provided by us.

After the access token is obtained following header needs to be sent with every request until unless mentioned.

Authorization: Bearer {access_token}

Replace {access_token} with the access token obtained for the user.

In case the access_token got expired, 401 HTTP status will be sent in response for any request in which case a new access token has to be obtained.

Interactive API

Profile

Endpoint to get user profile.

URL

GET /api/v2/profile

Response

{
   "status":"success",
   "message":"",
   "data":{
      "pan_number":"ABCDE1234",
      "name":"ABC",
      "login_id":"S127",
      "exchanges":[
         "BSE",
         "MCX",
         "CDS",
         "NSE",
         "NFO"
      ],
      "email_address":"abc@xyz.in",
      "dp_ids":[
         "123456789"
      ],
      "broker_name":"SOUTHASIAN",
      "banks":[
         {
            "branch_name":"",
            "bank_name":"ABC",
            "account_id":"S127"
         },
         {
            "branch_name":"",
            "bank_name":" ",
            "account_id":"S127"
         },
         {
            "branch_name":"",
            "bank_name":" ",
            "account_id":"S127"
         },
         {
            "branch_name":"",
            "bank_name":" ",
            "account_id":"S127"
         },
         {
            "branch_name":"",
            "bank_name":"XYZ",
            "account_id":"S127"
         },
         {
            "branch_name":"",
            "bank_name":"ABC",
            "account_id":"S127"
         }
      ],
      "backoffice_enabled":true
   }
}
Field Type Description
pan_number string PAN Number of User
name string Name
login_id string Login ID
exchanges array of string Exchanges the user subscribed to
email_address string Email Address
dp_ids array of string DP Ids
broker_name string Broker Name
banks array of objects Contains array of bank details
backoffice_enabled boolean Denotes whether API is integrated with Backoffice

Place order

Endpoint for placing regular and cover order.

URL

POST /api/v2/order

Request

{  
   "exchange":"NSE",
   "order_type":"MARKET",
   "instrument_token":11460,
   "quantity":1,
   "disclosed_quantity":0,
   "price":0,
   "transaction_type":"BUY",
   "trigger_price":0,
   "validity":"DAY",
   "product":"CNC",
   "source":"web",
   "order_tag": "order1"
}
Field Type Mandatory Description
exchange string yes Exchange segment. See Appendix for supported exchange segments.
order_type string yes Order Type. See Appendix for supported exchange segments.
instrument_token integer yes Unique token issued by the exchange for the instrument
quantity integer yes Quantity
disclosed_quantity integer yes Disclosed quantity
price float yes Price
transaction_type string yes Order side
trigger_price float yes Trigger price
validity string yes Validity of order. See Appendix for supported validities.
product string yes Product Type. See Appendix for supported product types.
source string yes Device Type. It can be either web or mob
order_tag string no Any random data can be sent which will be stored with the order and can be used to query the order history

Response

{  
   "status":"success",
   "message":"Order placed successfully",
   "data":{  
      "oms_order_id":"180806000047513"
   }
}
Field Type Description
oms_order_id string Unique Order Id

Place AMO

Endpoint for placing regular and cover AMO .

URL

POST /api/v2/amo

Request

{  
   "exchange":"NSE",
   "order_type":"MARKET",
   "instrument_token":11460,
   "quantity":1,
   "disclosed_quantity":0,
   "price":0,
   "transaction_type":"BUY",
   "trigger_price":0,
   "validity":"DAY",
   "product":"CNC",
   "source":"web",
   "order_tag": "order1"
}
Field Type Mandatory Description
exchange string yes Exchange segment. See Appendix for supported exchange segments.
order_type string yes Order Type. See Appendix for supported exchange segments.
instrument_token integer yes Unique token issued by the exchange for the instrument.
quantity integer yes Quantity
disclosed_quantity integer yes Disclosed quantity
price float yes Price
transaction_type string yes Order side
trigger_price float yes Trigger price
validity string yes Validity of order. See Appendix for supported validities.
product string yes Product Type. See Appendix for supported product types.
source string yes Device Type. It can be either web or mob
order_tag string no Any random data can be sent which will be stored with the order and can be used to query the order history

Response

{  
   "status":"success",
   "message":"Order placed successfully",
   "data":{  
      "oms_order_id":"180806000048741"
   }
}
Field Type Description
oms_order_id string Unique Order Id

Place Bracket Order

Endpoint for placing bracket order

URL

POST /api/v2/bracketorder

Request

{  
   "exchange": "NFO",
   "instrument_token": 47308,
   "transaction_type": "BUY",
   "quantity": 40,
   "disclosed_quantity": 0,
   "validity":"DAY",
   "square_off_value": 28000.50,
   "stop_loss_value": 27900.10,
   "price": 27956.50,
   "source": "web",
   "order_type": "LIMIT",
   "trailing_stop_loss": 1,
   "order_tag": "order1"
}

Field Type Mandatory Description
exchange string yes Exchange segment. See Appendix for supported exchange segments.
order_type string yes Order Type. See Appendix for supported exchange segments.
instrument_token integer yes Unique token issued by the exchange for the instrument
quantity integer yes Quantity
disclosed_quantity integer yes Disclosed quantity
price float yes Price
transaction_type string yes Order side
validity string yes Validity of order. See Appendix for supported validities.
source string yes Device Type. It can be either web or mob
square_off_value float yes Square off Value in Absolute price.
stop_loss_value float yes Stop loss value in Absoulte price.
trailing_stop_loss float no Trailing stop loss in relative price.
order_tag string no Any random data can be sent which will be stored with the order and can be used to query the order history

Response

{  
   "status":"success",
   "message":"",
   "data":{  
      "oms_order_id":"180806000064102"
   }
}
Field Type Description
oms_order_id string Unique Order Id

Place Basket Order

CO and BO orders are not supported in the basket order API.

URL

POST /api/v2/basketorder

Request

{
    "source": "web",
    "orders": [
        {
            "exchange": "NSE",
            "order_type": "MARKET",
            "instrument_token": 22,
            "quantity": 6,
            "disclosed_quantity": 0,
            "price": 0,
            "transaction_type": "BUY",
            "trigger_price": 0,
            "validity": "DAY",
            "product": "CNC"

        },
            {
            "exchange": "BSE",
            "order_type": "MARKET",
            "instrument_token": 500285,
            "quantity": 3,
            "disclosed_quantity": 0,
            "price": 0,
            "transaction_type": "BUY",
            "trigger_price": 0,
            "validity": "DAY",
            "product": "CNC"
        }

    ]
}
Field Type Mandatory Description
exchange string yes Exchange segment. See Appendix for supported exchange segments.
order_type string yes Order Type. See Appendix for supported exchange segments.
instrument_token integer yes Unique token issued by the exchange for the instrument
quantity integer yes Quantity
disclosed_quantity integer yes Disclosed quantity
price float yes Price
transaction_type string yes Order side
trigger_price float yes Trigger price
validity string yes Validity of order. See Appendix for supported validities.
product string yes Product Type. See Appendix for supported product types.
source string yes Device Type. It can be either web or mob

Response

{
    "status": "success",
    "message": "Order placed successfully",
    "data": {}
}

Modify order

Endpoint to modify order

URL

PUT /api/v2/order

Request

{
  "oms_order_id": "180807000042019",
  "instrument_token": 11460,
  "exchange": "NSE",
  "transaction_type": "BUY",
  "product": "CNC",
  "validity": "DAY",
  "order_type": "LIMIT",
  "price": 13.6,
  "trigger_price": 0,
  "quantity": 1,
  "disclosed_quantity": 0
}
Field Type Mandatory Description
oms_order_id string yes Unique Order Id
instrument_token integer yes Unique token issued by the exchange for the instrument
exchange string yes Exchange segment. See Appendix for supported exchange segments.
order_type string yes Order Type. See Appendix for supported exchange segments.
quantity integer yes Quantity
disclosed_quantity integer yes Disclosed quantity
price float yes Price
transaction_type string yes Order side
trigger_price float yes Trigger price
product string yes Product Type. See Appendix for supported product types.
validity string yes Validity of order. See Appendix for supported validities.

Response

{
  "status": "success",
  "message": "",
  "data": {
    "oms_order_id": [
      "180807000042019"
    ]
  }
}
Field Type Description
oms_order_id string Unique Order Id

Cancel order

Endpoint to cancel order

URL

DELETE /api/v2/order?oms_order_id=180807000042019&order_status=open

Response

{
  "status": "success",
  "message": "",
  "data": {
    "status": "Ok"
  }
}

Order History

Endpoint to get order history

URL

GET api/v2/order/{oms_order_id}

Response

{
  "status": "success",
  "message": "",
  "data": [
    {
      "validity": "DAY",
      "trigger_price": 0.0,
      "transaction_type": "B",
      "trading_symbol": "HDFC-EQ",
      "quantity_to_fill": 1,
      "product": "NRML",
      "price_to_fill": 12.1,
      "order_status": "rejected",
      "oms_order_id": "181113000010455",
      "nest_request_id": null,
      "exchange_time": "--",
      "exchange_order_id": null,
      "exchange": "NSE",
      "disclosed_quantity": "0",
      "average_price": 0.0
    },
    {
      "validity": "DAY",
      "trigger_price": 0.0,
      "transaction_type": "B",
      "trading_symbol": "HDFC-EQ",
      "quantity_to_fill": 1,
      "product": "NRML",
      "price_to_fill": 12.1,
      "order_status": "put order req received",
      "oms_order_id": "181113000010455",
      "nest_request_id": null,
      "exchange_time": "--",
      "exchange_order_id": null,
      "exchange": "NSE",
      "disclosed_quantity": "0",
      "average_price": 0.0
    }
  ]
}

Order History with Tag

URL

GET api/v2/order/tag/{order_tag}

Response

{
  "status": "success",
  "message": "",
  "data": [
    {
      "validity": "DAY",
      "trigger_price": 0.0,
      "transaction_type": "B",
      "trading_symbol": "HDFC-EQ",
      "quantity_to_fill": 1,
      "product": "NRML",
      "price_to_fill": 12.1,
      "order_status": "rejected",
      "oms_order_id": "181113000010455",
      "nest_request_id": null,
      "exchange_time": "--",
      "exchange_order_id": null,
      "exchange": "NSE",
      "disclosed_quantity": "0",
      "average_price": 0.0
    },
    {
      "validity": "DAY",
      "trigger_price": 0.0,
      "transaction_type": "B",
      "trading_symbol": "HDFC-EQ",
      "quantity_to_fill": 1,
      "product": "NRML",
      "price_to_fill": 12.1,
      "order_status": "put order req received",
      "oms_order_id": "181113000010455",
      "nest_request_id": null,
      "exchange_time": "--",
      "exchange_order_id": null,
      "exchange": "NSE",
      "disclosed_quantity": "0",
      "average_price": 0.0
    }
  ]
}

Scripinfo

Endpoint to get scripinfo

URL

GET api/v2/scripinfo?exchange=MCX&instrument_token=47308

Response

{  
   "status":"success",
   "message":"",
   "data":{  
      "permitted_to_trade": null,
      "warning": 0.0,
      "price_quotation": "NA",
      "series": "XX",
      "price_units": "NA",
      "list_date": "1 Jun, 2018 - 0:0:0",
      "symbol": "BANKNIFTY18AUGFUT",
      "circuit_rating": "            ",
      "exchange": "NFO",
      "im_spread_benifit": null,
      "last_trading_date": "06 August, 2018 15:29:59",
      "remarks": "NA",
      "expulsion_date": "1 Jan, 1980",
      "record_date": "1 Jan, 1980",
      "tick_size": 0.05,
      "general_numerator": "1",
      "board_lot_quantity": "40",
      "open_interest": 2744360,
      "dpr": "24999.20-30554.55",
      "buy_var_margin": "NA",
      "expiry_date": "30 Aug, 2018 - 14:30:0",
      "issue_rate": 0,
      "delivery_units": "NA",
      "readmdate": "1 Jan, 1980",
      "lower_circuit_limit": 24999.2,
      "freeze": 2501.0,
      "price_numerator": "1",
      "max_order_size": "2501",
      "higher_circuit_limit": 30554.55,
      "tender_period_start_date": "NA",
      "tender_period_end_date": "NA",
      "market_type": "NA",
      "issue_start_date": "1 Jun, 2018",
      "issue_maturity_date": "30 Aug, 2018 - 14:30:0",
      "book_cls_start_time": "1 Jan, 1980",
      "general_denominator": "1",
      "delivery_start_date": "1 Jan, 1980",
      "instrument_type": "FUTIDX",
      "int_pay_date": "1 Jan, 1980",
      "issue_capital": null,
      "delivery_end_date": "1 Jan, 1980",
      "price_denominator": null,
      "sell_var_margin": "NA",
      "other_buy_margin": "NA",
      "other_sell_margin": "NA",
      "comments": "NA",
      "nodel_start_date": "1 Jan, 1980",
      "quantity_units": "NA",
      "exposure_margin": null,
      "nodel_end_time": null,
      "local_update_time": "06 August, 2018 15:30:00"
   }
}

Orderbook

Endpoint to get orderbook

URL

GET api/v2/order

Response

{
  "status": "success",
  "message": "",
  "data": {
    "pending_orders": [],
    "completed_orders": [
      {
        "validity": "DAY",
        "user_order_id": "1",
        "trigger_price": 0.0,
        "transaction_type": "BUY",
        "trading_symbol": "HDFC-EQ",
        "remaining_quantity": 1,
        "rejection_reason": "user privilege is view only",
        "quantity": 1,
        "product": "NRML",
        "price": 12.1,
        "order_type": "LIMIT",
        "order_tag": "HDFC-ORDER2",
        "order_status": "rejected",
        "order_entry_time": 1542088664,
        "oms_order_id": "181113000010455",
        "nest_request_id": "1",
        "lotsize": 1,
        "login_id": "HO786",
        "leg_order_indicator": "",
        "instrument_token": "1330",
        "filled_quantity": 0,
        "exchange_time": 0,
        "exchange_order_id": "NA",
        "exchange": "NSE",
        "disclosed_quantity": 0,
        "client_id": "HO786",
        "average_price": 0.0
      },
      {
        "validity": "DAY",
        "user_order_id": "1",
        "trigger_price": 0.0,
        "transaction_type": "BUY",
        "trading_symbol": "HDFC-EQ",
        "remaining_quantity": 1,
        "rejection_reason": "user privilege is view only",
        "quantity": 1,
        "product": "NRML",
        "price": 12.1,
        "order_type": "LIMIT",
        "order_tag": "",
        "order_status": "rejected",
        "order_entry_time": 1542088549,
        "oms_order_id": "181113000010338",
        "nest_request_id": "1",
        "lotsize": 1,
        "login_id": "HO786",
        "leg_order_indicator": "",
        "instrument_token": "1330",
        "filled_quantity": 0,
        "exchange_time": 0,
        "exchange_order_id": "NA",
        "exchange": "NSE",
        "disclosed_quantity": 0,
        "client_id": "HO786",
        "average_price": 0.0
      },
      {
        "validity": "DAY",
        "user_order_id": "1",
        "trigger_price": 0.0,
        "transaction_type": "BUY",
        "trading_symbol": "ACC-EQ",
        "remaining_quantity": 1,
        "rejection_reason": "user privilege is view only",
        "quantity": 1,
        "product": "NRML",
        "price": 12.1,
        "order_type": "LIMIT",
        "order_tag": "",
        "order_status": "rejected",
        "order_entry_time": 1542088500,
        "oms_order_id": "181113000010283",
        "nest_request_id": "1",
        "lotsize": 1,
        "login_id": "HO786",
        "leg_order_indicator": "",
        "instrument_token": "22",
        "filled_quantity": 0,
        "exchange_time": 0,
        "exchange_order_id": "NA",
        "exchange": "NSE",
        "disclosed_quantity": 0,
        "client_id": "HO786",
        "average_price": 0.0
      }
    ]
  }
}
Field Type Description
exchange string Exchange segment. See Appendix for supported exchange segments.
order_type string Order Type. See Appendix for supported exchange segments.
instrument_token string Unique token issued by the exchange for the instrument
quantity integer Quantity
disclosed_quantity integer Disclosed quantity
price float Price
transaction_type string Order side
validity string Validity of order. See Appendix for supported validities.
trigger_price float Trigger price
trading_symbol string Trading symbol
remaining_quantity integer Remaining quantity
rejection_reason string Reason for order rejection. Will be present only incase of REJECTED orders.
product string Product
order_status string Order status
order_entry_time integer Order entry time(in unix time)
oms_order_id string Unique order id
lotsize integer Lot size of the instrument
login_id string Login Id of the user who placed the order
client_id string Client Id of the user on behalf the order is placed
leg_order_indicator string Indicates which leg the order belongs to incase of BO.
filled_quantity integer Traded quantity
exchange_time integer Exchange Timestamp(in unix time)
exchange_order_id string Unique order id given by exchange
average_price string Average Trade Price
order_tag string Any random data can be sent which will be stored with the order and can be used to query the order history

Tradebook

Endpoint to get tradebook

URL

GET api/v2/trade

Response

{  
   "status":"success",
   "message":"",
   "data":{  
      "trades":[  
         {  
            "user_order_id":"1",
            "transaction_type":"BUY",
            "trading_symbol":"JPASSOCIAT-EQ",
            "trade_price":15.1,
            "trade_id":"27411730",
            "product":"CNC",
            "order_entry_time":1533544142,
            "oms_order_id":"180806000047513",
            "instrument_token":"11460",
            "filled_quantity":1,
            "exchange_time":1533544141,
            "exchange_order_id":"1100000004487278",
            "exchange":"NSE"
         },
         {  
            "user_order_id":"1",
            "transaction_type":"BUY",
            "trading_symbol":"JPASSOCIAT-EQ",
            "trade_price":15.1,
            "trade_id":"27374476",
            "product":"CNC",
            "order_entry_time":1533543811,
            "oms_order_id":"180806000046877",
            "instrument_token":"11460",
            "filled_quantity":1,
            "exchange_time":1533543809,
            "exchange_order_id":"1100000004424792",
            "exchange":"NSE"
         },
         {  
            "user_order_id":"1",
            "transaction_type":"BUY",
            "trading_symbol":"COPPER18AUG450CE",
            "trade_price":1.95,
            "trade_id":"410004065",
            "product":"NRML",
            "order_entry_time":1533533928,
            "oms_order_id":"180806000026440",
            "instrument_token":"210471",
            "filled_quantity":1,
            "exchange_time":1533533928,
            "exchange_order_id":"231821800028879",
            "exchange":"MCX"
         },
         {  
            "user_order_id":"1",
            "transaction_type":"BUY",
            "trading_symbol":"CRUDEOILM18SEPFUT",
            "trade_price":4656.0,
            "trade_id":"310007436",
            "product":"NRML",
            "order_entry_time":1533533928,
            "oms_order_id":"180806000026439",
            "instrument_token":"210108",
            "filled_quantity":1,
            "exchange_time":1533533928,
            "exchange_order_id":"231821800028878",
            "exchange":"MCX"
         },
         {  
            "user_order_id":"1",
            "transaction_type":"SELL",
            "trading_symbol":"CRUDEOILM18AUGFUT",
            "trade_price":4716.0,
            "trade_id":"310007435",
            "product":"NRML",
            "order_entry_time":1533533928,
            "oms_order_id":"180806000026438",
            "instrument_token":"210032",
            "filled_quantity":1,
            "exchange_time":1533533928,
            "exchange_order_id":"231821800028877",
            "exchange":"MCX"
         }
      ]
   }
}
Field Type Description
exchange string Exchange segment. See Appendix for supported exchange segments.
instrument_token string Unique token issued by the exchange for the instrument
trade_price float Price at which the trade executed
trade_id string Unique id issued by exchange for the trade
product string Product Type
order_entry_time integer Entry time of order into OMS
filled_quantity integer Traded Quantity
exchange_time integer Exchange Timestamp when trade executed
exchange_order_id string Unique order id issued by exchange
oms_order_id string Unique order id
transaction_type string Transaction Type(It can be either BUY or SELL)

Cash Positions

Endpoint to get cash position

URL

GET api/v2/cashposition

Response

{  
   "status":"success",
   "message":"",
   "data":{  
      "cash_positions":[  
         {  
            "utilized":{  
               "var_margin":"0.00",
               "unrealised_m2m":"-0.00",
               "span_margin":"0.00",
               "realised_m2m":"-0.00",
               "premium_present":"1950.000000",
               "pay_out":"0.00",
               "multiplier":"1.00",
               "exposure_margin":"0.00",
               "elm":"0.00",
               "debits":"1959.37"
            },
            "segment":"COM",
            "net":"-1959.37",
            "category":"COMMODITY_OPTIONS",
            "available":{  
               "pay_in":"0",
               "notionalCash":"0.000000",
               "direct_collateral_value":"0.00",
               "credits":"0.00",
               "collateral_value":"0.00",
               "cashmarginavailable":"0.00",
               "adhoc_margin":"0.000000"
            }
         },
         {  
            "utilized":{  
               "var_margin":"0.00",
               "unrealised_m2m":"-0.00",
               "span_margin":"0.00",
               "realised_m2m":"-0.00",
               "premium_present":"0",
               "pay_out":"0.00",
               "multiplier":"1.00",
               "exposure_margin":"0.00",
               "elm":"0.00",
               "debits":"30.20"
            },
            "segment":"ALL",
            "net":"1969.80",
            "category":"EQUITY1",
            "available":{  
               "pay_in":"0",
               "notionalCash":"0.000000",
               "direct_collateral_value":"0.00",
               "credits":"2000.00",
               "collateral_value":"0.00",
               "cashmarginavailable":"0.00",
               "adhoc_margin":"2000.000000"
            }
         }
      ]
   }
}
Field Type Description
utilized object Contains utilized margins
var_margin string Var Margin
span_margin string Span Margin
unrealised_m2m string Unrealized M2M
realised_m2m string Realised M2M
premium_present string Premium Present
pay_out string Pay Out
multiplier string Multiplier
exposure_margin string Exposure margin
elm string ELM
debits string Debits
segment string Segment
net string Net Margin
category string Category
available object Contains avaliable margins
pay_in string Pay In
notionalCash string Notional cash
direct_collateral_value string Direct Collateral Value
credits string Credits
collateral_value string Collateral value
cashmarginavailable string Cash margin available
adhoc_margin string Adhoc Margin

Daywise positions

Endpoint to get daywise position

URL

GET api/v2/positions?type=daywise

Response

{  
   "status":"success",
   "message":"",
   "data":{  
      "positions":[  
         {  
            "unrealised_pnl":"-250.00",
            "trading_symbol":"COPPER18AUG450CE",
            "total_sell_quantity":0,
            "total_buy_quantity":1,
            "strike_price":"450.0",
            "sell_quantity":"0",
            "sell_amount":"0.0",
            "realised_pnl":"0.00",
            "product":"NRML",
            "oms_order_id":null,
            "net_quantity":1,
            "net_amount":-1950.0,
            "multiplier":1,
            "m2m":"-250.00",
            "ltp":1.7,
            "instrument_token":"210471",
            "fill_id":null,
            "exchange":"MCX",
            "enabled":true,
            "close_price":1.95,
            "client_id":"S127",
            "cf_sell_quantity":0,
            "cf_buy_quantity":0,
            "cf_average_sell_price": 0.0,
            "cf_average_buy_price": 0.0,
            "buy_quantity":"1",
            "buy_amount":"1950.0",
            "bep":"1.95",
            "average_sell_price":"0.0",
            "average_buy_price":"1.95"
         },
         {
            "unrealised_pnl":"-620.00",
            "trading_symbol":"CRUDEOILM18AUGFUT",
            "total_sell_quantity":1,
            "total_buy_quantity":0,
            "strike_price":"0",
            "sell_quantity":"1",
            "sell_amount":"47160.0",
            "realised_pnl":"0.00",
            "product":"NRML",
            "oms_order_id":null,
            "net_quantity":-1,
            "net_amount":47160.0,
            "multiplier":1,
            "m2m":"-620.00",
            "ltp":4778.0,
            "instrument_token":"210032",
            "fill_id":null,
            "exchange":"MCX",
            "enabled":true,
            "close_price":4716.0,
            "client_id":"S127",
            "cf_sell_quantity":0,
            "cf_buy_quantity":0,
            "cf_average_sell_price":0,
            "cf_average_buy_price":0,
            "buy_quantity":"0",
            "buy_amount":"0.0",
            "bep":"4,716.00",
            "average_sell_price":"4716.0",
            "average_buy_price":"0.0"
         }
      ]
   }
}

Netwise positions

Endpoint to get netwise position

URL

GET api/v2/positions?type=netwise

Response

{
  "status": "success",
  "message": "",
  "data": {
    "positions": [
      {
        "unrealised_pnl": "0.00",
        "trading_symbol": "COPPER18AUG450CE",
        "total_sell_quantity": 1,
        "total_buy_quantity": 1,
        "strike_price": "450.0",
        "sell_quantity": "0",
        "sell_amount": "2570.0",
        "realised_pnl": "840.00",
        "product": "NRML",
        "oms_order_id": null,
        "net_quantity": 0,
        "net_amount": 620,
        "multiplier": 1,
        "m2m": "840.00",
        "ltp": 1.7,
        "instrument_token": "210471",
        "fill_id": null,
        "exchange": "MCX",
        "enabled": true,
        "close_price": 0,
        "client_id": "S127",
        "cf_sell_quantity": 1,
        "cf_buy_quantity": 0,
        "cf_average_sell_price": 2.57,
        "cf_average_buy_price": 0,
        "buy_quantity": "1",
        "buy_amount": "1950.0",
        "bep": "0.00",
        "average_sell_price": "2.57",
        "average_buy_price": "1.95"
      },
      {
        "unrealised_pnl": "0.00",
        "trading_symbol": "CRUDEOILM18AUGFUT",
        "total_sell_quantity": 1,
        "total_buy_quantity": 1,
        "strike_price": "0",
        "sell_quantity": "1",
        "sell_amount": "47160.0",
        "realised_pnl": "300.00",
        "product": "NRML",
        "oms_order_id": null,
        "net_quantity": 0,
        "net_amount": -250,
        "multiplier": 1,
        "m2m": "300.00",
        "ltp": 4782,
        "instrument_token": "210032",
        "fill_id": null,
        "exchange": "MCX",
        "enabled": true,
        "close_price": 0,
        "client_id": "S127",
        "cf_sell_quantity": 0,
        "cf_buy_quantity": 1,
        "cf_average_sell_price": 0,
        "cf_average_buy_price": 4741,
        "buy_quantity": "0",
        "buy_amount": "47410.0",
        "bep": "0.00",
        "average_sell_price": "4716.0",
        "average_buy_price": "4741.0"
      },
      {
        "unrealised_pnl": "0.00",
        "trading_symbol": "CRUDEOILM18SEPFUT",
        "total_sell_quantity": 1,
        "total_buy_quantity": 1,
        "strike_price": "0",
        "sell_quantity": "0",
        "sell_amount": "46730.0",
        "realised_pnl": "-300.00",
        "product": "NRML",
        "oms_order_id": null,
        "net_quantity": 0,
        "net_amount": 170,
        "multiplier": 1,
        "m2m": "-300.00",
        "ltp": 4718,
        "instrument_token": "210108",
        "fill_id": null,
        "exchange": "MCX",
        "enabled": true,
        "close_price": 0,
        "client_id": "S127",
        "cf_sell_quantity": 1,
        "cf_buy_quantity": 0,
        "cf_average_sell_price": 4673,
        "cf_average_buy_price": 0,
        "buy_quantity": "1",
        "buy_amount": "46560.0",
        "bep": "0.00",
        "average_sell_price": "4673.0",
        "average_buy_price": "4656.0"
      },
      {
        "unrealised_pnl": "-0.10",
        "trading_symbol": "JPASSOCIAT-EQ",
        "total_sell_quantity": 0,
        "total_buy_quantity": 2,
        "strike_price": "0",
        "sell_quantity": "0",
        "sell_amount": "0.0",
        "realised_pnl": "0.00",
        "product": "CNC",
        "oms_order_id": null,
        "net_quantity": 2,
        "net_amount": -30.2,
        "multiplier": 1,
        "m2m": "-0.10",
        "ltp": 15.05,
        "instrument_token": "11460",
        "fill_id": null,
        "exchange": "NSE",
        "enabled": true,
        "close_price": 15.1,
        "client_id": "S127",
        "cf_sell_quantity": 0,
        "cf_buy_quantity": 0,
        "cf_average_sell_price": 0,
        "cf_average_buy_price": 0,
        "buy_quantity": "2",
        "buy_amount": "30.2",
        "bep": "15.10",
        "average_sell_price": "0.0",
        "average_buy_price": "15.1"
      }
    ]
  }
}

Holdings

Endpoint to get holdings

URL

GET api/v2/holdings

Response

{
  "status": "success",
  "message": "",
  "data": {
    "holdings": [
      {
        "withheld_qty": "0",
        "used_quantity": "0",
        "trading_symbol": "GMRINFRA-EQ",
        "target_product": "NA",
        "t1_quantity": "0",
        "quantity": "1",
        "product": "CNC",
        "price": "0.00",
        "nse_ltp": "17.90",
        "isin": "INE776C01039",
        "instrument_token": "13528",
        "holding_update_quantity": "0",
        "haircut": "0.00",
        "exchange": "NSE",
        "collateral_update_quantity": "0",
        "collateral_type": "--",
        "collateral_quantity": "0",
        "client_id": "S127",
        "buy_avg": 14.95,
        "bse_ltp": "17.85"
      },
      {
        "withheld_qty": "0",
        "used_quantity": "0",
        "trading_symbol": "JPASSOCIAT-EQ",
        "target_product": "NA",
        "t1_quantity": "0",
        "quantity": "3",
        "product": "CNC",
        "price": "0.00",
        "nse_ltp": "15.00",
        "isin": "INE455F01025",
        "instrument_token": "11460",
        "holding_update_quantity": "0",
        "haircut": "0.00",
        "exchange": "NSE",
        "collateral_update_quantity": "0",
        "collateral_type": "--",
        "collateral_quantity": "0",
        "client_id": "S127",
        "buy_avg": 15.37,
        "bse_ltp": "14.96"
      }
    ]
  }
}

Feeds API

This is the websocket API for marketfeeds.

Every message sent to the server should have following format.

{"a": "subscribe", "v": [[13, 1], [12, 1]], "m": "marketdata"}

or

{"a": "subscribe", "v": [1, 2], "m": "market_status"}
Field Description
a Action to be performed
v Array of [exchange, token] pairs or exchange codes(for only market status and exchange messages)
m mode

Messages from the server

All messages from the server are in binary until unless mentioned. It has the following structure.

Position Type Field
0 - 1 bytes int8 Mode(see Modes below for the codes)
1-length binary Message structure. See below for individual message structures.

API URL

wss://[base_url]/hydrasocket/v2/websocket?access_token={access_token}

{access_token} is the token obtained for the user using OAuth2.

Exchanges

Hydra currently supports following exchanges.

Exchange Code Multipler
NSE 1 100
NFO 2 100
CDS 3 10000000
MCX 4 100
BSE 6 100
BFO 7 100

All prices should be divided by Multiplier

Modes

Hydra has following modes

Mode Code
"marketdata" 1
"compact_marketdata" 2
"snapquote" 3
"full_snapquote" 4
"spreaddata" 5
"spread_snapquote" 6
"dpr" 7
"oi" 8
"market_status" 9
"exchange_messages" 10

Only these modes can be subscribed or unsubscribed.

Actions

There are three type of actions.

Action Description
subscribe Subscribes to data
unsubscribe Unsubscribes to data
h Heartbeat

Heartbeat

A heartbeat message has to be sent every 10 seconds to keep the connection alive. If a heartbeat is not sent, server will close the connection automatically.

{"a": "h", "v": [], "m": ""}

Marketdata

You can subscribe to marketdata for multiple instruments at the same time.

Example Subscription

{"a": "subscribe", "v": [[1, 22], [1, 1330]], "m": "marketdata"}

For unsubscription, a needs to be unsubcribe

Message structure

Byte Position Type Field
1-2 int8 Exchange code
2-6 int32 Instrument Token
6-10 int32 Last Traded Price
10-14 int32 Last Traded Time (Unix Time)
14-18 int32 Last Traded Quantity
18-22 int32 Trade Volume
22-26 int32 Best Bid Price
26-30 int32 Best Bid Quantity
30-34 int32 Best Ask Price
34-38 int32 Best Ask Quantity
38-46 int64 Total Buy Quantity
46-54 int64 Total Sell Quantity
54-58 int32 Average Trade Price
58-62 int32 Exchange Timestamp (Unix Time)
62-66 int32 Open Price
66-70 int32 High Price
70-74 int32 Low Price
74-78 int32 Close Price
78-82 int32 Yearly High Price
82-86 int32 Yearly Low Price

Compact Marketdata

You can subscribe to compact marketdata for multiple instruments at the same time.

Example Subscription

{"a": "subscribe", "v": [[1, 22], [1, 1330]], "m": "compact_marketdata"}

For unsubscription, a needs to be unsubcribe

Message structure

Byte Position Type Field
1-2 int8 Exchange
2-6 int32 Instrument token
6-10 int32 Ltp
10-14 int32 Change
14-18 int32 Exchange Timestamp
18-22 int32 Volume

Snapquote

You can subscribe to snapquote for multiple instruments at the same time.

Example Subscription

{"a": "subscribe", "v": [[1, 22], [1, 1330]], "m": "snapquote"}

For unsubscription, a needs to be unsubcribe

Message structure

Byte Position Type Field
1-2 int8 Exchange code
2-6 int32 Instrument Token
6-26 Byte array of int32 of length 5 Top 5 Buyers
26-46 Byte array of int32 of length 5 Top 5 bid prices
46-66 Byte array of int32 of length 5 Top 5 Bid Quantities
66-86 Byte array of int32 of length 5 Top 5 Sellers
86-106 Byte array of int32 of length 5 Top 5 Ask prices
106-126 Byte array of int32 of length 5 Top 5 Ask Quantities
126-130 int32 Exchange Timestamp(Unix Time)

Full Snapquote

You can subscribe to full snapquote for multiple instruments at the same time.

Example Subscription

{"a": "subscribe", "v": [[1, 22], [1, 1330]], "m": "full_snapquote"}

For unsubscription, a needs to be unsubcribe

Message structure

Byte Position Type Field
1-2 int8 Exchange code
2-6 int32 Instrument Token
6-26 Byte array of int32 of length 5 Top 5 Buyers
26-46 Byte array of int32 of length 5 Top 5 bid prices
46-66 Byte array of int32 of length 5 Top 5 Bid Quantities
66-86 Byte array of int32 of length 5 Top 5 Sellers
86-106 Byte array of int32 of length 5 Top 5 Ask prices
106-126 Byte array of int32 of length 5 Top 5 Ask Quantities
126-130 int32 Average Trade Price
130-134 int32 Open
134-138 int32 High
138-142 int32 Low
142-146 int32 Close
146-154 int64 Total Buy Quantity
154-162 int64 Total Sell Quantity
162-166 int32 Volume

Market Status

You can subscribe to market status for multiple exchanges at the same time.

Example Subscription

{"a": "subscribe", "v": [1,2,3,4,6], "m": "market_status"}

For unsubscription, a needs to be unsubcribe

Message Structure

Byte Position Type Field
1-2 int8 Exchange code
2-4 int16 Length of market type
4-(4 + length of market type) string Market Type
(4 + length of market type) - (6 + length of market type) int16 Length of Status
(6 + length of market type) - (6 + length of market type + length of status) string Status
(6 + length of market type + length of status) - (10 + length of market type + length of status) int32 Exchange Timestamp

Exchange Message

You can subscribe to exchange messages for multiple exchanges at the same time.

Example Subscription

{"a": "subscribe", "v": [1,2,3,4,6], "m": "exchange_messages"}

For unsubscription, a needs to be unsubcribe

Message Structure

Byte Position Type Field
1-2 int8 Exchange code
2-4 int16 Length of message
4-(4 + length of message) string Message
(4 + length of message) - (8 + length of message) int32 Exchange Timestamp

DPR

You are already subscribed to DPR updates when you subscribe to marketdata or compact market data.

Message structure

Byte Position Type Field
1-2 int8 Exchange code
2-6 int32 Instrument Token
6-10 int32 Exchange Timestamp
10-14 int32 High Price
14-18 int32 Low Price

Open Interest

You are already subscribed to Open interest updates when you subscribe to marketdata or compact market data.

Message structure

Byte Position Type Field
1-2 int8 Exchange code
2-6 int32 Instrument token
6-10 int32 Current Open Interest
10-14 int32 Intital Open Interest
14-18 int32 Exchange Timestamp

Appendix

Exchanges

Product Types

Order Sides

Order Types

Errors

The Kittn API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a kitten with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The kitten requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many kittens! 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.

ANT JS DEMO

Third Party Buy/Sell order Buttons Example

Place buy order ACC-EQ (NSE, CNC, LIMIT, PRICE = 2, QTY = 1)

Basket order

Powered by

Alice Blue