Introduction
REST is enough to place a trade. For a live book — ticks, open P/L, and position changes — you typically use two feeds. Chart ticks come from the public market socket /ws/markets (same as Trade, no OAuth). Account, position, and contract updates for the signed-in user come from the Partner WebSocket after you have an access token.
The Partner WebSocket is scoped to that authorized user. It is not a feed of every referred trader. Partner-wide fills and commissions belong on webhooks.
Bootstrap the socket
For index candles and last price, open wss://api.coinpes.com/ws/markets (locally ws://localhost:8082/ws/markets) and subscribe with { "action": "subscribe", "symbol": "VOL75" }. That path is public.
- For the authorized user,
POST /v1/ws-tokenwith the Bearer token. The response includes a short-lived bootstrap token andws_url. - Open that URL. Locally the gateway is often port 8001; production typically uses
wss://on the API host. - Subscribe only to the channels the screen needs (quotes for the visible symbol, account, positions). Unused channels waste battery and make reconnects heavier.
What to show in your UI
- Mid, bid, and ask for the symbol on screen.
- Open CFD positions and live P/L.
- Open contracts until they settle.
- Wallet balance after fills and settlements.
Prefer socket updates for animation. After any gap, trust REST for the official list of positions and balances so a missed tick cannot leave a ghost row.
Reconnects
Treat the socket as ephemeral. If it drops, mint a fresh ws-token and reconnect. Do not reuse an expired bootstrap token. Then reconcile: list positions and accounts over REST so you do not miss a fill that happened while disconnected.
Back off on repeated failures. A tight reconnect loop will hit rate limits and look like an outage to the user.
Webhooks vs the socket
If you also run a partner backend, do not expect this connection to tell you that a referred trader on another device just settled a contract. Subscribe to contract.settled (and Test it in Referrals) for that.
The WebSocket is for the authorized user, not a dump of every referred trader. Partner-wide events belong on webhooks.
Message shapes: WebSocket reference.
