Binance Spot WebSocket Skill
Use this skill to run Binance Spot public market streams through uxc subscribe raw WebSocket mode.
Reuse the uxc skill for generic runtime behavior, sink handling, and event-envelope parsing.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to Binance Spot public WebSocket streams.
- A writable sink path for NDJSON output.
Scope
This skill covers Binance Spot public market streams such as:
- - trade events
- aggregate trade events
- book ticker updates
- ticker updates
- depth updates
This skill does not cover:
- - Binance Spot REST/OpenAPI workflows
- private user data streams
- signed WebSocket API methods
- margin, wallet, futures, or other non-Spot product families
Endpoint Model
Binance Spot public market streams use raw WebSocket endpoints.
- - preferred base: INLINECODE4
- raw stream form: INLINECODE5
- combined stream form: INLINECODE6
Important:
- - stream names are lowercase
- connections are valid for up to 24 hours
- raw stream payloads arrive directly as JSON objects
- combined stream payloads arrive as INLINECODE7
Core Workflow
- 1. Start a subscription directly with
uxc subscribe start:
-
uxc subscribe start wss://stream.binance.com:443/ws/btcusdt@trade --transport websocket --sink file:$HOME/.uxc/subscriptions/binance-btcusdt-trade.ndjson
- 2. Inspect the sink output:
-
tail -n 5 $HOME/.uxc/subscriptions/binance-btcusdt-trade.ndjson
- 3. Query runtime status:
-
uxc subscribe list
-
uxc subscribe status <job_id>
- 4. Stop the job when finished:
- INLINECODE13
Common Stream Targets
-
btcusdt@trade
- - aggregate trade stream:
-
btcusdt@aggTrade
-
btcusdt@bookTicker
-
btcusdt@miniTicker
-
btcusdt@ticker
- INLINECODE19
Runtime Validation
The following live raw WebSocket flow was validated successfully through uxc:
- - endpoint: INLINECODE21
- transport: INLINECODE22
- sink output:
-
open
- repeated
data events with Binance
trade payloads
-
closed after stop
Observed event fields included:
- - INLINECODE27
- INLINECODE28
- INLINECODE29
- INLINECODE30
- INLINECODE31
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable event fields first:
event_kind, data, meta. - Use
wss://stream.binance.com:443 as the default public stream host; it validated more reliably than :9443 in recent runtime checks. - Stream names must be lowercase.
- This skill is read-only. Do not describe it as account, order, or signed WebSocket support.
- Combined streams are useful when one job should emit multiple markets into one sink, but downstream parsing must handle
stream wrappers. - INLINECODE39 is the intended execution path for this skill;
uxc link is not the main interface because stream identity is encoded directly in the endpoint path.
References
-
references/usage-patterns.md
- - Binance Spot WebSocket Streams:
- https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams
Binance 现货 WebSocket 技能
使用此技能可通过 uxc subscribe 原始 WebSocket 模式运行 Binance 现货公共市场数据流。
复用 uxc 技能以实现通用运行时行为、接收器处理和事件信封解析。
前置条件
- - 已安装 uxc 并可在 PATH 中访问。
- 具备访问 Binance 现货公共 WebSocket 数据流的网络权限。
- 为 NDJSON 输出提供可写的接收器路径。
适用范围
本技能涵盖 Binance 现货公共市场数据流,包括:
- - 交易事件
- 聚合交易事件
- 订单簿滚动更新
- 滚动行情更新
- 深度更新
本技能不涵盖:
- - Binance 现货 REST/OpenAPI 工作流
- 私有用户数据流
- 签名 WebSocket API 方法
- 杠杆、钱包、合约或其他非现货产品系列
端点模型
Binance 现货公共市场数据流使用原始 WebSocket 端点。
- - 推荐基础地址:wss://stream.binance.com:443
- 原始流格式:wss://stream.binance.com:443/ws/
- 组合流格式:wss://stream.binance.com:443/stream?streams=/
重要说明:
- - 流名称必须小写
- 连接有效期为 24 小时
- 原始流负载直接以 JSON 对象形式到达
- 组合流负载以 {stream:...,data:{...}} 格式到达
核心工作流
- 1. 直接使用 uxc subscribe start 启动订阅:
- uxc subscribe start wss://stream.binance.com:443/ws/btcusdt@trade --transport websocket --sink file:$HOME/.uxc/subscriptions/binance-btcusdt-trade.ndjson
- 2. 检查接收器输出:
- tail -n 5 $HOME/.uxc/subscriptions/binance-btcusdt-trade.ndjson
- 3. 查询运行时状态:
- uxc subscribe list
- uxc subscribe status
- 4. 完成后停止任务:
- uxc subscribe stop
常用流目标
- btcusdt@trade
- btcusdt@aggTrade
- btcusdt@bookTicker
- btcusdt@miniTicker
- btcusdt@ticker
- btcusdt@depth
运行时验证
以下实时原始 WebSocket 流已通过 uxc 成功验证:
- - 端点:wss://stream.binance.com:443/ws/btcusdt@trade
- 传输方式:--transport websocket
- 接收器输出:
- open
- 重复的 data 事件,包含 Binance trade 负载
- 停止后的 closed
观察到的事件字段包括:
使用规范
- - 保持自动化处理 JSON 输出信封;不要使用 --text。
- 首先解析稳定的事件字段:event_kind、data、meta。
- 使用 wss://stream.binance.com:443 作为默认公共流主机;在最近的运行时检查中,该地址比 :9443 更可靠。
- 流名称必须小写。
- 本技能为只读。不要将其描述为支持账户、订单或签名 WebSocket。
- 当单个任务需要向一个接收器发送多个市场数据时,组合流很有用,但下游解析必须处理 stream 包装器。
- uxc subscribe start ... --transport websocket 是本技能的预期执行路径;uxc link 不是主要接口,因为流标识直接编码在端点路径中。
参考
- references/usage-patterns.md
- - Binance 现货 WebSocket 流:
- https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams