Live Data

The Sparta Live API allows you to subscribe to real-time data for integration into your applications. It uses the WebSocket protocol for live streaming.

wss://api-live.sparta.app/v2/customer/socket/websocket

All messages in both directions are JSON text frames. Binary frames are rejected.


Authentication

Before subscribing to data, you must authenticate using a JWT token. You can obtain your JWT token from the authentication endpoint.

Authentication payload:

{"type": "auth", "payload": "YOUR_JWT_HERE"}

Successful authentication response:

{"type": "auth-success"}

Failed authentication response:

{"type": "auth-failed"}
⚠️

Tokens issued by the authentication endpoint are valid for 12 hours. The token is checked when you send auth; an open connection is not closed when the token later expires, but you will need a valid token to authenticate again after any disconnection. Request a fresh token as part of your reconnect logic rather than reusing one obtained earlier.

Any other command sent before a successful auth is rejected with a NOT_LOGGED error and the connection is closed.


Subscriptions

Once authenticated, subscribe to price updates for a curve quotation. id is the quotation identifier from the catalogue; tenor is the tenor name exactly as returned by the ongoing and historical endpoints (for example "Dec 26", "Q1 27", "1-5 Dec 26", "C 01"); type must be "price".

Subscribe to a single tenor:

{
  "type": "subscribe",
  "payload": {
    "id": "688e03d9-8210-5437-9156-822828be2c74",
    "tenor": "Dec 26",
    "type": "price"
  }
}

Subscribe to all calendar tenors of a curve quotation:

{
  "type": "subscribe",
  "payload": {
    "id": "688e03d9-8210-5437-9156-822828be2c74",
    "tenor": "*",
    "type": "price"
  }
}
📘

"*" covers the calendar tenors (months, quarters, years, cycles, half-months, decades and delivery windows). It does not include the continuous tenors C 00, C 01 and C 02. Subscribe to those explicitly if you need them.

Initial snapshot

As soon as a subscription is established you receive the latest value we hold for each subscribed tenor, one message per tenor:

{
  "payload": {
    "id": "688e03d9-8210-5437-9156-822828be2c74",
    "tenor": "Dec 26",
    "generatedOn": "2026-08-24T17:14:58.025",
    "price": 183.0
  },
  "type":"price"
}
  • generatedOn is the time the value was published, in UTC (no timezone suffix is included). It matches the publication times on the intraday endpoints (which carry extra sub-millisecond precision). Note the ongoing settlement and assessment endpoints stamp the snapshot time instead, so those will not match.
  • The snapshot is the last value published, however old that is — read generatedOn to see which day's value you have, rather than assuming it is current. Daily-assessed curves show the previous assessment until the new one is published.
  • Only tenors for which we hold a value are sent. If a tenor has never been published, has expired, or has not been updated for a long period, nothing is sent for it and no error is returned. Treat silence as "no current value" and fall back to the historical endpoints if you need one.
  • Subscribing again to the same tenor re-sends the snapshot, so you can use a subscribe as an on-demand "latest value" request.

Live updates

After the snapshot, every new value published for a subscribed tenor is pushed in the same format. The feed carries the latest value per tenor: if several values for the same tenor are published faster than your connection can consume them, intermediate ones may be skipped.


Error responses

Errors are returned as {"type": "<CODE>", "message": "..."}:

CodeMeaning
NO_ACCESSYour account is not enabled for live data, or the quotation is not in your licence.
NOT_LOGGEDA command was sent before successful authentication. The connection is closed.
ERROR_PARSINGThe message could not be parsed, or a payload field has an unsupported value (for example a type other than "price").
COMMAND_NOT_FOUNDUnknown type at the top level. Supported commands are auth, subscribe, unsubscribe and ping.
BINARY_MESSAGEA binary frame was received. Only text frames are accepted.
UNEXPECTED_ERRORAn internal error; retry, and contact support if it persists.

A successful subscribe has no separate acknowledgement — the snapshot messages are the confirmation.


Unsubscribing

To stop receiving updates for a subscription, send an unsubscribe message:

{
  "type": "unsubscribe",
  "payload": {
    "id": "688e03d9-8210-5437-9156-822828be2c74",
    "tenor": "Dec 26",
    "type": "price"
  }
}

To unsubscribe from all tenors for a curve quotation:

{
  "type": "unsubscribe",
  "payload": {
    "id": "688e03d9-8210-5437-9156-822828be2c74",
    "tenor": "*",
    "type": "price"
  }
}

Note: Unsubscribe is a fire-and-forget operation. No confirmation response is sent on success. You will simply stop receiving updates for the unsubscribed subscription.


Connection Health

To detect hung connections, you can send a ping message:

Ping:

{
  "type": "ping",
  "payload": {
    "name": "health check"
  }
}

Pong response:

{
  "type": "pong",
  "payload": {
    "name": "health check"
  }
}

Connection Keep-Alive

Two independent limits apply to every connection:

  • Idle limit — 60 seconds. If no message is sent in either direction for 60 seconds, the connection is dropped. This is an abrupt close (WebSocket close code 1006, no close frame). Incoming price updates count as activity, so a busy subscription keeps itself alive; a quiet one does not.
  • Subscription requirement — 3 minutes. A connection that holds no subscriptions is closed by the server after about 3 minutes (close code 1000), regardless of pings. Subscribe promptly after authenticating.

Best practice: subscribe immediately after auth-success, then send a ping every 30–50 seconds whenever your subscriptions are quiet.


Recovery After Disconnection

Connection state is not stored between sessions. When reconnecting, authenticate again (with a valid token) and resubscribe to all desired symbols.

There are two approaches for recovery:

Natural Refresh

  • No historical data replayed.
  • Client immediately receives the latest messages.
  • Recommended for stateless clients that only need current state.
  • Fastest approach.

Intraday Replay


Maintenance Schedule

  • Regular restarts occur on Sundays at 12:00 UTC. All clients will be disconnected.
  • Mid-week restarts may occur without notice for urgent fixes.
  • Clients should be configured to automatically reconnect, re-authenticate and resubscribe.
📘

Best practice: Disconnect after the Friday close and reconnect on Sunday after the scheduled restart.


Did this page help you?