We're still building this. Field names may change before launch.

View as Markdown

Streaming

The per-account WebSocket protocol. Full sync, incremental updates, market data, sequence numbers and resume.

There are two ways to stream:

  • A socket.io protocol for existing clients that already speak it, alongside the /users/current/… REST API. See Switching from another provider.
  • Tickwire’s plain WebSocket protocol (this page): JSON frames, one socket per account, easy to use from any language without an SDK.

Connect

wss://api.tickwire.io/users/current/accounts/{accountId}/ws?auth-token=<token>

Or, better, leave the key out of the URL and send it as the auth-token (or X-API-Key, or Authorization: Bearer) header on the upgrade, if your client can set headers. Browsers can’t, so they use the query parameter; give a browser a short-lived scoped token, not a full key. See WebSockets: header or query parameter.

Subscribe

{
  "type": "subscribe",
  "sync": { "startingHistoryTime": "2026-09-01T00:00:00Z", "sessionId": null, "lastSeq": null },
  "marketData": [
    { "symbol": "EURUSD", "subscriptions": [
      { "type": "quotes", "intervalInMilliseconds": 500 },
      { "type": "candles", "timeframe": "1m" },
      { "type": "ticks" },
      { "type": "marketDepth" }
    ] }
  ]
}
  • sync.startingHistoryTime: send history (deals and history orders) from this time. null sends all history. sync.startingHistoryOrderTime and sync.startingDealTime set it for one kind only.
  • sync.sessionId and sync.lastSeq: resume after a disconnect (below). Leave them out on a first connect.
  • marketData: optional. Without subscriptions you get quotes. ticks and marketDepth are MT5 only. On MT4 they are refused with an error frame and not_supported_on_mt4. The rest of the stream carries on.

We answer with a subscribed frame. It carries your sessionId and the market data you now receive.

Send {"type": "unsubscribe", "marketData": [...]} to drop market data. You get an unsubscribed frame back. {"type": "unsubscribe"} with no marketData ends the session and closes the socket. Send {"type": "ping"} whenever you like; you’ll get pong.

Frames

Every server frame has type, seq (increasing by one per frame) and time (UTC).

Full synchronization, in this order. Every sync frame carries the same synchronizationId.

FrameCarries
synchronizationStartedsessionId, platform, historyStartTime, historyOrdersSupported and the broker time offset
brokerConnectionStatusconnected
healthour health snapshot
accountInformationaccountInformation
specificationssymbol specifications
positionsthe full list (replace yours)
positionsSynchronizedNothing else
ordersthe full list of pending orders (replace yours)
ordersSynchronizedNothing else
historyOrdersa batch; may repeat
historyOrdersSynchronizedNothing else
dealsa batch; may repeat
dealsSynchronizedNothing else
synchronizedYour state is complete

Prices for the symbols you subscribed to follow.

Incremental updates after that: accountInformationUpdated, positionUpdated, positionRemoved, orderUpdated, orderCompleted, historyOrderAdded, dealAdded.

Market data: prices (with the account’s equity, margin, freeMargin and marginLevel), candles, ticks and book.

Status: health (our health snapshot) whenever it changes, and brokerConnectionStatus with connected: true|false.

Control: subscribed, unsubscribed, resumed, pong, error (with error and message) and warning, for example when you read too slowly (below).

{ "type": "positionUpdated", "seq": 1842, "time": "2026-09-23T11:02:14.120Z",
  "position": { "id": "46870472", "symbol": "EURUSD", "type": "POSITION_TYPE_BUY", "volume": 0.01,
                "openPrice": 1.07182, "profit": 0.42, "brokerTime": "2026-09-23 14:02:14.120" } }

Resume after a disconnect

Keep the sessionId from synchronizationStarted or subscribed, and the last seq you processed. Reconnect and subscribe with both:

{ "type": "subscribe", "sync": { "sessionId": "<your sessionId>", "lastSeq": 2010 } }
  • If we still hold every frame after lastSeq, we replay them. Then a resumed frame arrives with fromSeq, toSeq and replayed. No gap, no full sync.
  • If not, we run a full synchronization in the same session. seq keeps counting up. Replace your state when synchronized arrives.
  • lastSeq without sessionId always gets a full synchronization.

Slow consumers

If you don’t read fast enough, we don’t buffer forever. We drop frames and send:

{ "type": "warning", "seq": 2210, "code": "slow_consumer",
  "firstMissingSeq": 2011, "lastMissingSeq": 2209, "droppedFrames": 199 }

Resume with your sessionId and lastSeq: 2010 to get the missing frames back, or accept a fresh sync. If your queue stays full for 30 seconds, we close the socket with code 4008. You can resume the same way.

Close codes

CodeMeaning
1000You sent unsubscribe with no marketData
4001The session was resumed on another socket
4008Slow consumer. Resume with sessionId and lastSeq
4029Too many sessions

Heartbeats

We send a frame at least every 15 seconds, a health frame if nothing else is happening. If you hear nothing for 60 seconds, reconnect.