← All articles

Gate API INVALID_CURRENCY_PAIR in Node.js: pair format, INVALID_CURRENCY and CONTRACT_NOT_FOUND

Gate’s INVALID_CURRENCY_PAIR error almost always means the pair string is in the wrong shape, not that the market is missing. Gate spot pairs are written BASE_QUOTE with an underscore, so BTC_USDT works while BTCUSDT, BTC-USDT and BTC/USDT all fail. That is easy to trip over when the same code also talks to an exchange that uses BTCUSDT or BTC-USDT.

This note shows how the error surfaces in the open-source gateio-api package (the Gate JavaScript SDK we maintain at Siebly), how to resolve any user-typed pair against Gate’s live pair list, and the two related errors you will meet next: INVALID_CURRENCY and CONTRACT_NOT_FOUND. Everything below was run against the live public API on 25 November 2026 with gateio-api 1.6.9. No API key is needed for any of it.

What Gate returns for each format

Public ticker requests, GET /api/v4/spot/tickers?currency_pair=..., gave these results:

Input HTTP Response
BTC_USDT 200 Ticker for BTC_USDT
btc_usdt 200 Ticker for BTC_USDT (REST accepted lower case)
BTCUSDT 400 {"label":"INVALID_CURRENCY_PAIR","message":"Invalid currency pair BTCUSDT"}
BTC-USDT 400 INVALID_CURRENCY_PAIR
BTC/USDT 400 INVALID_CURRENCY_PAIR
FOO_USDT 400 {"label":"INVALID_CURRENCY","message":"Invalid currency FOO"}

So the two labels tell you different things. INVALID_CURRENCY_PAIR means Gate could not parse the string as a pair. INVALID_CURRENCY means it parsed the pair but one side is not a currency Gate knows, usually a typo or a ticker that is listed under a different symbol on Gate.

Reading the label from the SDK error

When a request fails, gateio-api throws an object with the HTTP status in code and Gate’s JSON body in body, so the label is one property away:

import { RestClient } from 'gateio-api';

const client = new RestClient();

try {
  await client.getSpotTicker({ currency_pair: 'BTCUSDT' });
} catch (err) {
  const e = err as { code?: number; body?: { label?: string; message?: string } };
  console.log(e.code, e.body?.label, e.body?.message);
  // 400 INVALID_CURRENCY_PAIR Invalid currency pair BTCUSDT
}

Branch on body.label rather than on the message text. The label is stable; the message includes whatever you sent.

Resolve pairs against the live list, not a regex

A tempting fix is to split BTCUSDT by guessing the quote currency. It works until a symbol ends in something that looks like a quote. A safer approach is to load Gate’s pair list once with getSpotCurrencyPairs() and index each pair under both its Gate id and its compact form. On 25 November 2026 that list had 2,136 pairs and no two collapsed to the same compact string, so the lookup is unambiguous:

import { RestClient } from 'gateio-api';

const client = new RestClient();

type PairIndex = Map<string, string>;

async function buildPairIndex(): Promise<PairIndex> {
  const pairs = await client.getSpotCurrencyPairs();
  const index: PairIndex = new Map();
  for (const p of pairs) {
    if (!p.id) continue;
    index.set(p.id, p.id); // BTC_USDT
    index.set(p.id.replace('_', ''), p.id); // BTCUSDT
  }
  return index;
}

function resolvePair(index: PairIndex, input: string): string {
  const key = input.trim().toUpperCase().replace(/[-/:\s]/g, '_');
  const id = index.get(key) ?? index.get(key.replace('_', ''));
  if (!id) throw new Error(`Gate has no spot pair matching "${input}"`);
  return id;
}

const index = await buildPairIndex();
resolvePair(index, 'BTCUSDT'); // 'BTC_USDT'
resolvePair(index, 'btc-usdt'); // 'BTC_USDT'
resolvePair(index, 'BTC/USDT'); // 'BTC_USDT'
resolvePair(index, 'ETHBTC'); // 'ETH_BTC'
resolvePair(index, 'FOOUSDT'); // throws before any order is sent

Refresh the index on start-up and every few hours. New listings appear without notice, and a stale list turns a valid symbol into a false “no such pair”.

A valid pair can still be closed for trading

Getting the format right is not the last check. Each pair from getSpotCurrencyPair() carries a trade_status of tradable, buyable, sellable or untradable. On 25 November 2026 three pairs were not fully tradable: ETNM_USDT (sellable), USDT_USD and ACE_USDT (both untradable). The same record gives the order limits you need before sizing an order:

const id = resolvePair(index, 'eth/usdt');
const pair = await client.getSpotCurrencyPair({ currency_pair: id });

if (pair.trade_status !== 'tradable') {
  throw new Error(`${id} is ${pair.trade_status} on Gate`);
}

console.log(id, pair.min_quote_amount, pair.amount_precision, pair.precision);
// ETH_USDT 3 4 2

min_quote_amount is the smallest order value in the quote currency, amount_precision is the number of decimals allowed in the amount, and precision is the number of decimals allowed in the price.

Futures: CONTRACT_NOT_FOUND instead

Futures endpoints use the same underscore format but call it a contract, and they answer a bad name with a different label and no message:

curl https://api.gateio.ws/api/v4/futures/usdt/contracts/BTCUSDT
# 400 {"label":"CONTRACT_NOT_FOUND"}

With the SDK, pass the settle currency and the contract name:

const contract = await client.getFuturesContract({
  settle: 'usdt',
  contract: 'BTC_USDT',
});

console.log(contract.name, contract.quanto_multiplier); // BTC_USDT 0.0001

If you see CONTRACT_NOT_FOUND for a name that looks right, check the settle currency as well. A USDT-margined contract will not be found under settle: 'btc'.

WebSocket subscriptions fail quietly

The WebSocket API does not throw. A subscription with the wrong format is acknowledged with an error inside the response, and then no updates arrive. With gateio-api the acknowledgement comes through the response event:

import { WebsocketClient, WS_KEY_MAP } from 'gateio-api';

const ws = new WebsocketClient();

ws.on('response', (data) => {
  if (data?.error) {
    console.error('Subscribe failed:', data.channel, data.payload, data.error.message);
  }
});

ws.on('update', (data) => console.log(data.result?.currency_pair, data.result?.last));

ws.subscribe({ topic: 'spot.tickers', payload: ['BTCUSDT'] }, WS_KEY_MAP.spotV4);
// Subscribe failed: spot.tickers [ 'BTCUSDT' ] unknown currency pair: BTCUSDT

The raw acknowledgement is "error":{"code":2,"message":"unknown currency pair: BTCUSDT"} with "result":{"status":"fail"}. Subscribing with BTC_USDT returns "status":"success" and ticker updates start straight away. If a stream seems silent, log the response events before suspecting the connection.

Checklist

  • Spot pairs are BASE_QUOTE with an underscore. Upper case is safest across REST and WebSocket.
  • INVALID_CURRENCY_PAIR: the string could not be parsed as a pair. Fix the format.
  • INVALID_CURRENCY: the pair parsed, but one currency is unknown. Check the symbol Gate uses.
  • CONTRACT_NOT_FOUND: futures name or settle currency is wrong.
  • Resolve user input against getSpotCurrencyPairs() and check trade_status before placing orders.
  • On WebSockets, watch the response event for subscription errors.

Further reading

The Gate API JavaScript tutorial walks through public data, keys, spot and futures orders and WebSockets in Node.js, and the Gate SDK docs list every REST and WebSocket method. If your signed requests are failing instead, see Gate API INVALID_SIGNATURE, REQUEST_EXPIRED and INVALID_KEY in Node.js. The SDK is open source under the MIT licence, from the same maintainers as the binance, bybit-api and okx-api packages, with over 4.5 million npm downloads across 10+ SDKs.