Protocol
The Raw API protocol is divided into two main parts: control messages and data records.
All messages sent by the client to the gateway are control messages.
Control messages
Control messages are used for authentication and subscribing to the gateway, and are encoded
as ASCII text. A single control message is composed by a series of key=value
pairs (called fields from now) separated by the | character.
Every control message terminates with a newline character (\n).
A control message can have optional and required fields. A control message which contains an unknown field or does not contain a required field will be considered invalid by the gateway. Control messages are limited to 64KiB; messages exceeding this length are invalid. After an invalid control message, the gateway will terminate the session with an error message.
An example of a correctly-formatted subscription request control message is schema=trades|stype_in=raw_symbol|symbols=SPY\n.
Data records
Once authenticated with the gateway, the gateway will not send any new control messages; subsequent messages will always be data records.
If compression is enabled, the data record stream will need to be decompressed with the compression algorithm of choice before decoding.
Data records are sent in the encoding specified during authentication. Unlike in the historical API, the CSV encoding is not supported.
In the DBN encoding, the records will be sequentially streamed.
In the JSON encoding, the records will follow the JSON lines specification,
where each line of the file is a JSON object. Lines use UNIX-style \n separators.
The ts_out parameter
If the client chose to set the ts_out parameter during the authentication, the gateway will send its send
timestamp with every data record. The format will vary per encoding.
In the dbn encoding, the ts_out is a 64-bit unsigned integer appended to every data record.
In the json encoding, the ts_out is added as an additional field within each JSON object.
Some records may share a ts_out value captured before those records are encoded.