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

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"}
⚠️

You must re-authenticate at least every 24 hours to avoid being disconnected.


Subscriptions

Once authenticated, you can subscribe to specific curve quotation updates.

Subscribe to a single contract for a curve quotation:

{
  "type": "subscribe",
  "payload": {
    "id": "0007f4dd-673a-5309-b606-178aadbd2d2c",
    "tenor": "Jul 25",
    "type": "price"
  }
}

Subscribe to all tenor prices for a curve quotation:

{
  "type": "subscribe",
  "payload": {
    "id": "0007f4dd-673a-5309-b606-178aadbd2d2c",
    "tenor": "*",
    "type": "price"
  }
}

After a subscription is established, you will immediately receive the latest value:

{
  "payload": {
    "id": "0007f4dd-673a-5309-b606-178aadbd2d2c",
    "tenor": "Jul 25",
    "generatedOn": "2025-05-16T15:16:05.173",
    "price": 3.5788883413888546
  },
  "type":"price"
}
⚠️

Subscriptions are not stored between sessions. If you reconnect, you must resubscribe.


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

To prevent idle disconnections, the WebSocket server requires periodic activity from the client.

  • Requirement: The client MUST send a ping message (or any other valid message) within 60 seconds of the last message.
  • Failure Behavior: If no message is received within 60 seconds, the server will close the connection.

Best practice: Send a ping message every 30-50 seconds.


Recovery After Disconnection

When reconnecting to the server, clients should 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.
📘

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