WebSocket vs REST for crypto market data: when to use which

REST polling, WebSockets, Server-Sent Events and webhooks for crypto market data: how each works, what it costs, and how to combine snapshots with streams.

In short

REST and WebSocket are two ways to get the same market data. With REST, your code asks a question and gets one answer; to see changes, it has to ask again. With a WebSocket, your code opens one long-lived connection and the server pushes updates as they happen. REST is simpler and works everywhere; a stream is faster and cheaper once you need many updates. Most production systems use both.

This guide explains how REST polling, WebSockets, Server-Sent Events and webhooks work, what each costs in requests and complexity, and the snapshot plus stream pattern that most market data clients end up with.

REST: ask, answer, repeat

A REST API answers HTTP requests. You send GET /markets, the server returns the current state as JSON, and the connection's job is done. To follow changes, a client polls: it repeats the request on a timer.

REST fits well when:

  • The data changes slowly compared with how often you need it, such as a daily summary or a liquidation map that is rebuilt every few minutes.
  • You need history. Time windows and pages are natural in REST: ask for a range, follow a cursor to the next page.
  • You run in short-lived environments such as scheduled jobs or serverless functions that cannot hold a connection open.

The costs show up at higher frequency. Each poll is a full request that counts against rate limits, most polls return data that has not changed, and anything that happens between two polls is only seen at the next one.

Making polling cheaper

Two HTTP features remove most of the waste:

  • Conditional requests. The server sends an ETag with each answer. The client sends it back in If-None-Match, and if nothing changed the server replies 304 Not Modified with no body.1 Our API supports this on its snapshot endpoints, as described in pagination and caching.
  • Forward cursors. For feeds, the client asks only for rows newer than the last one it saw instead of re-reading the whole window. Our feeds take an after parameter for exactly that.

WebSocket: one connection, both directions

A WebSocket starts as an HTTP request that asks to upgrade the connection. Once the server agrees, the same TCP connection carries messages in both directions until either side closes it.2 For market data, the client usually sends a subscription message ("trades of BTC") and then receives a message for every update.

WebSockets fit well when:

  • Updates are frequent, such as trades, order book changes or per-second market state.
  • Latency matters. An update arrives as soon as the server sends it, not at the next poll.
  • The client needs to send messages too, for example to change subscriptions without reconnecting.

The costs are on the client side. A WebSocket client has to handle disconnects, reconnect with backoff, re-subscribe, detect stale connections with heartbeats, and work out what it missed while it was away. Servers and proxies can close idle or long-running connections at any time, so this is ordinary behaviour, not an edge case.

Server-Sent Events: a one-way stream over HTTP

Server-Sent Events (SSE) are a simpler kind of stream. The client makes a normal HTTP GET, and the server keeps the response open and writes events as lines of text.3 Data only flows from server to client, which is all most market data consumers need.

SSE has two practical advantages. It is plain HTTP, so it passes through proxies and firewalls that sometimes block WebSockets. And each event can carry an id; when a browser's EventSource reconnects, it sends the last id it received in a Last-Event-ID header, so the server can resend what was missed.3

Webhooks: the server calls you

A webhook turns the direction around. Instead of your code connecting to the server, the server sends an HTTP request to an endpoint you run whenever an event happens. Webhooks suit events that are rare but important, such as an alert condition, and need no open connection at all. The trade-off is that you must run a public endpoint, verify each request's signature and handle retries.

Choosing between them

NeedGood fit
History, ranges, backfillsREST with cursors
A state that changes every few minutesREST with conditional requests
Many updates per second, lowest delayWebSocket
A one-way live feed that resumes cleanlyServer-Sent Events
Rare events delivered to your serverWebhooks

The pattern most clients end up with: snapshot plus stream

A stream alone is not enough, and neither is polling alone. Most robust clients combine them:

  1. Load a snapshot over REST or from the first message of the stream, and treat it as the full current state.
  2. Apply updates from the stream to that state as they arrive.
  3. On reconnect, resume or resync. If the server supports resuming from the last event id, ask for what was missed. If the gap is too long, or the stream represents a state rather than a list of events, load a fresh snapshot and start again.
  4. Backfill gaps over REST. When a stream reports that some events fell outside its resume window, page through the REST feed for that window.

Order book clients follow the same idea: a book snapshot, then incremental changes, and a fresh snapshot whenever the sequence breaks.

How this works on Blockmetric

Our API offers all four routes, so a client can pick per use case:

  • REST for every dataset, with cursor pages, time windows, forward polling and ETags. See the API reference.
  • A live stream over Server-Sent Events, with the same stream available over a WebSocket, carrying radar events, every single liquidation, or the live market state of every coin. The markets channel starts every connection with a full snapshot and then sends only the markets whose values changed. Event channels resume from Last-Event-ID within a limited window and send a gap frame when something fell outside it, and a heartbeat comment arrives every 15 seconds.4 The stream is part of API Pro.
  • Webhooks on API Dev and API Pro, signed, for the same radar events. See webhooks.

One open stream counts as one request against the per-minute limit, which is why a stream is usually far cheaper than polling the same data. The plans and their limits are compared on API pricing, and API rate limits and API keys explains how limits are counted.

For Hyperliquid's own API, which also has an HTTP info endpoint and a WebSocket, see Hyperliquid API. For blockchain RPC, where the same choice exists between HTTPS and WebSocket subscriptions, see What is an RPC node?

Common questions

Is WebSocket always faster than REST? For receiving updates, yes, because nothing waits for the next poll. For a single question, one REST request is just as fast and much simpler.

Do I still need REST if I use a stream? In practice, yes: for the first snapshot, for history and for filling gaps after a disconnect.

Why does my WebSocket keep disconnecting? Servers, load balancers and proxies close connections for many ordinary reasons: deploys, idle timeouts, maximum durations, slow readers. A client that reconnects and resumes on its own is the expected design.

Next steps

Live data

See today’s numbers

The live pages update continuously.

Read the stream docs

Free plan: every coin, up to 30 days of history. Compare plans

Sources

  1. IETF, RFC 9110 "HTTP Semantics", sections on ETag, If-None-Match and 304 Not Modified (accessed 2026-11-11)Back to text
  2. IETF, RFC 6455 "The WebSocket Protocol" (accessed 2026-11-11)Back to text
  3. WHATWG HTML Living Standard, "Server-sent events" (accessed 2026-11-11)Back to text
  4. Blockmetric API reference, "Live event stream" (accessed 2026-11-11)Back to text

How we collect and check the data: Data & methodology.

Share this guide as a link or as an image card with its title.

LiveHyperliquid markets 15sOperationalHyperliquid positions & whales 16sOperationalLiquidation heatmap & levels 20sOperationalLighter markets & liquidations 21sOperationalLighter positions & heatmap 22sOperationalLighter on Robinhood Chain: positions & heatmap 19sOperationalAster markets 53sOperationalBinance markets 43sOperationalBybit markets 59sOperationalGate markets 24sOperationalHTX markets 36sOperationalKuCoin markets 40sOperationalBinance liquidations 27sOperationalBybit liquidations 27sOperationalGate liquidations 27sOperationalHTX liquidations 27sOperationaldYdX positions & heatmap 27sOperationalGMX positions & heatmap 15sOperationalLong/short & open interest history 39sOperationalOrder books & trade flow 11sOperationalOn-chain transfers 20sOperationalSecurity monitor 22sOperationalBlockmetric Sentiment 8mOperationalAgency releases 4mOperationalAlert delivery 18sOperationalDataset files 52mOperational17:00:10 UTC