Part 8 · 1 chapters · ~12 min
Deriv's Product and API
Deriv's products and contract families as a frontend sees them, the shared WebSocket API with authorisation, subscriptions and request ids, the price-then-buy proposal flow, open-contract streams, and what all of it means for screen design, with a socket manager sketch and the homework of reading their frames.
11
Products, contracts and the WebSocket API
Speaking in a company's own terms signals that you have done the reading. Confirm every API detail below against Deriv's public API documentation and their open-source frontend repositories before the technical round. Use this chapter as the mental model, not as the reference.
code
// a socket manager sketch: one connection, request ids, subscriptions with cleanup
class DerivSocket {
private ws!: WebSocket; private nextId = 1;
private pending = new Map<number, (msg: any) => void>();
private subs = new Map<string, Set<(msg: any) => void>>(); // subscription id → listeners
send(req: object): Promise<any> {
const req_id = this.nextId++;
this.ws.send(JSON.stringify({ ...req, req_id }));
return new Promise(res => this.pending.set(req_id, res));
}
private onMessage = (e: MessageEvent) => {
const msg = JSON.parse(e.data);
const subId = msg.subscription?.id;
if (subId && this.subs.has(subId)) this.subs.get(subId)!.forEach(f => f(msg));
const p = this.pending.get(msg.req_id); if (p) { this.pending.delete(msg.req_id); p(msg); }
};
// reconnect: reopen with backoff, re-authorise, re-send every active subscription, then
// reconcile open contracts from a snapshot before trusting the stream again
}| screen | streams | designed states |
|---|---|---|
| trade ticket | ticks for the symbol; the proposal for the current inputs | pricing, price moved, market closed, insufficient balance, buy rejected |
| open positions | one open-contract stream per position | reconnecting (values frozen and labelled), stopped out, take-profit hit |
| cashier | transfer status (poll or push) | pending, confirming with bank, failed with reason, reversed |
| statement | history calls, paginated | empty, loading more, export in progress |
do your homework visibly
Open DTrader, place a demo trade, and watch the WebSocket frames in DevTools (the DevTools course part 4). Mentioning one specific thing you saw in their frames, such as how proposals update or how reconnection behaves, is exactly the "childlike curiosity, evidence-based" signal the recruiter described.
DERIV'S PRODUCT, AS A FRONTEND SEES IT
contract types, the WebSocket API, and the price-then-buy flow every trading screen is built on
swipe the figure sideways, or tap expand for full screen
1/6
the products
The products: DTrader (the main web trading platform: options, multipliers, accumulators), Deriv Bot (a visual strategy builder that trades through the same API), MT5, Deriv X and cTrader integrations for CFDs, mobile apps, and P2P for deposits and withdrawals in many emerging markets, including Nigeria. Synthetic indices are generated markets that trade around the clock.