/bingx-ai-skills:bingx-spot-ws-accountfrom bingx-ai-skills
Subscribes to BingX spot WebSocket account data streams for real-time order updates and balance changes. Manages Listen Key lifecycle (generate, extend, delete).
Ships in bingx-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Real-time account data streams for BingX spot trading via WebSocket. Requires Listen Key authentication.
WebSocket Endpoint: wss://open-api-ws.bingx.com/market?listenKey=<key>
Unlike swap account streams, spot account streams require explicit channel subscription after connecting.
| Event Type | dataType | Description | Push Frequency |
|---|---|---|---|
| Order Update | spot.executionReport | Order creation, fills, cancellation | On change |
| Account Update | ACCOUNT_UPDATE | Account balance changes | On change |
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/openApi/user/auth/userDataStream | POST | Generate listen key (valid 1 hour) | Yes |
/openApi/user/auth/userDataStream | PUT | Extend listen key (to 60 min) | Yes |
/openApi/user/auth/userDataStream | DELETE | Delete listen key | Yes |
Listen Key is required to authenticate WebSocket account data streams. See references/authentication.md for HMAC SHA256 signing details.
POST /openApi/user/auth/userDataStream
Headers: X-BX-APIKEY: <your-api-key>, X-SOURCE-KEY: BX-AI-SKILL
Response:
{"listenKey": "a8ea75681542e66f1a50a1616dd06ed77dab61baa0c296bca03a9b13ee5f2dd7"}
PUT /openApi/user/auth/userDataStream
Parameters: listenKey (string, required)
Extends validity to 60 minutes. Recommended: call every 30 minutes.
DELETE /openApi/user/auth/userDataStream
Parameters: listenKey (string, required)
WebSocket Connection: see references/websocket.md for GZIP decompression and Ping/Pong heartbeat.
TypeScript helper:
CONSTRAINT: You MUST copy the
connectSpotWsAccountfunction below verbatim when generating code. Do NOT rewrite the WebSocket or decompression logic.
import * as pako from "pako";
import * as crypto from "crypto";
function decompress(data: ArrayBuffer): string {
return new TextDecoder("utf-8").decode(pako.ungzip(new Uint8Array(data)));
}
async function generateListenKey(apiKey: string, secretKey: string): Promise<string> {
const timestamp = Date.now();
const paramStr = `timestamp=${timestamp}`;
const signature = crypto.createHmac("sha256", secretKey).update(paramStr).digest("hex");
const url = `https://open-api.bingx.com/openApi/user/auth/userDataStream?${paramStr}&signature=${signature}`;
const res = await fetch(url, {
redirect: "error",
method: "POST",
headers: { "X-BX-APIKEY": apiKey, "X-SOURCE-KEY": "BX-AI-SKILL" },
});
const text = await res.text();
if (!res.ok) throw new Error(`BingX error ${res.status}: ${text}`);
const json = JSON.parse(text);
if (json.listenKey) return json.listenKey;
if (json.data?.listenKey) return json.data.listenKey;
if (json.code !== 0) throw new Error(`BingX error ${json.code}: ${json.msg}`);
return json.listenKey ?? json.data?.listenKey;
}
function connectSpotWsAccount(
listenKey: string,
channels: string[],
onEvent: (event: any) => void
): WebSocket {
const ws = new WebSocket(
`wss://open-api-ws.bingx.com/market?listenKey=${listenKey}`
);
ws.binaryType = "arraybuffer";
ws.onopen = () => {
for (const ch of channels) {
ws.send(JSON.stringify({
id: crypto.randomUUID(),
reqType: "sub",
dataType: ch,
}));
}
};
ws.onmessage = (event) => {
const text = decompress(event.data as ArrayBuffer);
if (text.includes("ping") || text === "Ping") {
ws.send("Pong");
return;
}
try {
onEvent(JSON.parse(text));
} catch {
onEvent(text);
}
};
ws.onerror = (err) => console.error("WS error:", err);
ws.onclose = (ev) => console.log("WS closed:", ev.code, ev.reason);
return ws;
}
connectSpotWsAccount, generateListenKey, and decompress verbatimSubscribe to order updates and account balance:
const listenKey = await generateListenKey(API_KEY, SECRET_KEY);
connectSpotWsAccount(listenKey, ["spot.executionReport", "ACCOUNT_UPDATE"], (event) => {
if (event.dataType === "spot.executionReport") {
// event.data: order update details
} else if (event.e === "ACCOUNT_UPDATE") {
// event.a.B: balance updates
}
});
For complete event field descriptions and full response schemas, see api-reference.md.
CRITICAL RULES (apply to ALL responses):
&, =, ?, #, or newline characters.spot-ws-account provides authenticated real-time account data. Requires Listen Key, no CONFIRM needed for read-only monitoring.
When the user's request is vague (e.g. "monitor my spot account"), clarify what they want:
Please select the account data stream type:
- Order updates (fills, cancellations, status) — spot.executionReport
- Account balance changes — ACCOUNT_UPDATE
- Both order and balance updates
- Listen Key management (generate/extend/delete)
Spot account events contain the relevant symbol in the push payload (e.g., data.s for order updates, a.B[].a for asset/balance updates). If the user asks about a specific symbol or asset, filter the events by the corresponding field. No symbol parameter is needed for subscription — subscribe to the event type and filter in the push data.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
29 skills in this plugin
/bingx-agentBingX Agent (affiliate/broker) management — query invited users, daily commission details, agent user information, API transaction commission, and partner information. Use when the user asks about BingX agent invited users, affiliate commissions, referral relationships, partner data, or broker commission reports./bingx-announcementQuery BingX official announcements by module type — latest announcements, promotions, product updates, maintenance notices, listing/delisting, funding rate, crypto scout. Use when the user asks about BingX announcements, notices, activities, or the announcement API./bingx-dynamic-sl-tpUse when the user asks to set, adjust, or optimize stop-loss and take-profit for BingX perpetual futures, including dynamic stop-loss, trailing take-profit, partial take-profit, ATR stop-loss, volatility stop-loss, break-even stop, and trailing stop. It calculates SL/TP based on ATR, volatility, and support/resistance through bingx-swap-market and bingx-swap-trade./bingx-maker-entryUse when the user wants to open a BingX perpetual futures position with limit orders, maker entry, split entry, iceberg-style entry, or fee-saving execution instead of market orders. It scans order book depth, places multi-level limit orders near best price, and adjusts orders as price moves through bingx-swap-market, bingx-swap-trade, and bingx-swap-account./bingx-rsi-bottom-hunterUse when the user asks for RSI bottom fishing, oversold buying, RSI strategy, bottom hunter, or buying when RSI is low. It monitors RSI, confirms signals with bingx-technical-analysis, and supports entry, stop-loss, and take-profit planning through bingx-swap-market, bingx-swap-trade, and bingx-swap-account./bingx-sentiment-dashboardUse when the user asks about market sentiment, Fear & Greed Index, funding rate heatmap, OI anomalies, AHR999, DCA zone, or overall market mood.npx claudepluginhub bingx-api/api-ai-skills --plugin bingx-ai-skillsOther plugins' skills for the same job