Develop

Track signals


WS /channels/connect

WebSockets are used for sending signals from the tracks during races. These are for time critical data that need to be sent with low latency, and does not need to be persisted. Only the transient channels listed on the channels list are sent over WebSockets. These channels include countdown timers, lap times and disqualifications.

STOMP (Simpe Text Oriented Message Protocol) is used as the communications protocol over the WebSockets. You can find STOMP complient client libraries for many popular languages here.

You will need to pass a valid authentication token when connecting to the endpoint. Data will only be delivered while races are ongoing. It’s recommended that you will create a new connection with a fresh authentication token every day. After 22:00 every night, no more data will be transferred until next day when the first races start.


Endpoint
wss://api.travsport.se/customerapi/channels/connect


Topic
/customerapi/channels/user/topic/publish


Header Parameters

authorization (required) string - Bearer token


Channels

TimeToStart
TimeToDef
SplitTimes
PrelDisqualifiedHorses
Last500Meters


Sample code

Node.js: https://github.com/Troperty/racedata-node-samples


Connect using Javascript
const ws = new WebSocket(wsUrl, null, {
  headers: {
    authorization: `Bearer ${authToken}`
  }
});

const stompClient = Stomp.over(ws);
stompClient.connect({}, onConnected, onConnectionError);


Subscribe to topic
stompClient.subscribe(topic, onMessage);


Receive data from the server
// Receive a STOMP message from the server
const onMessage = (message) => {
  if (message.body) {
    const data = JSON.parse(message.body);
    console.log(data.payload);
  } else {
    console.log('Received empty message');
  }
};