Skip to main content
OKX operates three distinct regional domains, each with its own API endpoints. The SDK defaults to OKX Global and requires only a single option change to target a different region.

Supported regions

Global

Domain: www.okx.comThe default region. No extra configuration needed.market: 'GLOBAL' (or omit entirely)

EEA

Domain: my.okx.comFor users registered under the European Economic Area entity.market: 'EEA'

US

Domain: app.okx.comFor users registered under the OKX US entity.market: 'US'
Available functionality differs between regions. Refer to the corresponding API documentation for your region: Global, EEA, US.

Configuring the RestClient

Pass the market option to the RestClient constructor. All subsequent REST calls will be routed to the correct regional domain.
import { RestClient } from 'okx-api';

// Global is the default — no market option required.
const client = new RestClient({
  apiKey: 'apiKeyHere',
  apiSecret: 'apiSecretHere',
  apiPass: 'apiPassHere',
});

Configuring the WebsocketClient

The WebsocketClient (and WebsocketAPIClient) accept the same market option.
import { WebsocketClient } from 'okx-api';

const wsClient = new WebsocketClient({
  market: 'EEA',
  accounts: [
    {
      apiKey: 'apiKeyHere',
      apiSecret: 'apiSecretHere',
      apiPass: 'apiPassHere',
    },
  ],
});

wsClient.on('update', (data) => {
  console.log(new Date(), 'ws update (raw data received)', JSON.stringify(data));
});
wsClient.on('open', (data) => {
  console.log('ws connection opened open:', data.wsKey);
});
wsClient.on('reconnected', (data) => {
  console.log('ws has reconnected ', data?.wsKey);
});
wsClient.on('exception', (data) => {
  console.error('ws exception: ', data);
});

wsClient.subscribe([
  { channel: 'instruments', instType: 'SPOT' },
  { channel: 'tickers', instId: 'ETH-BTC' },
]);

The market option

The market property is typed as APIMarket and is shared between RestClientOptions and WSClientConfigurableOptions:
export type APIMarket =
  | 'prod'    // alias for GLOBAL, kept for backwards compatibility
  | 'GLOBAL'  // www.okx.com (default)
  | 'EEA'     // my.okx.com
  | 'US';     // app.okx.com
Omitting market is equivalent to setting market: 'GLOBAL'.

Demo trading mode

All regions support OKX’s paper/demo trading environment. Set demoTrading: true alongside your region to use demo trading credentials without touching live funds.
import { RestClient, WebsocketClient } from 'okx-api';

const demoRestClient = new RestClient({
  apiKey: process.env.API_KEY_COM,
  apiSecret: process.env.API_SECRET_COM,
  apiPass: process.env.API_PASS_COM,
  demoTrading: true,
});

const demoWsClient = new WebsocketClient({
  demoTrading: true,
  accounts: [
    {
      apiKey: process.env.API_KEY_COM,
      apiSecret: process.env.API_SECRET_COM,
      apiPass: process.env.API_PASSPHRASE_COM,
    },
  ],
});
Demo trading API keys are separate from live keys. Generate them under OKX Demo Trading by selecting the demo environment.

Build docs developers (and LLMs) love