Message flows

Authentication

The authentication message flow is initiated by the gateway.

The gateway will send a greeting message followed by a challenge request.

The client must then issue an authentication request, which the gateway will respond to with an authentication response

For the purpose of this example, assume the API key is db-89s9vCvwDDKPdQJ5Pb30Fyj9mNUM6.

When connecting to the gateway, the gateway will send two messages:

lsg_version=0.2.0\n

cram=j5pwMHz6vwXruJM4cOwQrQeQE0bImIzT\n

To generate the response, the client first concatenates the cram value and their API key in the format $cram|$key.

In this example, this would be j5pwMHz6vwXruJM4cOwQrQeQE0bImIzT|db-89s9vCvwDDKPdQJ5Pb30Fyj9mNUM6.

The concatenated string is then hashed with SHA-256. In this example, it produces 6d3c875bb9f8cf503c3ed83ee5f476a3ad53f0c67706c51cf42d2db5ad8ff5a9.

This result is then concatenated with the last five bytes of the API key (also referred to as the bucket_id) in the format $auth-$bucket_id.

With this, the authentication response string is generated as 6d3c875bb9f8cf503c3ed83ee5f476a3ad53f0c67706c51cf42d2db5ad8ff5a9-mNUM6.

The client then sends the authentication message containing this string to the gateway:

auth=6d3c875bb9f8cf503c3ed83ee5f476a3ad53f0c67706c51cf42d2db5ad8ff5a9-mNUM6|dataset=GLBX.MDP3|encoding=dbn|ts_out=0\n

If the key is valid, the gateway will reply with a successful response: success=1|session_id=135567\n

Subscription

After authenticating, the client can subscribe to live data.

To subscribe, the client must send a subscription request to the gateway.

Subscriptions from multiple symbols and schemas can be made in the same session. Different datasets require separate connections.

The same symbol can have separate subscriptions in different schemas.

A subscription will not take effect until the session is started.

To remove symbols from a subscription, the client can send an unsubscribe request.

If one or more symbols in a subscription fail to resolve, the gateway will send an ErrorMsg record with code=SymbolResolutionFailed for each unresolved symbol. The session is not terminated, and any successfully resolved symbols in the same subscription will continue to stream normally.

For other subscription failures (such as code=InvalidSubscription or code=InternalError), the gateway will send an ErrorMsg record and terminate the session.

To subscribe to trades for all E-mini S&P Mini 500 Futures on CME, the client would send:

schema=trades|stype_in=parent|symbols=ES.FUT\n

Intraday historical subscription

After authenticating, the client can subscribe to intraday historical data.

The subscription mechanism is similar to live data: the client must send a subscription request to the gateway, containing the start parameter which can be formatted as nanoseconds since the UNIX epoch or as a datetime string of one of the formats listed in Dates and times.

When handling an intraday historical subscription, the gateway will send all messages beginning from the specified timestamp and, after catching up in time, will continue sending live data as it arrives.

This makes intraday historical subscriptions the ideal way to deal with application restarts on the client side.

Our gateways keep data from up to the last 24 hours to serve via the intraday historical API. Requests for data over 24 hours old will be rejected.

To subscribe to trades for all E-mini S&P 500 Futures on CME starting from 2023-04-05 00:00:00 UTC, the client would send:

schema=trades|stype_in=parent|symbols=ES.FUT|start=1680652800000000000\n

or

schema=trades|stype_in=parent|symbols=ES.FUT|start=2023-04-05T00:00:00\n

Starting the session

Once the gateway receives the session start message, it will start streaming data messages to the client and will continue until the connection is terminated.

Once the session has started, it's still possible to send new subscriptions to the gateway, as long as they do not contain the start field, and to unsubscribe from symbols.

Info

A session cannot be started more than once.

After authenticating, to subscribe to trades for all E-mini S&P 500 Futures on CME starting from 2023-04-05 00:00:00 UTC, the client would send:

schema=trades|stype_in=parent|symbols=ES.FUT|start=1680652800000000000\n

Then, when ready to receive data, the client would send:

start_session=1\n

After this, the gateway will begin streaming data records to the client.

Unsubscribing

To remove symbols from the session's subscriptions, the client sends an unsubscribe request to the gateway.

An unsubscribe request applies to a single schema. It doesn't need to match an earlier subscription: any subset of the subscribed symbols can be removed, and symbols=ALL_SYMBOLS removes every symbol for the schema. Unsubscribe requests can be sent before or after the session is started.

The gateway acknowledges each unsubscribe request with a system message with code=UNSUBSCRIBE_ACK. If the request is sent before the session is started, the acknowledgement is sent after the session starts, following the DBN metadata.

Symbols that aren't subscribed, or that are only subscribed through a parent symbol, are left in place and reported in an ErrorMsg. These errors don't end the session.

After subscribing to trades for the E-mini S&P 500 and E-mini Nasdaq-100 December 2026 futures and starting the session:

schema=trades|stype_in=raw_symbol|symbols=ESZ6,NQZ6\n

start_session=1\n

to stop receiving trades for NQZ6, the client would send:

unsubscribe|schema=trades|stype_in=raw_symbol|symbols=NQZ6\n

The gateway will acknowledge the request with an UNSUBSCRIBE_ACK system message and continue streaming trades for ESZ6.