Security order book
The request cannot be executed anonymously. The required token
parameter must contain an up-to-date Access Token.
This operation can be performed with request to HTTP API.
The request creates a subscription to receive information about the current number of lots and their price in bids and asks of the specified financial asset.
Request
To create a subscription to a data channel, send a message to the established WebSocket connection with a request body containing the details of the subscription to be created.
- Request body
- Schema
{
"opcode": "OrderBookGetAndSubscribe",
"code": "SBER",
"depth": 10,
"exchange": "MOEX",
"instrumentGroup": "TQBR",
"format": "Simple",
"frequency": 100,
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"token": "eyJhbGciOiJ..."
}
Request body parameters
OrderBookGetAndSubscribe
— Subscription to order bookBarsGetAndSubscribe
— Subscription to price history (candlesticks)QuotesSubscribe
— Subscription to quotesInstrumentsGetAndSubscribeV2
— Subscription to security information updates on the selected exchangeAllTradesGetAndSubscribe
— Subscribe to all tradesPositionsGetAndSubscribeV2
— Subscription to information about current positions on securities and moneySummariesGetAndSubscribeV2
— Subscription to portfolio summary informationRisksGetAndSubscribe
— Subscription to consolidated information on portfolio risksSpectraRisksGetAndSubscribe
— Subscription to information on derivatives market risks (FORTS)TradesGetAndSubscribeV2
— Subscription for information on tradesOrdersGetAndSubscribeV2
— Subscription to information about current orders on the market for the selected exchange and securityStopOrdersGetAndSubscribeV2
— Subscription to information about current conditional orders in the market for the selected exchange and securityunsubscribe
— Cancelation of previously created subscriptionMOEX
— Moscow ExchangeSPBX
— SPB Exchange- List of Moscow Exchange codes is available in table
- SPB Exchange securities always have
SPBX
code Simple
is the original data format. Supports legacy (deprecated) parameters to ensure backward compatibilitySlim
is the lightweight data format for fast messaging. Does not support legacy (deprecated) parametersHeavy
is the complete data format, evolving and augmented with new fields. Does not support legacy (deprecated) parametersSimple
— 25 millisecondsSlim
— 10 millisecondsHeavy
— 500 milliseconds.
Operation code:
Security code (ticker)
Example: SBER
Order book depth. Default value - 20 (20x20), maximum - 50 (50x50)
Example: 20
Exchange code:
Example: MOEX
Trading mode code (Board):
Example: TQBR
The format of the JSON object returned by the server:
Example: Simple
Frequency (interval) of data transmission by the server. The server will return the latest data on request for the time interval specified as the parameter value. Example: the exchange transmits data every 2 ms, but if the parameter value is 10 ms, the server will return only the last value, discarding the previous ones.
Minimum value of the parameter depends on the selected format of the JSON object to be returned:
Example: 100
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Access Token
Example: eyJhbGciOiJ...
Responses
The content of the response returned to the WebSocket connection depends on the results of processing the request:
- If the request is processed successfully, the server will send one
200
code message in response, confirming that the subscription has been created, after which it will begin transmitting100
code messages containing the information requested as part of the subscription. - If the request processing failed, the server will send back one message with an error code corresponding to the reason for the failure, after which it will close the WebSocket connection.
- 100
- 200
- 401
Messages from the channel containing the requested information
- Simple
- Slim (Common)
- Slim (Bonds)
- Heavy
- Response body
- Schema
{
"data": {
"snapshot": true,
"bids": [
{
"price": 257.70,
"volume": 157
}
],
"asks": [
{
"price": 257.71,
"volume": 288
}
],
"timestamp": 1702631123,
"ms_timestamp": 1702631123780,
"depth": 20,
"existing": true
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
Deprecated field, will be removed in future updates. Use existing
field instead
Example: true
bids
object
Bid data
Price
Example: 115820
Volume
Example: 23
asks
object
Ask data
Price
Example: 116030
Volume
Example: 31
Deprecated field, will be removed in future updates. Use ms_timestamp
field instead
Example: 1610982677
Time (UTC) in Unix Time Milliseconds format
Example: 1610982677578
True
will return the response including data from snapshot, i.e. from history. False
will return only new events
Example: false
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
- Response body
- Schema
{
"data": {
"b": [
{
"p": 257.70,
"v": 157
}
],
"a": [
{
"p": 257.71,
"v": 288
}
],
"t": 1702631123780,
"h": false
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
b
object
Bid data
Price
Example: 115820
Volume
Example: 23
a
object
Ask data
Price
Example: 116030
Volume
Example: 31
Time (UTC) in Unix Time Milliseconds format
Example: 1610982677578
True
will return the response including data from snapshot, i.e. from history. False
will return only new events
Example: false
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
- Response body
- Schema
{
"data": {
"b": [
{
"p": 70.589,
"v": 146,
"y": 16.21
}
],
"a": [
{
"p": 70.772,
"v": 10,
"y": 16.14
}
],
"t": 1702631123780,
"h": false
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
b
object
Bid data
Price
Example: 70.589
Volume
Example: 146
Bond yield
Example: 16.14
a
object
Ask data
Price
Example: 70.772
Volume
Example: 10
Bond yield
Example: 16.21
Time (UTC) in Unix Time Milliseconds format
Example: 1610982677578
True
will return the response including data from snapshot, i.e. from history. False
will return only new events
Example: false
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
- Response body
- Schema
{
"data": {
"bids": [
{
"price": 257.70,
"volume": 157
}
],
"asks": [
{
"price": 257.71,
"volume": 288
}
],
"msTimestamp": 1702631123780,
"depth": 20,
"existing": false
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
bids
object
Bid data
Price
Example: 115820
Volume
Example: 23
asks
object
Ask data
Price
Example: 116030
Volume
Example: 31
Time (UTC) in Unix Time Milliseconds format
Example: 1610982677578
True
will return the response including data from snapshot, i.e. from history. False
will return only new events
Example: false
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Successful request processing report
- Body
- Schema
{
"message": "Handled successfully",
"httpCode": 200,
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
Text description of the returned HTTP code
Example: Handled successfully
HTTP message code
Example: 200
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Failed to process request. Access token is invalid, not specified in the message or belongs to other system environment
- Body
- Schema
{
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"httpCode": 401,
"message": "Invalid JWT token!"
}
Response body parameters
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
HTTP message code
Example: 401
Text description of the returned HTTP code
Example: Invalid JWT token!