Skip to main content

OKX API — Node.js SDK

The okx-api package is a fully-featured, actively maintained Node.js and TypeScript SDK for interacting with the OKX exchange. It covers every endpoint in OKX’s REST API and provides a robust, auto-reconnecting WebSocket client for real-time market data and private account streams.

Quickstart

Install the package and make your first API call in minutes

Authentication

Learn how to create and configure your OKX API credentials

REST Client

Explore the full REST API — account, trading, funding and more

WebSocket Client

Subscribe to real-time streams with automatic reconnection

Why use this SDK?

Complete REST coverage

Every OKX v5 REST endpoint is mapped to a typed TypeScript method — account, trading, funding, market data, earn, copy trading, grid trading, signal bots, block trading, and more.

Robust WebSockets

Automatic heartbeat detection, reconnection, re-authentication, and channel resubscription. Connections recover from failures without any extra code.

WebSocket API Client

Place, amend, and cancel orders via persistent WebSocket connections using a familiar promise-based interface — lower latency than REST.

Full TypeScript support

Type declarations for every request parameter and response object. Get IDE autocomplete and compile-time safety across the entire SDK.

Multi-region support

Works with OKX Global (www.okx.com), OKX EEA (my.okx.com), and OKX US (app.okx.com) — just set the market option.

Browser compatible

Comes with a webpack bundle for use in frontend applications. Works in any modern browser.

Key exports

import {
  RestClient,           // Full REST API client
  WebsocketClient,      // Real-time WebSocket streams
  WebsocketAPIClient,   // Promise-based WebSocket API (orders)
} from 'okx-api';

Installation

npm install okx-api

Community & support

This SDK is part of the Siebly.io family of exchange SDKs. Related packages are available for Bybit, Binance, Gate, Bitget, KuCoin, Coinbase, and more.

Build docs developers (and LLMs) love