This document describes version 4 of the websocket API. Any earlier version is unsupported and may be withdrawn at any time.

Base URL

wss://www.cfbenchmarks.com/ws/v4

Authorization

This API requires users to specify an API key. This key can be obtained by contacting CF Benchmarks for a license.

If connecting using Javascript, assuming the key username is 'abc' and the key password is '123', you would connect by specifying the protocol as the array ['cfb', 'abc, '123].

Some language APIs require the key to be specified in the websocket request header. In this case you would provide the username and key in the request header with a header field of the form Authorization: Basic <credentials> where credentials is the Base64 encoding of username and key joined by a single colon ':'.

Commands
Subscribe
Field Type Description Expected value
type string Command subscribe
id string Stream ID One of the stream IDs above
stream string Stream type One of: [value]

Example:

{ "type": "subscribe", "id": "BRTI", "stream": "value" }

Response:
No direct response if successful. The most recent value will be sent, and subsequent values until the unsubscribe command is sent.

Errors are described below.

Unsubscribe
Field Type Description Expected value
type string Command unsubscribe
id string Stream ID One of the stream IDs above
stream string Stream type One of: [value]

Example:

{ "type": "unsubscribe", "id": "BRTI", "stream": "value" }

Response:
No direct response if successful. Messages for the subscription will cease.

Errors are described below.

Messages
Value
Field Type Description Expected value
type string Message type value
id string Stream ID One of the stream IDs above
value number Stream value
time integer Calculation time of value in milliseconds since Unix epoch

Example:

{ "type": "value", "id": "BRTI", "value": "8835.56", "time": 1579264280000 }
Command Errors

Any command that results in an error returns the command with a success flag and a reason for the error.

Field Type Description Expected value
type string Command unsubscribe
id string Stream ID One of the stream IDs above
stream string Stream type One of: [value]
success boolean Was the command successful
reason string Reason for the error

Example:

{ "type": "foo", "id": "BRTI", "stream": "value", "success": false, "reason": "Unrecognised command" }