Files

2.9 KiB

Market Prices

Rate limits

  • 2400 requests/min or 40 requests/sec per IP address. (weight = 1) or length of product_ids for multi-product markets query.

{% hint style="info" %} See more details in API Rate limits {% endhint %}

Single Product

Request

{% tabs %} {% tab title="Websocket" %} Connect

WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]

Message

{
  "type": "market_price",
  "product_id": 1
}

{% endtab %}

{% tab title="REST (GET)" %} GET [GATEWAY_REST_ENDPOINT]/query?type=market_price&product_id={product_id} {% endtab %}

{% tab title="REST (POST)" %} POST [GATEWAY_REST_ENDPOINT]/query

Body

{
  "type": "market_price",
  "product_id": 1
}

{% endtab %} {% endtabs %}

Request Parameters

ParameterTypeRequiredDescription
product_idnumberYesId of spot / perp product for which to retrieve market price data.

Response

{
  "status": "success",
  "data": {
    "product_id": 1,
    "bid_x18": "24224000000000000000000",
    "ask_x18": "24243000000000000000000"
  },
  "request_type": "query_market_price",
}

{% hint style="info" %} Note: that price is represented using fixed point, so it is 1e18 times greater than the decimal price. {% endhint %}

Multiple Products

Request

{% tabs %} {% tab title="Websocket" %} Connect

WEBSOCKET [CORE_WEBSOCKET_ENDPOINT]

Message

{
  "type": "market_prices",
  "product_ids": [1, 2]
}

{% endtab %}

{% tab title="REST" %} POST /query

Body

{
  "type": "market_prices",
  "product_ids": [1, 2]
}

{% endtab %} {% endtabs %}

Request Parameters

ParameterTypeRequiredDescription
product_idsnumber[]YesList of spot / perp products for which to retrieve market price data.

Response

{
  "status": "success",
  "data": {
    "market_prices": [
      {
        "product_id": 1,
        "bid_x18": "31315000000000000000000",
        "ask_x18": "31326000000000000000000"
      },
      {
        "product_id": 2,
        "bid_x18": "31291000000000000000000",
        "ask_x18": "31301000000000000000000"
      },
    ]
  },
  "request_type": "query_market_prices"
}