Skip to main content

WEBSOCKET API Market Data - Get top of the book

WEBSOCKET API Market Data - Get top of the book

Written by Albert
Updated over a week ago

Get top of the book

Connection

URL:

/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}

arguments array

The connection parameters.

In the first element, provide the accountId as a string.

In the second element, provide a list of marketIds as an array of strings.

invocationId string

The invocation identifier.

Must be unique and increase by 1 for each sent message.

target string

The stream name.

Specify "Tob".

type int

The operation type.

Set to 4 to indicate a subscription to the stream.

Example:

{
"arguments": [
"67d0456f8c7b1108e4cf5d46",
[
"spot.eth_usdt"
]
],
"invocationId": "0",
"target": "Tob",
"type": 4
}

Message

type string

The operation type.

2 indicates the streaming is in progress.

invocationId string

The invocation identifier. Same as in the request.

item object

The dataset object.

item.markets array of objects

The array of market objects.

item.markets.marketId string

The market identifier, in the following format: {marketType}.{baseAssetId}_{quoteAssetId}, for example: cfd.eth_eur.

item.markets.ask decimal string

The top-of-the-book ask price.

item.markets.bid decimal string

The top-of-the-book bid price.

item.snapshot boolean

The data snapshot.

If snapshot: true, it indicates the message contains the full dataset. Subsequent messages with snapshot: false only include updates or changes since the initial snapshot.

Example:

{
"type": 2,
"invocationId": "0",
"item": {
"markets": [
{
"marketId": "spot.eth_usdt",
"ask": "2483.82",
"bid": "2483.81"
}
],
"snapshot": false
}
}

Did this answer your question?