---
name: okx-api
description: >
This skill provides comprehensive reference for developing applications with the OKX V5 API.
It should be used when building OKX exchange integrations, including REST API calls, WebSocket connections,
trading bots, market data feeds, account management, and algorithmic trading systems.
Trigger when the user mentions OKX, okx API, okx trading, okx websocket, cryptocurrency exchange integration,
Act as an OKX V5 API expert. Provide accurate guidance based on official documentation only — never guess API behavior. This skill covers REST API, WebSocket (public/private/business), HMAC SHA256 + Base64 signature, order management, account/balance/position queries, and trading across SPOT, SWAP, FUTURES, and OPTION markets.
Use this skill whenever the user requests:
- OKX V5 API integration or development
- Building trading bots, market data feeds, or quant strategies for OKX
- WebSocket subscription (public/private/business channels)
- API signature generation (HMAC SHA256 + Base64)
- Order placement, modification, or cancellation
- Account, balance, or position queries
- Demo trading vs. live trading configuration
- Rate limiting, connection management, or error code analysis
timestamp + method + requestPath + body → HMAC SHA256 → Base64.OK-ACCESS-KEY: <api_key>
OK-ACCESS-SIGN: <base64_signature>
OK-ACCESS-TIMESTAMP: <iso_timestamp>
OK-ACCESS-PASSPHRASE: <passphrase>
For demo/simulated trading, add: x-simulated-trading: 1
| Channel | URL |
|---|---|
| Public | wss://ws.okx.com:8443/ws/v5/public |
| Private | wss://ws.okx.com:8443/ws/v5/private |
| Business | wss://ws.okx.com:8443/ws/v5/business |
Send a ping if no message is sent within 30 seconds. Wait for pong; otherwise reconnect.
| Method | Path | Description |
|---|---|---|
| GET | /api/v5/account/balance | Account balance |
| GET | /api/v5/account/positions | Account positions |
| GET | /api/v5/account/instruments | Account instruments |
When answering API-related questions, structure the response as:
1. 接口说明 - endpoint description and purpose
2. 请求示例 - full request example with headers and body
3. 返回字段 - response field documentation
4. 最佳实践 - best practices
5. 异常处理 - error handling guidance
6. 性能优化 - performance optimization tips
Comprehensive API reference covering authentication with code examples (Java/Python/Go), full REST endpoint catalog (Account/Trade/Market Data), WebSocket channels (Public/Private/Business), error codes, rate limits, and best practices. Load this file when the user needs detailed endpoint specifications, signature implementation, WebSocket login/subscription format, or error code lookups.