Developers

Order book levels

Get one instrument's order book, up to 10 price levels a side.

On this page

URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.

Do not use this to poll for data -- a websocket subscription is much more performant, and useful.

SDKclient.orderbook_levels(...)
HTTPPOST https://market-data.testnet.grvt.io/full/v1/book, or /lite/v1/book for lite names (the SDKs' default)
WebSocketmethod v1/book on wss://market-data.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthNone (public)
RetriesRead: the SDKs retry retryable errors (rules)
Contract idorderbook.orderbook_levels (RPCOrderbookLevelsV1)

Request

Body type ApiOrderbookLevelsRequest. Fields the server fills are left out.

  • instrumentlite name istring (instrument name)required#
    The instrument name, e.g. BTC_USDT_Perp (perpetual), BTC_USDT_SFP (stable funding perp) or BTC_USDT_SpotSwap (spot swap).
  • depthlite name dinteger (uint32)required#
    Depth of the order book to be retrieved (10, 50, 100, 500)

Response

Body type ApiOrderbookLevelsResponse (the same object is the JSON-RPC result over WebSocket).

resultlite name robject OrderbookLevelsrequired#
The orderbook levels objects matching the request asset
  • event_timelite name etstring (int64 unix ns)required#
    Time at which the event was emitted in unix nanoseconds
  • instrumentlite name istring (instrument name)required#
    The instrument name, e.g. BTC_USDT_Perp (perpetual), BTC_USDT_SFP (stable funding perp) or BTC_USDT_SpotSwap (spot swap).
  • bidslite name barray<OrderbookLevel>required#
    The list of best bids up till query depth
    3 fields of OrderbookLevel
    • pricelite name pstringrequired#
      The price of the level. Decimal string, e.g. "65000.5"; up to 9 decimals.
    • sizelite name sstringrequired#
      The number of assets offered. Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
    • num_orderslite name nointeger (uint32)required#
      The number of open orders at this level
  • askslite name aarray<OrderbookLevel>required#
    The list of best asks up till query depth Fields: same as result.bids[] above.

Errors

Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):

3000InvalidInstrument400
Instrument is invalid
3031InvalidDepth400
Depth is invalid
7725SfpEndpointNotSupported403
This endpoint is not supported for stable funding.
Plus 4 errors any call can return
1002InternalServer500
Internal Server Error
1003InvalidRequest400
Request could not be processed due to malformed syntax
1004NotFound404
Data Not Found
1006RateLimit429retryable
You have surpassed the allocated rate limit for your tier

Example

Example code
from grvt import Grvt

with Grvt(env="testnet") as client:
    resp = client.orderbook_levels(
        instrument="BTC_USDT_Perp",
        depth=50,
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments):

With full field names:

curl -sS "https://market-data.testnet.grvt.io/full/v1/book" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "instrument": "BTC_USDT_Perp",
  "depth": 50
}
EOF

With lite field names:

curl -sS "https://market-data.testnet.grvt.io/lite/v1/book" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "i": "BTC_USDT_Perp",
  "d": 50
}
EOF
Run on testnet
esc

↑ ↓ move↵ open⇧↵ open .mdTry an error code like 2002

Keyboard shortcuts

⌘ K
Search the docs
/
Search
l
Next code language (Python → TypeScript → Go → Rust → curl → WebSocket)
j / k
Next / previous page
t
Light / dark theme
?
This help
Esc
Close dialogs and drawers