Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.
Every channel, live or replayed, uses wss://api.0xarchive.io/ws, except the live mempool channel, which is served only on wss://stream.0xarchive.io/ws with the same key and protocol. If one snapshot or a bounded window answers the question, the REST API is simpler to retry.
Before you connect
Subscribe to one channel
Save this as subscribe.mjs and run node subscribe.mjs:
An open socket only means the key was accepted; a wrong key fails the handshake with HTTP 401. Wait for subscribed after subscribe, or replay_started after replay, and handle error: an unknown channel, for example, returns an error message with error_codeinvalid_parameter.
Stream live or replay history
The same socket does both. Each command names its channel and symbol.
Live streaming
The example above is a live subscription; unsubscribe takes the same channel and symbol. Channels lists every channel with its live and replay availability and what each message does to your local state, Real-time streams covers ordering and local books, and L4 order book covers stateful L4 books built from a snapshot and diffs. For Hyperliquid channels and depth choices, see Hyperliquid WebSocket streaming.
Historical replay
Send a replay command with a window in Unix milliseconds. Save this as replay.mjs and run node replay.mjs. It replays five minutes of BTC trades from an hour ago, inside the Free plan’s 30 days, and takes about 30 seconds at speed 10:
import WebSocket from "ws";const apiKey = process.env.OXARCHIVE_API_KEY;if (!apiKey) throw new Error("Set OXARCHIVE_API_KEY");const ws = new WebSocket("wss://api.0xarchive.io/ws", { headers: { Authorization: `Bearer ${apiKey}` }});const end = Date.now() - 60 * 60 * 1000; // one hour agoconst start = end - 5 * 60 * 1000; // five minutes earlierlet rows = 0;ws.on("open", () => { ws.send(JSON.stringify({ op: "replay", channel: "trades", symbol: "BTC", start, end, speed: 10 }));});ws.on("message", (raw) => { const message = JSON.parse(raw); if (message.type === "replay_started") { console.log("replaying", message.channel, message.symbol, "at", `${message.speed}x`); } else if (message.type === "historical_data") { rows += 1; if (rows === 1) console.log("first fill", new Date(message.timestamp).toISOString(), message.data.price, message.data.size); } else if (message.type === "gap_detected") { console.warn("gap from", message.gap_start, "to", message.gap_end); } else if (message.type === "replay_completed") { console.log("replay completed:", rows, "fill rows"); ws.close(); } else if (message.type === "error") { // The server refused the command, for example a window outside your plan's history. console.error(message.error_code, message.message); ws.close(); }});// A connection failure, such as a rejected key, arrives as the socket's own error event.ws.on("error", (err) => console.error("connection failed:", err.message));
It prints the speed the replay runs at, the first fill, and the number of fill rows when the window ends. Two kinds of error reach the client. A failed connection, such as a rejected key, fires the socket’s own error event with the HTTP status of the handshake. A refused command arrives as a message with typeerror and a stable error_code, and the socket stays open.Standard replay sends replay_started, then historical_data messages in order, gap_detected where the window has an interruption, and replay_completed. A multi-channel replay sends replay_snapshot baselines before its timeline. L4 and full-depth replay sends replay_started, one l4_snapshot, ordered l4_batch messages, and replay_completed; it ignores speed, and replay.seek returns an error. Replay covers each delivery model and the pause, resume, seek, and stop controls. To prepare a backtest from REST windows or replay, see Prepare data for a reproducible backtest.
Commands and events
Client commands use op: subscribe, unsubscribe, replay, replay.pause, replay.resume, replay.seek, replay.stop, and ping. Server messages use type, and the names differ: the command replay.pause is answered by the event replay_paused. The older stream and stream.stop commands return an error; use Bulk Exports for large files. The Protocol reference has every command and event shape.
Channels and limits
Which channels stream live, which replay, and how, is on Channels, venue family by venue family. Subscription, connection, and replay-speed limits per plan are on Limits.
Measure your own latency
Current WebSocket health is an HTTP service check, not a measurement of your connection. These are separate numbers: HTTP service health, server-side REST handler timing, stored-data freshness, ingest lag, WebSocket upgrade/connect time, application ping/pong round-trip time, and client processing lag. In the data-quality response, websocket.current_ms is the latest stored order-book freshness value, not client WebSocket round-trip time.To measure your own path, send {"op":"ping"} and time the {"type":"pong"} reply. The result describes your client and network.
Next step
Last modified on October 18, 2026
Was this page helpful?
{"docsConfig":{"theme":"palm","$schema":"https://mintlify.com/docs.json","name":"0xArchive","description":"Hyperliquid and Lighter market data through the REST API, WebSocket, Webhook Alerts, and Bulk Exports. Start with your first request on the Free plan.","colors":{"primary":"#15803D","light":"#21C55E","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/0xarchive-e895b8e7/_8ck-oUq6ufsot88/logo-light.svg?fit=max\u0026auto=format\u0026n=_8ck-oUq6ufsot88\u0026q=85\u0026s=125ef51299181bd38460b33344f30ff5","dark":"https://mintcdn.com/0xarchive-e895b8e7/_8ck-oUq6ufsot88/logo-dark.svg?fit=max\u0026auto=format\u0026n=_8ck-oUq6ufsot88\u0026q=85\u0026s=829b1f9b3638e20a5c6bc6032ab00025","href":"https://0xarchive.io/?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=logo_home"},"favicon":"https://mintcdn.com/0xarchive-e895b8e7/_8ck-oUq6ufsot88/favicon.svg?fit=max\u0026auto=format\u0026n=_8ck-oUq6ufsot88\u0026q=85\u0026s=df84c8913362b83bdf0443dd4b49a717","api":{"openapi":{"source":"openapi.json","directory":"api-reference"},"params":{"expanded":"all"},"playground":{"display":"interactive"},"examples":{"defaults":"required","languages":["curl","python","javascript","go"],"prefill":true,"autogenerate":true},"url":"full"},"appearance":{"default":"dark","strict":false},"navbar":{"links":[{"href":"https://0xarchive.io/pricing?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=navbar_pricing","label":"Pricing"},{"href":"https://0xarchive.io/status?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=navbar_status","label":"Status"},{"href":"https://0xarchive.io/changelog?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=navbar_changelog","label":"Changelog"},{"href":"https://github.com/0xArchiveIO","label":"GitHub"}],"primary":{"type":"button","label":"Dashboard","href":"https://0xarchive.io/dashboard?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=navbar_dashboard"}},"footer":{"socials":{"x":"https://x.com/0xarchiveIo","github":"https://github.com/0xArchiveIO","telegram":"https://t.me/archivedotio","linkedin":"https://www.linkedin.com/company/0xarchive"},"links":[{"header":"Product","items":[{"label":"Pricing","href":"https://0xarchive.io/pricing?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_pricing"},{"label":"Status","href":"https://0xarchive.io/status?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_status"},{"label":"Data Catalog","href":"https://0xarchive.io/data?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_data_catalog"},{"label":"Dashboard","href":"https://0xarchive.io/dashboard?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_dashboard"}]},{"header":"Developers","items":[{"label":"Data rights","href":"/data-rights"},{"label":"AI clients","href":"/ai-clients"},{"label":"Coding agents","href":"/coding-agents"},{"label":"Choose an interface","href":"/tooling"}]},{"header":"Resources","items":[{"label":"Reference","href":"/reference"},{"label":"OpenAPI","href":"/openapi"},{"label":"Free crypto data API","href":"/free-crypto-data-api"},{"label":"Sitemap","href":"/sitemap"},{"label":"llms.txt","href":"/llms.txt"},{"label":"llms-full.txt","href":"/llms-full.txt"},{"label":"Resources","href":"https://0xarchive.io/resources?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_blog"}]},{"header":"Company","items":[{"label":"Home","href":"https://0xarchive.io/?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_home"},{"label":"Contact","href":"https://0xarchive.io/contact?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_contact"},{"label":"Terms","href":"https://0xarchive.io/terms?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_terms"},{"label":"Privacy","href":"https://0xarchive.io/privacy?utm_source=docs\u0026utm_medium=referral\u0026utm_campaign=docs_nav\u0026utm_content=footer_privacy"}]}]},"search":{"prompt":"Search routes, symbols, SDKs, WebSocket replay, and data quality"},"seo":{"metatags":{"canonical":"https://docs.0xarchive.io","og:site_name":"0xArchive Docs","og:type":"website","twitter:card":"summary_large_image","twitter:site":"@0xarchiveIo","google-site-verification":"Hpedp6bedqc3av1195euaGMwyFEVHcJhcyUY9YiMvTY"},"organization":{"id":"https://0xarchive.io/#organization","name":"0xArchive","legalName":"Archive Labs Inc.","url":"https://0xarchive.io/","logo":"https://0xarchive.io/logo-square-1024.png","sameAs":["https://x.com/0xarchiveIo","https://github.com/0xArchiveIO","https://t.me/archivedotio","https://www.linkedin.com/company/0xarchive/"]},"indexing":"all"},"fonts":{"family":"Geist","source":"fonts/geist-variable.woff2","format":"woff2"},"icons":{"library":"lucide"},"styling":{"eyebrows":"breadcrumbs","codeblocks":{"theme":"github-dark"},"latex":true},"errors":{"404":{"redirect":false,"title":"Page not found","description":"Open the quickstart, REST reference, or search the docs for the route you need."}},"contextual":{"options":["copy","view","assistant","chatgpt","claude","perplexity","cursor","vscode","windsurf","grok","devin","aistudio"],"display":"header"},"thumbnails":{"background":"https://mintcdn.com/0xarchive-e895b8e7/ZmnWL31Kq8lGIdPW/images/og-background.svg?fit=max\u0026auto=format\u0026n=ZmnWL31Kq8lGIdPW\u0026q=85\u0026s=802efd004c3811d20f873d5f00c5ef32"},"metadata":{"timestamp":true},"markdown":{"schema":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"0xarchive-e895b8e7","hasAudioNarration":false,"actualSubdomain":"0xarchive-e895b8e7","customDomains":["docs.0xarchive.io"],"gitSource":{"type":"github","owner":"0xarchiveio","repo":"mintlify-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6afc9f4a07f748c86f2884f0","clientVersion":"0.0.4177","searchFilterCounts":[{"language":"default","tag":"REST API","count":505},{"language":"default","tag":"OpenAPI and schemas","count":242},{"language":"default","tag":"Operation schemas","count":237},{"language":"default","tag":"Endpoint reference","count":225},{"language":"default","tag":"HIP-3","count":104},{"language":"default","tag":"Hyperliquid core","count":104},{"language":"default","tag":"Terminal","count":96},{"language":"default","tag":"Lighter","count":60},{"language":"default","tag":"Webhook Alerts","count":53},{"language":"default","tag":"HIP-4","count":52}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":true,"enableContextualStarterQuestions":true,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"[email protected]","showHelpButton":true}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"styles.css","href":"/_mintlify/custom/0xarchive-e895b8e7/f5f5f3ca5c5101a6/styles.css"}],"page":{"pagePath":"websocket","slug":"/websocket","pageMetadata":{"title":"WebSocket API","sidebarTitle":"Overview","description":"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.","href":"/websocket"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const TaskCard=({title,description,href,action,secondaryHref,secondaryAction,tracking,facts=[],children})=>{const _components={a:`a`,..._provideComponents()};return _jsx(`div`,{className:`oxa-task-card-shell`,children:_jsxs(`section`,{className:`oxa-task-card`,\"aria-label\":title,children:[_jsxs(`div`,{className:`oxa-task-card__summary`,children:[_jsx(`p`,{className:`oxa-task-card__title`,children:_jsx(`strong`,{children:title})}),description\u0026\u0026_jsx(`p`,{className:`oxa-task-card__description`,children:description})]}),facts.length>0\u0026\u0026_jsx(`dl`,{className:`oxa-task-card__facts`,children:facts.map(({label,value})=>_jsxs(`div`,{className:`oxa-task-card__fact`,children:[_jsx(`dt`,{className:`oxa-task-card__label`,children:label}),_jsx(`dd`,{className:`oxa-task-card__value`,children:value})]},label))}),children\u0026\u0026_jsx(`div`,{className:`oxa-task-card__content`,children}),_jsxs(`div`,{className:`oxa-task-card__actions`,children:[_jsx(_components.a,{className:`oxa-cta oxa-task-card__primary`,href,\"data-oxa-cta\":tracking,children:action}),secondaryHref\u0026\u0026_jsxs(_components.a,{className:`oxa-task-card__secondary`,href:secondaryHref,children:[secondaryAction,_jsx(`span`,{\"aria-hidden\":`true`,children:` →`})]})]})]})})};function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning,_MdxComponentBoundary}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Every channel, live or replayed, uses `,_jsx(_components.code,{children:`wss://api.0xarchive.io/ws`}),`, except the live `,_jsx(_components.a,{href:`/websocket/mempool`,children:_jsx(_components.code,{children:`mempool`})}),` channel, which is served only on `,_jsx(_components.code,{children:`wss://stream.0xarchive.io/ws`}),` with the same key and protocol. If one snapshot or a bounded window answers the question, the `,_jsx(_components.a,{href:`/rest-api`,children:`REST API`}),` is simpler to retry.`]}),`\n`,_jsx(Heading,{level:`2`,id:`before-you-connect`,children:`Before you connect`}),`\n`,_jsx(_MdxComponentBoundary,{name:`TaskCard`,children:_jsx(TaskCard,{title:`Get your application connected`,href:`/websocket/connection`,action:`Connection setup`,secondaryHref:`/websocket/channels`,secondaryAction:`Browse channels`,description:`Keep your key on the server, then start with the channel your application needs.`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An API key, sent in the opening handshake as `,_jsx(_components.code,{children:`Authorization: Bearer $OXARCHIVE_API_KEY`}),`. The Free plan works, and replays the most recent 30 days.`]}),`\n`,_jsxs(_components.li,{children:[`A server-side runtime. Browsers cannot set the `,_jsx(_components.code,{children:`Authorization`}),` header, so a browser app connects through your backend. Keep the key out of browser code, logs, and shared notebooks.`]}),`\n`,_jsxs(_components.li,{children:[`For the example below, Node.js 18 or later and the `,_jsx(_components.code,{children:`ws`}),` package: `,_jsx(_components.code,{children:`npm install ws`}),`.`]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`subscribe-to-one-channel`,children:`Subscribe to one channel`}),`\n`,_jsxs(_components.p,{children:[`Save this as `,_jsx(_components.code,{children:`subscribe.mjs`}),` and run `,_jsx(_components.code,{children:`node subscribe.mjs`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`21`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-dark github-dark`,style:{backgroundColor:`#24292e`,\"--shiki-dark-bg\":`#24292e`,color:`#e1e4e8`,\"--shiki-dark\":`#e1e4e8`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`21`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`import`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` WebSocket `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`from`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"ws\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` process.env.`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`OXARCHIVE_API_KEY`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`!`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`apiKey) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`throw`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` new`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:` Error`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"Set OXARCHIVE_API_KEY\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` ws`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` new`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:` WebSocket`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"wss://api.0xarchive.io/ws\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` headers: { Authorization: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"`Bearer ${\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`apiKey`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"}`\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"open\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, () `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`send`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`JSON`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`stringify`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`({ op: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"subscribe\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, channel: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"orderbook\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, symbol: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }));`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"message\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, (`}),_jsx(_components.span,{style:{color:`#FFAB70`,\"--shiki-dark\":`#FFAB70`},children:`raw`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` message`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`parse`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(raw);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"subscribed\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"subscribed\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, message.channel, message.symbol);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(message.symbol, message.data.levels[`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`0`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`][`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`0`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`], message.data.levels[`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`1`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`][`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`0`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`]);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`error`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(message.error_code, message.message);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"close\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, (`}),_jsx(_components.span,{style:{color:`#FFAB70`,\"--shiki-dark\":`#FFAB70`},children:`code`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#FFAB70`,\"--shiki-dark\":`#FFAB70`},children:`reason`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"closed\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, code, `}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`String`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(reason)));`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The server first confirms the subscription:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-dark github-dark`,style:{backgroundColor:`#24292e`,\"--shiki-dark-bg\":`#24292e`,color:`#e1e4e8`,\"--shiki-dark\":`#e1e4e8`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"subscribed\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"channel\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"orderbook\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"coin\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"symbol\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Then each update arrives as a `,_jsx(_components.code,{children:`data`}),` message. `,_jsx(_components.code,{children:`levels`}),` holds bids, then asks, up to 20 per side (one each shown here):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-dark github-dark`,style:{backgroundColor:`#24292e`,\"--shiki-dark-bg\":`#24292e`,color:`#e1e4e8`,\"--shiki-dark\":`#e1e4e8`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"data\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"channel\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"orderbook\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"coin\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"symbol\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"coin\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"time\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`1791287222643`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` \"levels\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` [{ `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"px\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"86303.0\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"sz\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"17.36307\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"n\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`55`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` [{ `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"px\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"86304.0\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"sz\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"0.99133\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`\"n\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`: `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`11`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`An open socket only means the key was accepted; a wrong key fails the handshake with HTTP `,_jsx(_components.code,{children:`401`}),`. Wait for `,_jsx(_components.code,{children:`subscribed`}),` after `,_jsx(_components.code,{children:`subscribe`}),`, or `,_jsx(_components.code,{children:`replay_started`}),` after `,_jsx(_components.code,{children:`replay`}),`, and handle `,_jsx(_components.code,{children:`error`}),`: an unknown channel, for example, returns an `,_jsx(_components.code,{children:`error`}),` message with `,_jsx(_components.code,{children:`error_code`}),` `,_jsx(_components.code,{children:`invalid_parameter`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`stream-live-or-replay-history`,children:`Stream live or replay history`}),`\n`,_jsx(_components.p,{children:`The same socket does both. Each command names its channel and symbol.`}),`\n`,_jsx(Heading,{level:`3`,id:`live-streaming`,children:`Live streaming`}),`\n`,_jsxs(_components.p,{children:[`The example above is a live subscription; `,_jsx(_components.code,{children:`unsubscribe`}),` takes the same channel and symbol. `,_jsx(_components.a,{href:`/websocket/channels`,children:`Channels`}),` lists every channel with its live and replay availability and what each message does to your local state, `,_jsx(_components.a,{href:`/websocket/real-time`,children:`Real-time streams`}),` covers ordering and local books, and `,_jsx(_components.a,{href:`/websocket/l4-orderbook`,children:`L4 order book`}),` covers stateful L4 books built from a snapshot and diffs. For Hyperliquid channels and depth choices, see `,_jsx(_components.a,{href:`/hyperliquid-websocket-streaming-api`,children:`Hyperliquid WebSocket streaming`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`historical-replay`,children:`Historical replay`}),`\n`,_jsxs(_components.p,{children:[`Send a `,_jsx(_components.code,{children:`replay`}),` command with a window in Unix milliseconds. Save this as `,_jsx(_components.code,{children:`replay.mjs`}),` and run `,_jsx(_components.code,{children:`node replay.mjs`}),`. It replays five minutes of BTC trades from an hour ago, inside the Free plan’s 30 days, and takes about 30 seconds at `,_jsx(_components.code,{children:`speed`}),` 10:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`38`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-dark github-dark`,style:{backgroundColor:`#24292e`,\"--shiki-dark-bg\":`#24292e`,color:`#e1e4e8`,\"--shiki-dark\":`#e1e4e8`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`38`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`import`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` WebSocket `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`from`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"ws\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` process.env.`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`OXARCHIVE_API_KEY`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`!`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`apiKey) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`throw`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` new`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:` Error`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"Set OXARCHIVE_API_KEY\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` ws`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` new`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:` WebSocket`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"wss://api.0xarchive.io/ws\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` headers: { Authorization: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"`Bearer ${\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`apiKey`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"}`\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` end`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` Date.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`now`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`() `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`-`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 60`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` *`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 60`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` *`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 1000`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`; `}),_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#6A737D`},children:`// one hour ago`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` start`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` end `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`-`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 5`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` *`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 60`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` *`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 1000`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`; `}),_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#6A737D`},children:`// five minutes earlier`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`let`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` rows `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 0`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"open\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, () `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`send`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`JSON`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`stringify`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`({ op: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"replay\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, channel: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"trades\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, symbol: `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"BTC\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, start, end, speed: `}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:`10`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }));`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"message\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, (`}),_jsx(_components.span,{style:{color:`#FFAB70`,\"--shiki-dark\":`#FFAB70`},children:`raw`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` const`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` message`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` =`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`parse`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(raw);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"replay_started\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"replaying\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, message.channel, message.symbol, `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"at\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"`${\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`message`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`.`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`speed`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:\"}x`\"}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` } `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`else`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"historical_data\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` rows `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`+=`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 1`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (rows `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#79B8FF`,\"--shiki-dark\":`#79B8FF`},children:` 1`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"first fill\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`new`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:` Date`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(message.timestamp).`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`toISOString`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(), message.data.price, message.data.size);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` } `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`else`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"gap_detected\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`warn`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"gap from\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, message.gap_start, `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"to\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, message.gap_end);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` } `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`else`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"replay_completed\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`log`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"replay completed:\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, rows, `}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"fill rows\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`close`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` } `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`else`}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:` if`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` (message.type `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`===`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#6A737D`},children:` // The server refused the command, for example a window outside your plan's history.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`error`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(message.error_code, message.message);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`close`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#6A737D`},children:`// A connection failure, such as a rejected key, arrives as the socket's own error event.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`ws.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`on`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"error\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, (`}),_jsx(_components.span,{style:{color:`#FFAB70`,\"--shiki-dark\":`#FFAB70`},children:`err`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`) `}),_jsx(_components.span,{style:{color:`#F97583`,\"--shiki-dark\":`#F97583`},children:`=>`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:` console.`}),_jsx(_components.span,{style:{color:`#B392F0`,\"--shiki-dark\":`#B392F0`},children:`error`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`(`}),_jsx(_components.span,{style:{color:`#9ECBFF`,\"--shiki-dark\":`#9ECBFF`},children:`\"connection failed:\"`}),_jsx(_components.span,{style:{color:`#E1E4E8`,\"--shiki-dark\":`#E1E4E8`},children:`, err.message));`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`It prints the speed the replay runs at, the first fill, and the number of fill rows when the window ends. Two kinds of error reach the client. A failed connection, such as a rejected key, fires the socket’s own `,_jsx(_components.code,{children:`error`}),` event with the HTTP status of the handshake. A refused command arrives as a message with `,_jsx(_components.code,{children:`type`}),` `,_jsx(_components.code,{children:`error`}),` and a stable `,_jsx(_components.code,{children:`error_code`}),`, and the socket stays open.`]}),`\n`,_jsxs(_components.p,{children:[`Standard replay sends `,_jsx(_components.code,{children:`replay_started`}),`, then `,_jsx(_components.code,{children:`historical_data`}),` messages in order, `,_jsx(_components.code,{children:`gap_detected`}),` where the window has an interruption, and `,_jsx(_components.code,{children:`replay_completed`}),`. A multi-channel replay sends `,_jsx(_components.code,{children:`replay_snapshot`}),` baselines before its timeline. L4 and full-depth replay sends `,_jsx(_components.code,{children:`replay_started`}),`, one `,_jsx(_components.code,{children:`l4_snapshot`}),`, ordered `,_jsx(_components.code,{children:`l4_batch`}),` messages, and `,_jsx(_components.code,{children:`replay_completed`}),`; it ignores `,_jsx(_components.code,{children:`speed`}),`, and `,_jsx(_components.code,{children:`replay.seek`}),` returns an error. `,_jsx(_components.a,{href:`/websocket/replay`,children:`Replay`}),` covers each delivery model and the pause, resume, seek, and stop controls. To prepare a backtest from REST windows or replay, see `,_jsx(_components.a,{href:`/guides/point-in-time-backtesting`,children:`Prepare data for a reproducible backtest`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`commands-and-events`,children:`Commands and events`}),`\n`,_jsxs(_components.p,{children:[`Client commands use `,_jsx(_components.code,{children:`op`}),`: `,_jsx(_components.code,{children:`subscribe`}),`, `,_jsx(_components.code,{children:`unsubscribe`}),`, `,_jsx(_components.code,{children:`replay`}),`, `,_jsx(_components.code,{children:`replay.pause`}),`, `,_jsx(_components.code,{children:`replay.resume`}),`, `,_jsx(_components.code,{children:`replay.seek`}),`, `,_jsx(_components.code,{children:`replay.stop`}),`, and `,_jsx(_components.code,{children:`ping`}),`. Server messages use `,_jsx(_components.code,{children:`type`}),`, and the names differ: the command `,_jsx(_components.code,{children:`replay.pause`}),` is answered by the event `,_jsx(_components.code,{children:`replay_paused`}),`. The older `,_jsx(_components.code,{children:`stream`}),` and `,_jsx(_components.code,{children:`stream.stop`}),` commands return an `,_jsx(_components.code,{children:`error`}),`; use `,_jsx(_components.a,{href:`/data-catalog`,children:`Bulk Exports`}),` for large files. The `,_jsx(_components.a,{href:`/websocket/schema`,children:`Protocol reference`}),` has every command and event shape.`]}),`\n`,_jsx(Heading,{level:`2`,id:`channels-and-limits`,children:`Channels and limits`}),`\n`,_jsxs(_components.p,{children:[`Which channels stream live, which replay, and how, is on `,_jsx(_components.a,{href:`/websocket/channels`,children:`Channels`}),`, venue family by venue family. Subscription, connection, and replay-speed limits per plan are on `,_jsx(_components.a,{href:`/websocket/limits`,children:`Limits`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`measure-your-own-latency`,children:`Measure your own latency`}),`\n`,_jsxs(_components.p,{children:[`Current WebSocket health is an HTTP service check, not a measurement of your connection. These are separate numbers: HTTP service health, server-side REST handler timing, stored-data freshness, ingest lag, WebSocket upgrade/connect time, application ping/pong round-trip time, and client processing lag. In the data-quality response, `,_jsx(_components.code,{children:`websocket.current_ms`}),` is the latest stored order-book freshness value, not client WebSocket round-trip time.`]}),`\n`,_jsxs(_components.p,{children:[`To measure your own path, send `,_jsx(_components.code,{children:`{\"op\":\"ping\"}`}),` and time the `,_jsx(_components.code,{children:`{\"type\":\"pong\"}`}),` reply. The result describes your client and network.`]}),`\n`,_jsx(Heading,{level:`2`,id:`next-step`,children:`Next step`}),`\n`,_jsx(_MdxComponentBoundary,{name:`TaskCard`,children:_jsx(TaskCard,{title:`Bring the stream into your server application`,description:`Authenticate your client, track acknowledgements and rebuild subscriptions and state after a reconnect. Keep the API key out of browser code.`,href:`/websocket/connection`,action:`Connect your client`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{TaskCard,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":"github-dark"},"config":{},"pageMetadata":{"title":"WebSocket API","sidebarTitle":"Overview","description":"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.","href":"/websocket"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[144,1363,")=>null;function _cr"]]},"mdxExtracts":{"tableOfContents":[{"title":"Before you connect","slug":"before-you-connect","depth":2,"children":[]},{"title":"Subscribe to one channel","slug":"subscribe-to-one-channel","depth":2,"children":[]},{"title":"Stream live or replay history","slug":"stream-live-or-replay-history","depth":2,"children":[{"title":"Live streaming","slug":"live-streaming","depth":3,"children":[]},{"title":"Historical replay","slug":"historical-replay","depth":3,"children":[]}]},{"title":"Commands and events","slug":"commands-and-events","depth":2,"children":[]},{"title":"Channels and limits","slug":"channels-and-limits","depth":2,"children":[]},{"title":"Measure your own latency","slug":"measure-your-own-latency","depth":2,"children":[]},{"title":"Next step","slug":"next-step","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/0xarchive-e895b8e7/7de7178c454c8311/analytics-delayed.js","/_mintlify/custom/0xarchive-e895b8e7/64d76990ea4d1101/ahrefs-analytics.js","/_mintlify/custom/0xarchive-e895b8e7/9c04a5e34ef7363a/assistant-ui.js","/_mintlify/custom/0xarchive-e895b8e7/ae934b733ebeac03/single-public-docs.js","/_mintlify/custom/0xarchive-e895b8e7/ab832e8be54292e5/webhooks-anchors.js"],"subdomain":"0xarchive-e895b8e7","siteName":"0xArchive","title":"WebSocket API - 0xArchive","contextualStarterQuestions":[{"_id":"6ad43b698587738a5bbbd672","deploymentId":"69fcef8bc84766ada2de665b","questionText":"What WebSocket URL should I use?","status":"active","generatedBy":"contextual","path":"websocket","createdAt":"2026-10-18T03:22:17.558Z","updatedAt":"2026-10-18T03:22:17.558Z","__v":0},{"_id":"6ad43b698587738a5bbbd673","deploymentId":"69fcef8bc84766ada2de665b","questionText":"How do I set up authentication?","status":"active","generatedBy":"contextual","path":"websocket","createdAt":"2026-10-18T03:22:17.558Z","updatedAt":"2026-10-18T03:22:17.558Z","__v":0},{"_id":"6ad43b698587738a5bbbd674","deploymentId":"69fcef8bc84766ada2de665b","questionText":"Which channels can I subscribe to?","status":"active","generatedBy":"contextual","path":"websocket","createdAt":"2026-10-18T03:22:17.558Z","updatedAt":"2026-10-18T03:22:17.558Z","__v":0}],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-18T03:22:05.418Z","gitLastModified":"2026-10-18T03:21:29.000Z","originalFileLocation":"websocket.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\">\u003cmeta data-mint-head name=\"application-name\" content=\"0xArchive\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"WebSocket API - 0xArchive\">\u003cmeta data-mint-head property=\"og:description\" content=\"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"0xArchive Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.0xarchive.io/websocket\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://0xarchive-e895b8e7.mintlify.site/_mintlify/api/og/v2?division=Documentation\u0026amp;title=WebSocket+API\u0026amp;description=Stream+live+Hyperliquid+and+Lighter+market+data%2C+or+replay+a+stored+window+in+order%2C+over+authenticated+WebSocket+connections.\u0026amp;theme=77376188720d2fe77317e930\u0026amp;signature=a6d2b1567d89de33753ed8744f91d08fb5bb76993eb3d05c2b940e4dd6b85e8e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"WebSocket API - 0xArchive\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://0xarchive-e895b8e7.mintlify.site/_mintlify/api/og/v2?division=Documentation\u0026amp;title=WebSocket+API\u0026amp;description=Stream+live+Hyperliquid+and+Lighter+market+data%2C+or+replay+a+stored+window+in+order%2C+over+authenticated+WebSocket+connections.\u0026amp;theme=77376188720d2fe77317e930\u0026amp;signature=a6d2b1567d89de33753ed8744f91d08fb5bb76993eb3d05c2b940e4dd6b85e8e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/0xarchive-e895b8e7/epsl9cg6_-QmFjTh/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"0xArchive\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#15803D\">\u003cmeta data-mint-head name=\"google-site-verification\" content=\"Hpedp6bedqc3av1195euaGMwyFEVHcJhcyUY9YiMvTY\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.0xarchive.io/websocket\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/websocket.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://0xarchive.io/#organization\",\"name\":\"0xArchive\",\"legalName\":\"Archive Labs Inc.\",\"url\":\"https://0xarchive.io/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://0xarchive.io/logo-square-1024.png\"},\"sameAs\":[\"https://x.com/0xarchiveIo\",\"https://github.com/0xArchiveIO\",\"https://t.me/archivedotio\",\"https://www.linkedin.com/company/0xarchive/\"]},{\"@type\":\"WebSite\",\"@id\":\"https://docs.0xarchive.io#website\",\"name\":\"0xArchive\",\"url\":\"https://docs.0xarchive.io\",\"publisher\":{\"@id\":\"https://0xarchive.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.0xarchive.io/websocket#webpage\",\"url\":\"https://docs.0xarchive.io/websocket\",\"name\":\"WebSocket API\",\"description\":\"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\",\"dateModified\":\"2026-10-18T03:21:29.000Z\",\"isPartOf\":{\"@id\":\"https://docs.0xarchive.io#website\"}},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.0xarchive.io/websocket#article\",\"headline\":\"WebSocket API\",\"name\":\"WebSocket API\",\"description\":\"Stream live Hyperliquid and Lighter market data, or replay a stored window in order, over authenticated WebSocket connections.\",\"url\":\"https://docs.0xarchive.io/websocket\",\"mainEntityOfPage\":{\"@id\":\"https://docs.0xarchive.io/websocket#webpage\"},\"dateModified\":\"2026-10-18T03:21:29.000Z\",\"publisher\":{\"@id\":\"https://0xarchive.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.0xarchive.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"0xArchive\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"0xArchive\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/websocket.md","siteName":"0xArchive","nav":{"global":null,"tabs":[{"tab":"Get Started","pages":[{"title":"Get Started","href":""}]},{"tab":"REST API","pages":[{"title":"REST API","href":"/rest-api"}]},{"tab":"WebSocket","pages":[{"title":"WebSocket API","sidebarTitle":"Overview","href":"/websocket"},{"group":"Connect","icon":"plug","pages":[{"title":"WebSocket connection and authentication","sidebarTitle":"Connection","description":"Authenticate and connect to the 0xArchive WebSocket, then keep the connection alive, reconnect safely, and handle streaming failures.","href":"/websocket/connection"},{"title":"WebSocket keep alive","sidebarTitle":"Keep-alive","href":"/websocket/keep-alive"},{"title":"WebSocket limits","sidebarTitle":"Limits","href":"/websocket/limits"}]},{"group":"Channels and modes","icon":"radio","pages":[{"title":"WebSocket channels","sidebarTitle":"Channels","href":"/websocket/channels"},{"title":"Hyperliquid WebSocket API for Real-Time Market Data","sidebarTitle":"Real-time streams","href":"/websocket/real-time"},{"title":"WebSocket replay","sidebarTitle":"Replay","href":"/websocket/replay"},{"title":"WebSocket L4 order book","sidebarTitle":"L4 order book","href":"/websocket/l4-orderbook"},{"title":"Lighter WebSocket channels","sidebarTitle":"Lighter channels","href":"/websocket/lighter"},{"title":"Mempool channel","sidebarTitle":"Mempool","href":"/websocket/mempool"}]},{"group":"Message reference","icon":"braces","pages":[{"title":"WebSocket protocol reference","sidebarTitle":"Protocol reference","href":"/websocket/schema"},{"title":"WebSocket command schemas","sidebarTitle":"JSON schemas","href":"/websocket/json-schemas"}]}]},{"tab":"Webhook Alerts","pages":[{"title":"Webhook Alerts","href":"/webhooks"}]},{"tab":"Bulk Exports","pages":[{"title":"Bulk Exports","href":"/exports"}]},{"tab":"SDKs \u0026 Tools","pages":[{"title":"SDKs \u0026 Tools","href":"/tooling"}]},{"tab":"Terminal","pages":[{"title":"Terminal","href":"/terminal"}]}]},"basePath":"","title":"WebSocket API - 0xArchive","deploymentId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","buildId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","dynamics":[],"chunks":[]}