OKX API for Openclaw

A robust integration for OKX v5 REST and WebSocket APIs enabling automated crypto trading, account management, and real-time market data analysis.

xhfkindergarten
v1.0.0
Mar 7, 2026
0
1.7k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install okx-api

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install okx-api using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is OKX API?

The OKX API skill provides a comprehensive bridge between AI agents and the OKX exchange ecosystem. By leveraging this Openclaw Skills component, developers can programmatically access spot trading, derivatives, and detailed account analytics. It simplifies the complexities of cryptocurrency exchange interaction by handling HMAC SHA256 authentication and signature generation, allowing for secure and efficient operations across both live and sandbox environments.

Built for high-performance trading workflows, this skill supports the full breadth of the OKX v5 interface. Whether you are building an automated trading bot or a portfolio tracking tool, this skill ensures your agent has the necessary tools to interact with one of the most liquid exchanges in the industry.

OKX API Use Cases

  • Executing automated trades across spot, perpetual swaps, futures, and options markets.
  • Monitoring real-time price movements and market depth using WebSocket subscriptions.
  • Managing account risk by programmatically checking positions and canceling open orders.
  • Fetching historical candlestick data for technical analysis and backtesting strategies.
  • Creating automated portfolio reports by querying account balances across multiple assets.

How OKX API Works

  1. The agent authenticates using API credentials stored within the Openclaw Skills configuration environment.
  2. For private endpoints, the skill automatically generates a secure HMAC SHA256 signature based on the request timestamp, method, and payload.
  3. The skill dispatches requests to the OKX v5 REST API or establishes persistent WebSocket connections for streaming data.
  4. Response envelopes are parsed to validate success codes and handle potential rate limiting errors.
  5. The structured data is returned to the agent to drive further logic or provide status updates to the user.

OKX API Setup

To enable this skill, store your credentials in your local environment configuration. Openclaw Skills will automatically inject these into the agent workspace.

Add the following to your ~/.openclaw/openclaw.json:

{
  "env": {
    "OKX_API_KEY": "your-api-key",
    "OKX_SECRET_KEY": "your-secret-key",
    "OKX_PASSPHRASE": "your-passphrase",
    "OKX_DEMO": "1"
  }
}

Alternatively, export the variables in your shell:

export OKX_API_KEY="your-api-key"
export OKX_SECRET_KEY="your-secret-key"
export OKX_PASSPHRASE="your-passphrase"

OKX API Data Schema & Taxonomy

The skill follows the OKX v5 standard response structure, ensuring data consistency across all endpoints.

Property Type Description
code String Status code where 0 indicates success.
msg String Error message detail if the request fails.
data Array A collection of objects containing the requested resource.

All trading pairs use the instId format (e.g., BTC-USDT for spot, BTC-USDT-SWAP for perpetuals). Account data is organized by UID and includes detailed sub-account and equity breakdowns.

OKX API Advanced Features

  • Sandbox Support: Utilize the OKX demo trading environment by setting the simulated trading header.
  • WebSocket Integration: Access low-latency public and private channels for real-time updates.
  • Batch Operations: Support for batch-order and batch-cancel endpoints to maximize throughput within rate limits.
  • Automated Auth Helper: Includes a reusable Python script within Openclaw Skills for standardized request signing and error handling.
  • Multi-Instrument Compatibility: Works seamlessly across spot, margin, futures, and options instrument types.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*