← All articles

OKX API 60018 “doesn’t exist” in Node.js: keep delisted pairs out of your WebSocket subscriptions

OKX WebSocket error 60018 means “Wrong URL or {0} doesn’t exist. Please use the correct URL, channel and parameters referring to API document.” In a market-data subscribe, {0} is usually the channel and instId. It is not a signing or permissions problem.

A typical case is a pair that was delisted. After OKX delisted RVN-USDT-SWAP on 19 November 2026 at 08:00 UTC, a subscribe to { channel: 'tickers', instId: 'RVN-USDT-SWAP' } failed with 60018. If your bot keeps a fixed symbol list, or the SDK resubscribes after a reconnect, the same error comes back until you drop that instId.

This post shows how to subscribe only to live instruments and unsubscribe when one leaves that state, using okx-api (3.2.10 at the time of writing). Public REST and public WebSockets do not need API keys.

What the error looks like in okx-api

OKX sends a WebSocket message with event: "error". okx-api emits that payload on the exception event and adds wsKey. The code is a string:

{
  "event": "error",
  "code": "60018",
  "msg": "Subscribe failed, wrong URL or channel:tickers,instId:RVN-USDT-SWAP doesn't exist. Please use the correct URL, channel and parameters referring to API document.",
  "connId": "40cac853",
  "id": "8",
  "wsKey": "prodPublic"
}

You can reproduce the shape (with a current delisted or typo instId) like this:

import { WebsocketClient } from 'okx-api';

const ws = new WebsocketClient();

ws.on('exception', (err) => {
  // OKX's event field is 'error'. The SDK surfaces it on 'exception'.
  console.error(err.code, err.msg);
});

ws.subscribe({
  channel: 'tickers',
  instId: 'RVN-USDT-SWAP',
});

Why it happens

60018 is a general “this channel or parameter does not exist” error. A typo in instId or channel, or the wrong WebSocket URL, will trigger it. In production, the usual cause is an instrument that is no longer listed.

GET /api/v5/public/instruments returns instruments with open contracts. Each row has a state. Official values include live, suspend, rebase, post_only, preopen, test and settling (event contracts). OKX recommends checking that state is live before you place orders. The same check belongs in front of a WebSocket subscribe. There is no state query parameter on this endpoint, so you filter the array yourself.

The public instruments channel pushes incremental updates when an instrument’s state or trading parameters change. Official docs say that when a product is delisted (for example when a futures contract is settled or an option is exercised), the instrument status is changed to expired and the instrument is no longer available. Those pushes are not a full replacement list. Merge them into a local cache by instId.

okx-api caches every topic you pass to subscribe() and resubscribes after a reconnect. unsubscribe() removes the topic from that cache. A failed subscribe with 60018 does not, so the next reconnect tries again and fails again until you unsubscribe.

Subscribe only to live instruments

Load the instrument list once, keep the live rows, and subscribe only to those instIds. Subscribe to the instruments channel as well, and drop a pair when its state is no longer live. If 60018 still arrives, parse the instId from msg when it is present and unsubscribe so reconnect will not retry it.

import { RestClient, WebsocketClient } from 'okx-api';
import type { Instrument, WsDataEvent, WsEvent } from 'okx-api';

const instType = 'SWAP' as const;
const rest = new RestClient();
const ws = new WebsocketClient();

const subscribed = new Set<string>();

function tickerTopic(instId: string) {
  return { channel: 'tickers' as const, instId };
}

function dropInstrument(instId: string, reason: string) {
  if (!subscribed.has(instId)) return;
  subscribed.delete(instId);
  ws.unsubscribe(tickerTopic(instId));
  console.warn('unsubscribed', instId, reason);
}

ws.on('exception', (err: WsEvent) => {
  if (err.code !== '60018') {
    console.error('ws exception', err);
    return;
  }

  console.error('OKX 60018', err.msg);
  const instId = err.msg?.match(/instId:([A-Za-z0-9-]+)/)?.[1];
  if (instId) {
    dropInstrument(instId, '60018');
  }
});

ws.on('update', (event: WsDataEvent<Instrument[]>) => {
  if (event.arg?.channel !== 'instruments') return;

  for (const inst of event.data) {
    if (inst.state !== 'live') {
      dropInstrument(inst.instId, `state=${inst.state}`);
    }
  }
});

async function subscribeLiveWatchlist(watchlist: string[]) {
  const instruments = await rest.getInstruments({ instType });
  const liveIds = new Set(
    instruments.filter((i) => i.state === 'live').map((i) => i.instId),
  );

  for (const instId of watchlist) {
    if (!liveIds.has(instId)) {
      console.warn(instId, 'is not live, skipping');
      continue;
    }
    subscribed.add(instId);
    ws.subscribe(tickerTopic(instId));
  }

  ws.subscribe({ channel: 'instruments', instType });
}

subscribeLiveWatchlist(['BTC-USDT-SWAP', 'ETH-USDT-SWAP']).catch(console.error);

Use the same instType you trade: SPOT, MARGIN, SWAP, FUTURES, OPTION or EVENTS. The tickers topic here is only an example. The same pattern applies to other instId channels such as trades, candle1m or books: unsubscribe with the same topic object you used to subscribe. If you subscribe to several channels per instrument, drop all of them.

The instId: fragment in the error message matches the official template with {0} filled in, as in the RVN-USDT-SWAP payload above. If a 60018 is about a wrong URL or channel name and has no instId, the regex will not match, and the log is the place to start.

Checklist

Symptom Likely cause Fix
60018 with instId:SOMETHING doesn't exist Delisted or never-listed instrument, or a typo in instId Filter getInstruments() to state === 'live', unsubscribe, and stop resubscribing that topic
60018 after a reconnect, for a pair that used to work The instrument was delisted while you were connected, and the SDK still had the topic cached Watch the instruments channel and unsubscribe() when state is no longer live. Catch 60018 as a backstop
60018 with no instId in msg Wrong channel name or WebSocket URL Check the channel string and that you are on the public connection for public channels
  • Do not subscribe from a hardcoded list without checking state === 'live'.
  • Treat instruments pushes as incremental. Merge by instId.
  • Call unsubscribe() so the SDK will not resubscribe after reconnected.
  • Compare err.code to the string '60018', not a number.

Further reading