Skip to main content

WEBSOCKET API Market Data - Get order book

WEBSOCKET API Market Data - Get order book

Written by Albert
Updated over a week ago

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 the marketId as a string.

invocationId string

The invocation identifier.

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

target string

The stream name.

Specify "Book".

type int

The operation type.

Set to 4 to indicate a subscription to the stream.

Example:

{
"arguments": [
"67d0456f8c7b1108e4cf5d46",
"cfd.eur_chf"
],
"invocationId": "0",
"target": "Book",
"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.instrument string

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

item.askTotalAmount string

The total ask amount.

item.bidTotalAmount string

The total bid amount.

item.asks array of objects

The array of ask price objects.

item.asks.price string

The price, in the quote asset.

item.asks.amount string

The total amount of the base asset available at a corresponding price level.

item.asks.total string

The total amount, in the quote asset, required to fully execute the orders at a corresponding price level.

item.bids array of objects

The array of bid price objects.

item.bids.price string

The price, in the quote asset.

item.bids.amount string

The total amount of the base asset available at a corresponding price level.

item.bids.total string

The total amount, in the quote asset, required to fully execute the orders at a corresponding price level.

item.version string

The order book version.

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": {
"instrument": "cfd.eur_chf",
"askTotalAmount": "18700000",
"bidTotalAmount": "19100000",
"asks": [
{
"price": "0.93677",
"amount": "5000000",
"total": "4683850"
},
{
"price": "0.93676",
"amount": "0",
"total": "0"
},
{
"price": "0.93676",
"amount": "0",
"total": "0"
}
],
"bids": [
{
"price": "0.93654",
"amount": "0",
"total": "0"
},
{
"price": "0.93654",
"amount": "0",
"total": "0"
},
{
"price": "0.93655",
"amount": "5000000",
"total": "4682750"
}
],
"version": "12498",
"snapshot": false
}
}

Did this answer your question?