Skip to content

OKX API SDK ​

okx-api provides JavaScript and TypeScript clients for OKX Spot, margin and derivatives APIs. Read prices, subscribe to account updates and manage orders through typed REST and WebSocket methods.

JavaScript & TypeScript · v3.2.9 · MIT license

Installation ​

TypeScript definitions are included.

Install the npm package with your preferred tool:

sh
npm install okx-api
sh
pnpm add okx-api
sh
yarn add okx-api
sh
bun add okx-api
sh
deno add npm:okx-api
text
Package: okx-api
npm: https://www.npmjs.com/package/okx-api

For other npm-compatible tools, use the same package from npm. Runtime-specific setup is covered below.

Choose your setup ​

Follow the guide for your runtime or framework. Each includes a complete project with commands to install dependencies and run it.

SetupGuides
Node.jsJavaScript or TypeScript
Alternative runtimesBun or Deno
Browser appsReact with Vite or Vite with plain JavaScript
Next.jsNode.js server Route Handler
Cloudflare WorkersPublic prices and authenticated orders
Mobile appsReact Native / Expo for iOS and Android

Browser and Expo guides include SDK-specific bundler configuration and polyfills where needed. See Runtime setup for project recipes and required configuration.

First request ​

Follow the Node.js quickstart to read a public Bitcoin price without credentials. Examples use live services by default. To use simulated funds, configure demo trading.

Choose a client ​

  • RestClient: public market data, authenticated account reads and order commands over REST.
  • WebsocketClient: public and private subscriptions, connection lifecycle events and low-level WebSocket API requests.
  • WebsocketAPIClient: promise-based order commands over WebSockets.

Next steps ​

Built by Siebly. Open source SDKs for exchange APIs.