okx-exchange-websocket-skill
Original:🇺🇸 English
Translated
1 scripts
Subscribe to OKX public exchange WebSocket channels through UXC raw WebSocket mode for ticker, trade, book, and candle events with explicit subscribe frames.
13installs
Sourceholon-run/uxc
Added on
NPX Install
npx skill4agent add holon-run/uxc okx-exchange-websocket-skillTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →OKX Exchange WebSocket Skill
Use this skill to run OKX public exchange WebSocket channels through raw WebSocket mode.
uxc subscribeReuse the skill for generic runtime behavior, sink handling, and event-envelope parsing.
uxcPrerequisites
- is installed and available in
uxc.PATH - Network access to the OKX public WebSocket endpoint.
- A writable sink path for NDJSON output.
Scope
This skill covers OKX public exchange channels such as:
- tickers
- trades
- books and books5
- candle channels
This skill does not cover:
- OKX OnchainOS MCP
- private WebSocket login flows
- trading, account, or order-management channels
- REST API workflows
Endpoint Model
Use the OKX public WebSocket endpoint:
wss://ws.okx.com:8443/ws/v5/public
OKX public channels require a subscribe frame after connect, for example:
json
{"op":"subscribe","args":[{"channel":"tickers","instId":"BTC-USDT"}]}Core Workflow
- Start a raw WebSocket subscription:
uxc subscribe start wss://ws.okx.com:8443/ws/v5/public --transport websocket --init-frame '{"op":"subscribe","args":[{"channel":"tickers","instId":"BTC-USDT"}]}' --sink file:$HOME/.uxc/subscriptions/okx-btcusdt-ticker.ndjson
- Inspect sink output:
tail -n 5 $HOME/.uxc/subscriptions/okx-btcusdt-ticker.ndjson
- Query runtime status:
uxc subscribe listuxc subscribe status <job_id>
- Stop the job when finished:
uxc subscribe stop <job_id>
Common Subscribe Frames
- tickers:
{"op":"subscribe","args":[{"channel":"tickers","instId":"BTC-USDT"}]}
- trades:
{"op":"subscribe","args":[{"channel":"trades","instId":"BTC-USDT"}]}
- books5:
{"op":"subscribe","args":[{"channel":"books5","instId":"BTC-USDT"}]}
- candles:
{"op":"subscribe","args":[{"channel":"candle1m","instId":"BTC-USDT"}]}
Runtime Validation
The following live raw WebSocket flow has been validated successfully through :
uxc- endpoint:
wss://ws.okx.com:8443/ws/v5/public - transport:
--transport websocket - init frame:
{"op":"subscribe","args":[{"channel":"tickers","instId":"BTC-USDT"}]}
Observed sink behavior:
- initial
open - JSON event for subscription acknowledgement
data - repeated events carrying ticker payloads under:
dataarg.channelarg.instIddata[0].lastdata[0].bidPxdata[0].askPxdata[0].ts
Guardrails
- Keep automation on the JSON output envelope; do not use .
--text - Parse stable event fields first: ,
event_kind,data.meta - Always pass for this skill.
--transport websocket - Public OKX channels do not require login. Do not mix this skill with private WebSocket auth flows.
- is required because OKX public channels are multiplexed behind one endpoint.
--init-frame - values use OKX instrument naming such as
instId.BTC-USDT - is the intended execution path for this skill;
uxc subscribe start ... --transport websocketis not the main interface because channel selection lives in the subscribe frame.uxc link
References
- Usage patterns:
references/usage-patterns.md
- OKX WebSocket API: