Client control messages

Authentication request

Authenticates the session against the gateway and sets the dataset for the session.

Fields

Field
Required
Type
Description
auth
required
string
The authentication response. Generated based on the client API key and the cram challenge sent by the gateway. See authentication for a detailed walkthrough of the process.
dataset
required
string
The dataset code (string identifier). Must be one of the values from metadata.list_datasets.
encoding
optional
string
The encoding to be used for the data sent by the gateway. Defaults to dbn.
compression
optional
string
The compression to be used for the data sent by the gateway. Defaults to none.
ts_out
optional
int8_t
If set to 1, the gateway will prepend the timestamp at which the message was processed to every data record. Defaults to 0.
pretty_px
optional
int8_t
If set to 1, the gateway will format fixed-precision fields as a decimal string. Only applicable for JSON encoding. Defaults to 0.
pretty_ts
optional
int8_t
If set to 1, the gateway will format timestamp fields as ISO 8601 strings. Only applicable for JSON encoding. Defaults to 0.
heartbeat_interval_s
optional
uint32_t
Overrides the interval in seconds at which the gateway will send heartbeat records. Defaults to the gateway's default interval. Must be between 5 and 1800 seconds.
slow_reader_behavior
optional
string
The slow reader behavior to be used for the session. Defaults to skip.
Example message
1
auth=6c476f2214fa0509607a968b7d62e3a3b605ee740f9c6d70f1bd3a34a9213f61-mNUM6|dataset=GLBX.MDP3|encoding=dbn|ts_out=0\n
Example response
1
success=1|session_id=135567\n

Subscription request

Add a new subscription to the session.

Supports multiple subscriptions for different schemas, which enables rich data streams containing mixed record types.

Specify an optional start time for intraday replay with subscriptions made before starting the session.

Subscriptions end when the TCP connection closes or when their symbols are removed with an unsubscribe request.

When subscribing to many symbols, a subscription can be split across multiple control messages so as to avoid exceeding the maximum length. It's recommended to chunk the symbols in groups of 500. All but the last message should include is_last=0 to indicate to the gateway that another part of the subscription remains.

Fields

Field
Required
Type
Description
schema
required
string
The data record schema code (string identifier). Must be one of the values from metadata.list_schemas.
stype_in
required
string
The symbology type of input symbols.
symbols
required
string
A comma-separated list of symbols to filter for. Setting this value to ALL_SYMBOLS will subscribe to all the symbols in the dataset.
start
optional
string or uint64_t
The inclusive start of subscription replay. Filters on ts_event except for CBBO and BBO schemas, which filter on ts_recv. Takes an ISO 8601 string or a UNIX timestamp in nanoseconds. Must be within the last 24 hours. Pass 0 to request all available data. Cannot be specified after the session is started.
snapshot
optional
int8_t
Request subscription with snapshot. When snapshot=1, start must be absent.
id
optional
uint32_t
A numerical identifier for the subscription.
is_last
optional
int8_t
0 indicates more requests will be sent with the same parameters other than symbols and the gateway should wait to process the request. is_last=1 is the default and instructs the gateway to process the request immediately.
Example message
1
schema=trades|start=1671717080706865759|stype_in=raw_symbol|symbols=SPY,QQQ\n

Unsubscribe request

Remove the specified symbols from the session's subscriptions for a schema.

The symbols don't need to match an earlier subscription request: any subset of the subscribed symbols can be removed, and ALL_SYMBOLS removes every symbol for the schema. An unsubscribe request can be sent before or after the session is started.

The gateway acknowledges the request with a system message with code=UNSUBSCRIBE_ACK. Symbols that aren't subscribed, or that can't be removed with the given stype_in, are left in place and reported in an ErrorMsg. If there's no subscription for the schema or stype_in isn't supported, the gateway sends an ErrorMsg with code=InvalidSubscription. None of these errors end the session.

The unsubscribe's stype_in must be compatible with the subscription's stype_in.

Subscribed with
Can unsubscribe with
raw_symbol, instrument_id, or continuous
raw_symbol or instrument_id
parent
parent

To remove a continuous symbol, unsubscribe the raw symbol or instrument ID that it resolved to at subscription time.

As with subscription requests, the symbols can be split across multiple control messages. All but the last message should include is_last=0.

Fields

Field
Required
Type
Description
unsubscribe
required
Identifies the message as an unsubscribe request. Must be the first field. A value can be given, such as unsubscribe=0, but it's ignored.
schema
required
string
The data record schema to unsubscribe from.
stype_in
required
string
The symbology type of input symbols. Must be one of raw_symbol, parent, or instrument_id.
symbols
required
string
A comma-separated list of symbols to unsubscribe from. Setting this value to ALL_SYMBOLS will remove every symbol for the schema.
is_last
optional
int8_t
0 indicates more requests will be sent with the same parameters other than symbols and the gateway should wait to process the request. is_last=1 is the default and instructs the gateway to process the request immediately.
Example message
1
unsubscribe|schema=trades|stype_in=raw_symbol|symbols=SPY,QQQ\n

Session start

After receiving this message, the gateway will start streaming data records to the client.

Info

This message should only be sent once per session.

Fields

Field
Required
Type
Description
start_session
required
ignored
The value sent here is irrelevant.
Example message
1
start_session=0\n