Skip to content

Market Depth

POST /marketDepth

The Market Depth API provides real-time data on the market depth for a given trading symbol on a specific exchange. This includes details about the current bid and ask prices, their quantities, and other relevant market data. It is useful for traders and investors to understand the supply and demand dynamics of a stock and make informed trading decisions.

Parameter

NameTypeRequiredDescription
exchangestringfalseName of the exchange. Valid values: BSE, NSE, NFO, BFO, MCX, CDS, MFO. Default is NSE if not provided. For BSE, NFO, CDS, and MCX, the exchange is mandatory.
symbolNamestringtrueSymbol name of the scrip. For Equity, enter the SymbolName of the scrip. For Derivatives, enter the TradingSymbol of the scrip.

Sample Request Body

json

requestBody={ 
  "exchange" : "BFO",
  "symbolName" : "BANKEX2450656000CE"
}

Sample Code

bash
curl -X POST 'https://tradeapi.samco.in/marketDepth' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"exchange":"BFO","symbolName":"BANKEX2450656000CE"}'
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Sample {
  public static void main(String[] args) throws Exception {
    String requestBody = """
        {
          "exchange": "BFO",
          "symbolName": "BANKEX2450656000CE"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/marketDepth"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
js
(async () => {
  const headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'x-session-token': '<SESSION_TOKEN>',
  };

  const requestBody = {
    exchange: "BFO",
    symbolName: "BANKEX2450656000CE"
  };

  const response = await fetch('https://tradeapi.samco.in/marketDepth', {
    method: 'POST',
    headers,
    body: JSON.stringify(requestBody),
  });

  const data = await response.json();
  console.log(data);
})();
py
import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': '<SESSION_TOKEN>',
}

requestBody = {
  "exchange": "BFO",
  "symbolName": "BANKEX2450656000CE"
}

r = requests.post('https://tradeapi.samco.in/marketDepth',
  data=json.dumps(requestBody),
  headers=headers)

print(r.json())

Sample Response

json
{
    "serverTime": "20/08/24 13:41:54",
    "msgId": "f494c1cb-ba67-4591-b29e-9a27f92e5204",
    "status": "Success",
    "statusMessage": "Market depth data retrieved successfully",
    "MarketDepthDetails": {
        "marketDepth": {
            "tradingSymbol": "NIFTY2482224500PE",
            "vega": "5.05",
            "theta": "-15.53",
            "gamma": "0.0010",
            "symbol": "36759_NFO",
            "tBuyQty": "774925",
            "iv": "13.80",
            "tSellQty": "985500",
            "bestFiveAsk": [
                {
                    "askNumber": "8",
                    "askSize": "1775",
                    "askPrice": "27.05"
                },
                {
                    "askNumber": "19",
                    "askSize": "4350",
                    "askPrice": "27.10"
                },
                {
                    "askNumber": "19",
                    "askSize": "3650",
                    "askPrice": "27.15"
                },
                {
                    "askNumber": "20",
                    "askSize": "5025",
                    "askPrice": "27.20"
                },
                {
                    "askNumber": "11",
                    "askSize": "1950",
                    "askPrice": "27.25"
                }
            ],
            "bestFiveBid": [
                {
                    "bidSize": "1400",
                    "bidNumber": "4",
                    "bidPrice": "27.00"
                },
                {
                    "bidSize": "3850",
                    "bidNumber": "13",
                    "bidPrice": "26.95"
                },
                {
                    "bidSize": "8975",
                    "bidNumber": "22",
                    "bidPrice": "26.90"
                },
                {
                    "bidSize": "5450",
                    "bidNumber": "18",
                    "bidPrice": "26.85"
                },
                {
                    "bidSize": "2800",
                    "bidNumber": "9",
                    "bidPrice": "26.80"
                }
            ],
            "atmIV": "11.70",
            "delta": "-0.19",
            "exc": "NFO"
        }
    }
}
json
{
  "serverTime": "14/05/24 13:49:07",
  "status": "Failure",
  "statusMessage": "No Symbol found for the provided symbol name and exchange."
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringThe timestamp of when the response was generated, indicating the server's current time.
msgIdstringA unique identifier for the request, useful for tracking and debugging.
statusstringThe status of the API response. Possible values: 'Success', 'Error', or 'Failure'.
statusMessagestringA message providing additional details about the status of the request.
MarketDepthDetailsObjectContains the market depth information.
tradingSymbolstringThe identifier for the financial instrument or contract.
vegastringMeasures the sensitivity of the F&O’s price to changes in the volatility of the underlying asset.
thetastringMeasures the rate at which the F&O’s price decreases as it approaches expiration.
gammastringMeasures the rate of change of delta with respect to changes in the underlying asset's price.
symbolstringA unique code for the instrument on the exchange.
tBuyQtystringThe total quantity available for buying.
ivstringImplied volatility of the F&O.
tSellQtystringThe total quantity available for selling.
bestFiveAskObjectAn array listing the top five ask prices (prices at which sellers are willing to sell).
askNumberstringThe order number for the ask price.
askSizestringThe quantity available at the ask price.
askPricestringThe price at which sellers are willing to sell.
bestFiveBidObjectAn array listing the top five bid prices (prices at which buyers are willing to buy).
bidSizestringThe quantity available at the bid price.
bidNumberstringThe order number for the bid price.
bidPricestringThe price at which buyers are willing to buy.
atmIVObjectThe implied volatility of the at-the-money F&O.
deltastringMeasures the sensitivity of the F&O’s price to changes in the price of the underlying asset.
excstringThe exchange code where the instrument is traded.