← All articles

Binance API rate limits in Node.js: request weight, 429, 418 and -1003

Binance Spot counts request weight by IP. A second service behind the same IP consumes the same budget. Once the budget is exhausted, Binance can return HTTP 429 with this body:

{"code":-1003,"msg":"Too much request weight used; current limit is 6000 request weight per 1 MINUTE. Please use WebSocket Streams for live updates to avoid polling the API."}

Repeated requests during the cooldown can lead to an HTTP 418 IP ban. Read the weight headers on each response and honour Retry-After across processes.

What 429, 418 and -1003 mean

  • HTTP 429: you broke a request rate limit. Binance’s Spot REST API docs say it is your job to back off at this point.
  • HTTP 418: your IP was banned automatically for continuing to send requests after 429s. The docs say bans “scale in duration for repeat offenders, from 2 minutes to 3 days”.
  • -1003 TOO_MANY_REQUESTS: the Binance error code in the response body. The Spot error codes page lists three messages for it:
Too many requests queued.
Too much request weight used; current limit is %s request weight per %s. Please use WebSocket Streams for live updates to avoid polling the API.
Way too much request weight used; IP banned until %s. Please use WebSocket Streams for live updates to avoid bans.

Binance uses -1003 for too much request weight. Order placement also has per-account limits, reported as -1015 TOO_MANY_ORDERS. See the Binance API error codes guide for other codes.

On Spot, both 429 and 418 responses carry a Retry-After header. In the docs’ words it gives “the number of seconds required to wait, in the case of a 429, to prevent a ban, or, in the case of a 418, until the ban is over.”

Read the current rate limits

Read rateLimits from Binance’s exchange information endpoint. The table shows the published limits on 27 November 2026.

Market Limit type Limit
Spot (MainClient) REQUEST_WEIGHT 6000 per 1 minute
Spot ORDERS 100 per 10 seconds
Spot ORDERS 200000 per 1 day
Spot RAW_REQUESTS 300000 per 5 minutes
USD-M futures (USDMClient) REQUEST_WEIGHT 2400 per 1 minute
USD-M futures ORDERS 1200 per 1 minute
USD-M futures ORDERS 300 per 10 seconds

Load the limits at startup. A Spot limiter set to 1,200 weight per minute would use only one fifth of a 6,000-weight budget. A hard-coded value above the current limit can trigger HTTP 429.

Read the limits when your process starts instead. Save this as limits.ts:

import { MainClient, USDMClient, type RateLimiter } from 'binance';

const INTERVAL_MS = { SECOND: 1_000, MINUTE: 60_000, DAY: 86_400_000 } as const;

export interface Limit {
  type: RateLimiter['rateLimitType'];
  windowMs: number;
  limit: number;
  label: string;
}

/** Turn exchangeInfo.rateLimits into numbers your code can use. */
export function parseRateLimits(rateLimits: RateLimiter[]): Limit[] {
  return rateLimits.map((r) => ({
    type: r.rateLimitType,
    windowMs: r.intervalNum * INTERVAL_MS[r.interval],
    limit: r.limit,
    label: `${r.limit} per ${r.intervalNum} ${r.interval}`,
  }));
}

/** The request weight allowed per minute, read from Binance instead of hard-coded. */
export function weightPerMinute(limits: Limit[]): number {
  const weight = limits.find((l) => l.type === 'REQUEST_WEIGHT' && l.windowMs === 60_000);
  if (!weight) throw new Error('No 1 minute REQUEST_WEIGHT limit in exchangeInfo');
  return weight.limit;
}

export async function loadLimits() {
  const spotInfo = await new MainClient().getExchangeInfo({ symbol: 'BTCUSDT' });
  const usdmInfo = await new USDMClient().getExchangeInfo();
  return {
    spot: parseRateLimits(spotInfo.rateLimits),
    usdm: parseRateLimits(usdmInfo.rateLimits),
  };
}

And a short script to print them, show-limits.ts:

import { loadLimits, weightPerMinute } from './limits.ts';

const { spot, usdm } = await loadLimits();
for (const [market, limits] of [['Spot', spot], ['USD-M futures', usdm]] as const) {
  console.log(market);
  for (const l of limits) console.log(`  ${l.type.padEnd(14)} ${l.label}`);
  console.log(`  weight budget per minute: ${weightPerMinute(limits)}`);
}

Output from node show-limits.ts:

Spot
  REQUEST_WEIGHT 6000 per 1 MINUTE
  ORDERS         100 per 10 SECOND
  ORDERS         200000 per 1 DAY
  RAW_REQUESTS   300000 per 5 MINUTE
  weight budget per minute: 6000
USD-M futures
  REQUEST_WEIGHT 2400 per 1 MINUTE
  ORDERS         1200 per 1 MINUTE
  ORDERS         300 per 10 SECOND
  weight budget per minute: 2400

The exchange information request is not free: Spot’s exchangeInfo has a weight of 20. Call it at startup and occasionally after that, not before every request.

Who shares the budget

This is where most surprise 429s come from. The two kinds of limit apply to different things:

  • Request weight is per IP address. The Spot docs say: “The limits on the API are based on the IPs, not the API keys.” Every process, container, cron job and API key that sends requests from the same IP spends the same 6000 (Spot) or 2400 (USD-M futures) a minute. Creating a second API key does not give you a second budget.
  • Order limits are per account. The Spot docs say “The number of unfilled orders is tracked for each account”, and the USD-M futures general info page says “The order rate limit is counted against each account.” Running order placement from two IPs does not double it.

So a 429 can appear even when your own process is well under budget, because something else on the same IP spent the rest. The usage headers below report the IP’s total, which is why they are the number to pace on, not a count kept inside one process.

Read your current usage: x-mbx-used-weight and getRateLimitStates()

Every Binance REST response includes headers with the weight the IP has used in the current window, such as x-mbx-used-weight-1m. Successful order responses also include order counts such as x-mbx-order-count-10s. The SDK records these after every response, including error responses, and getRateLimitStates() returns the latest values. Public endpoints need no API keys, so you can try it straight away. Save this as usage.ts:

import { MainClient, USDMClient } from 'binance';

const spot = new MainClient();
console.log('before any request:', spot.getRateLimitStates()['x-mbx-used-weight-1m']);

await spot.getOrderBook({ symbol: 'BTCUSDT', limit: 5 }); // weight 5 on Spot
console.log('Spot after one depth request:', spot.getRateLimitStates());

const usdm = new USDMClient();
await usdm.getOrderBook({ symbol: 'BTCUSDT', limit: 5 });
const futures = usdm.getRateLimitStates();
console.log('USD-M used weight (1m):', futures['x-mbx-used-weight-1m']);
console.log('USD-M x-mbx-used-weight:', futures['x-mbx-used-weight']);

Output from node usage.ts:

before any request: 0
Spot after one depth request: {
  'x-mbx-used-weight': 5,
  'x-mbx-used-weight-1m': 5,
  'x-sapi-used-ip-weight-1m': 0,
  'x-mbx-order-count-1s': 0,
  'x-mbx-order-count-10s': 0,
  'x-mbx-order-count-1m': 0,
  'x-mbx-order-count-1h': 0,
  'x-mbx-order-count-1d': 0,
  lastUpdated: 1795806031723
}
USD-M used weight (1m): 2
USD-M x-mbx-used-weight: 0

A few things to know before you build on these numbers:

  • Values are 0 and lastUpdated is unset until the client has received a response. A 0 before the first request means “unknown”, not “nothing used”.
  • Each client instance tracks its own copy. A MainClient and a USDMClient report different budgets, which is correct, as Spot and USD-M futures have separate weight limits.
  • For USD-M Futures, read x-mbx-used-weight-1m. A missing unsuffixed header does not mean usage is zero.
  • Order counts only appear on order responses, so they stay at 0 for a client that only reads market data.
  • x-sapi-used-ip-weight-1m is a separate counter used by IP limited /sapi endpoints, so it stays at 0 if you only call /api endpoints.

Pace requests before you hit the limit

The SDK does not throttle or retry REST requests. It sends each request when you call it and throws if Binance returns an error. So the pacing has to be in your code. Every endpoint has a documented weight, and some depend on the parameters. Spot’s order book (getOrderBook(), GET /api/v3/depth) is a good example:

limit Weight
1 to 100 5
101 to 500 25
501 to 1000 50
1001 to 5000 250
5001 to 7500 500

The pacer below uses the live x-mbx-used-weight-1m value from getRateLimitStates(), so it also sees weight spent by other processes on the IP. Below 70% of the limit it does nothing. Between 70% and 90% it spreads the remaining weight over the rest of the minute. At 90% it waits for the next minute. Requests through one pacer pass the check one at a time, so two concurrent calls cannot both see the same headroom. Save it as weight-pacer.ts:

import type { MainClient } from 'binance';

type HasRateLimitStates = Pick<MainClient, 'getRateLimitStates'>;

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const msToNextMinute = (now: number) => 60_000 - (now % 60_000) + 250;

/**
 * Paces REST calls from the x-mbx-used-weight-1m header the SDK records.
 * Below slowAt it does nothing. Between slowAt and stopAt it spreads the
 * remaining weight over the rest of the minute. At stopAt it waits for the next minute.
 */
export class WeightPacer {
  private queue: Promise<unknown> = Promise.resolve();
  private reserved = 0;
  private blockedUntil = 0;

  private readonly client: HasRateLimitStates;
  private readonly limitPerMinute: number;
  private readonly slowAt: number;
  private readonly stopAt: number;
  private readonly log: (line: string) => void;

  constructor(
    client: HasRateLimitStates,
    limitPerMinute: number,
    { slowAt = 0.7, stopAt = 0.9, log = console.log } = {},
  ) {
    this.client = client;
    this.limitPerMinute = limitPerMinute;
    this.slowAt = slowAt;
    this.stopAt = stopAt;
    this.log = log;
  }

  /** Run one request that costs `weight`, waiting first if the budget is tight. */
  run<T>(weight: number, request: () => Promise<T>): Promise<T> {
    const turn = this.queue.then(() => this.waitFor(weight));
    this.queue = turn.catch(() => undefined);
    return turn.then(async () => {
      this.reserved += weight;
      try {
        return await request();
      } finally {
        this.reserved -= weight;
      }
    });
  }

  /** Stop every request through this pacer until `until` (used after a 429 or 418). */
  blockUntil(until: number): void {
    this.blockedUntil = Math.max(this.blockedUntil, until);
  }

  /** Weight used this minute by everyone on this IP, plus requests still in flight. */
  usedWeight(now = Date.now()): number {
    const states = this.client.getRateLimitStates();
    // lastUpdated is unset until this client has seen a response.
    const sameMinute =
      Boolean(states.lastUpdated) &&
      Math.floor(states.lastUpdated / 60_000) === Math.floor(now / 60_000);
    return (sameMinute ? states['x-mbx-used-weight-1m'] : 0) + this.reserved;
  }

  private async waitFor(weight: number): Promise<void> {
    for (;;) {
      const now = Date.now();
      if (now < this.blockedUntil) {
        await sleep(this.blockedUntil - now);
        continue;
      }
      const used = this.usedWeight(now);
      const slowLimit = this.limitPerMinute * this.slowAt;
      const stopLimit = this.limitPerMinute * this.stopAt;

      if (used + weight >= stopLimit) {
        const wait = msToNextMinute(now);
        this.log(`used ${used} of ${this.limitPerMinute}: waiting ${wait} ms for the next minute`);
        await sleep(wait);
        continue;
      }
      if (used + weight >= slowLimit) {
        const requestsLeft = Math.max(1, Math.floor((stopLimit - used) / weight));
        const wait = Math.round(msToNextMinute(now) / requestsLeft);
        this.log(`used ${used} of ${this.limitPerMinute}: slowing down, ${wait} ms before the next request`);
        await sleep(wait);
      }
      return;
    }
  }
}

Use the exchange’s minute boundary when resetting the pacer. Keep the server clock synchronised. See fixing -1021 timestamp errors.

To test it against the real limit, this script asks for 30 order books with limit: 5000. At weight 250 each that is 7,500 weight, more than the 6000 a minute allows. Save it as pacer-demo.ts:

import { MainClient } from 'binance';
import { parseRateLimits, weightPerMinute } from './limits.ts';
import { WeightPacer } from './weight-pacer.ts';

// keepAlive reuses one HTTPS connection instead of opening one per request.
const client = new MainClient({ keepAlive: true });
const info = await client.getExchangeInfo({ symbol: 'BTCUSDT' });
const limit = weightPerMinute(parseRateLimits(info.rateLimits));
const pacer = new WeightPacer(client, limit);

// An order book with limit=5000 costs 250 weight on Spot, so 30 of them (7,500) cannot fit in one minute.
const started = Date.now();
for (let i = 1; i <= 30; i++) {
  await pacer.run(250, () => client.getOrderBook({ symbol: 'BTCUSDT', limit: 5000 }));
  const s = client.getRateLimitStates();
  const at = ((Date.now() - started) / 1000).toFixed(1);
  console.log(`#${i} at ${at}s, x-mbx-used-weight-1m=${s['x-mbx-used-weight-1m']}`);
}

Use the response header as the starting weight. A counter built from one process’s requests misses traffic from the rest of the IP.

Handle 429 and 418 without making it worse

  • The SDK throws a plain object, not an Error. instanceof Error is false, so check the fields instead.
  • The object has code, message, body, headers and requestUrl, but no HTTP status field. Detect rate limiting from code === -1003 and the retry-after header. If you need the raw status, the SDK’s parseExceptions: false option rethrows the underlying HTTP client error instead.
  • The SDK still updates getRateLimitStates() from the error response, so after a 429 it reports a weight above the 6000 limit.

This helper turns the thrown object into something you can act on. Save it as rate-limit-error.ts:

/** The object the binance SDK throws when Binance answers with an HTTP error. */
export interface BinanceHttpError {
  code?: number;
  message?: string;
  body?: unknown;
  headers?: Record<string, string>;
  requestUrl?: string;
}

export interface RateLimitHit {
  retryAfterMs: number;
  banned: boolean;
  message: string;
}

/** Returns details if the error is a 429 or 418 rate limit response, otherwise undefined. */
export function getRateLimitHit(error: unknown): RateLimitHit | undefined {
  if (typeof error !== 'object' || error === null || !('headers' in error)) return undefined;
  const e = error as BinanceHttpError;
  const retryAfter = e.headers?.['retry-after'];
  if (retryAfter === undefined && e.code !== -1003) return undefined;

  const seconds = Number(retryAfter);
  return {
    // No usable Retry-After: wait for the next minute rather than guessing lower.
    retryAfterMs: Number.isFinite(seconds) ? seconds * 1_000 : 60_000 - (Date.now() % 60_000),
    banned: /banned/i.test(e.message ?? ''),
    message: e.message ?? '',
  };
}

The retry rules come from the docs: wait at least Retry-After after a 429, never retry into a 418, and do not let one request keep retrying in a tight loop. Blocking the whole pacer matters as much as waiting: if one request waits but the other loops in your process carry on, you are still sending requests after a 429. Save this as with-rate-limit-retry.ts:

import { getRateLimitHit } from './rate-limit-error.ts';
import type { WeightPacer } from './weight-pacer.ts';

/**
 * Run a request through the pacer. On a 429, block every request through the
 * pacer for Retry-After, then try again. On a 418 ban, or a wait longer than
 * maxWaitMs, stop and throw so the caller can alert someone.
 */
export async function withRateLimitRetry<T>(
  pacer: WeightPacer,
  weight: number,
  request: () => Promise<T>,
  { attempts = 3, maxWaitMs = 120_000 } = {},
): Promise<T> {
  for (let attempt = 1; ; attempt++) {
    try {
      return await pacer.run(weight, request);
    } catch (error) {
      const hit = getRateLimitHit(error);
      if (!hit) throw error;

      pacer.blockUntil(Date.now() + hit.retryAfterMs);
      if (hit.banned || hit.retryAfterMs > maxWaitMs || attempt >= attempts) {
        throw new Error(`Binance rate limit, not retrying (retry after ${hit.retryAfterMs} ms): ${hit.message}`);
      }
      console.warn(`429 on attempt ${attempt}, pausing all requests for ${hit.retryAfterMs} ms`);
    }
  }
}

Use it in place of pacer.run():

const book = await withRateLimitRetry(pacer, 5, () => client.getOrderBook({ symbol: 'BTCUSDT', limit: 5 }));

On 429, pause requests across the IP for the cooldown. On 418, stop sending, report the ban and inspect which processes are consuming weight.

Move continuous data to WebSocket streams

Every message for -1003 ends with the same advice: use WebSocket streams for live updates. A polling loop that reads the top of the order book once a second costs 300 weight a minute on Spot (weight 5, 60 times), and it only sees one snapshot a second. A stream subscription costs no request weight. Save this as streams.ts:

import { WebsocketClient } from 'binance';

// Best bid and ask pushed by Binance on every change: no REST weight, no polling loop.
const ws = new WebsocketClient({ beautify: true });
let updates = 0;

ws.on('open', ({ wsKey }) => console.log('connected:', wsKey));
ws.on('formattedMessage', (event) => {
  updates++;
  if (updates === 1) console.log('first update:', JSON.stringify(event));
});
ws.on('exception', (error) => console.error('ws error', error));

await ws.subscribe(['btcusdt@bookTicker'], 'main2'); // 'main2' is port 443; 'main' is port 9443

setTimeout(() => {
  console.log(`updates in 10 s: ${updates}`);
  ws.closeAll();
}, 10_000);

Output from node streams.ts, with the SDK’s own connection log lines left out:

connected: main2
first update: {"updateId":103846950984,"symbol":"BTCUSDT","bidPrice":59909.08,"bidQty":0.66724,"askPrice":59909.09,"askQty":3.23096,"eventType":"bookTicker","wsMarket":"spot","streamName":"btcusdt@bookTicker","wsKey":"main2","isWSAPIResponse":false}
updates in 10 s: 1105

The example output shows over a thousand updates in 10 seconds with no request weight spent. Streams have their own limits, from Binance’s WebSocket streams page: 5 incoming messages per second per connection (pings, pongs and subscribe requests), 1024 streams per connection, and 300 connection attempts every 5 minutes per IP. The WebsocketClient batches subscriptions and reconnects for you, so the main thing to avoid is your own code opening new clients in a loop. The Binance JavaScript tutorial covers user data streams and the rest of the WebsocketClient.

Keep REST for what streams cannot give you: one off reads at startup, order placement and occasional reconciliation. For order book snapshots specifically, a single REST snapshot plus the diff stream replaces repeated polling.

Further reading