---
title: "Using proxy with Siebly SDKs"
description: "Configure Siebly proxies crypto trading api Node.js to bypass IP rate limits and geo-blocks. Learn to inject proxy agents for stable Binance & Bybit SDKs."
canonical: "https://siebly.io/blog/using-proxy-with-siebly-sdks"
---

# Using proxy with Siebly SDKs

Configure Siebly proxies crypto trading api Node.js to bypass IP rate limits and geo-blocks. Learn to inject proxy agents for stable Binance & Bybit SDKs.

## Technical Disclaimer

These articles are software engineering references for exchange API integrations. They are not financial, investment, legal, tax, compliance, or trading advice. Use public data, demo, testnet, or paper workflows first. Keep API credentials out of frontend code and disable withdrawal permissions for automation keys.

## Overview {#overview}

A trading bot is only as reliable as its networking layer. IP-based rate limits and regional API restrictions show up quickly when you run Node.js integrations at scale. Proxies let you route traffic through a different IP without rewriting your signing logic.

This guide shows how to wire HTTP and SOCKS proxies into Siebly.io SDK constructors. The pattern is the same across the major packages: pass axios networking options for REST, and pass a proxy agent through wsOptions for WebSockets.

SDKs covered here:

- [binance](/sdk/binance/javascript)
- [bybit-api](/sdk/bybit/javascript)
- [okx-api](/sdk/okx/javascript)
- [@siebly/kraken-api](/sdk/kraken/javascript)
- [bitget-api](/sdk/bitget/javascript)
- [bitmart-api](/sdk/bitmart/javascript)
- [gateio-api](/sdk/gate/javascript)
- [kucoin-api](/sdk/kucoin/javascript)
- [coinbase-api](/sdk/coinbase/javascript)

## Key Takeaways {#key-takeaways}

- REST clients take proxy settings in the second constructor argument (AxiosRequestConfig), not inside your API key options.
- WebSocket clients take a proxy agent via wsOptions.agent. Binance (private streams), KuCoin, and Kraken also need requestOptions for internal REST (listen keys / tokens).
- Axios native proxy config works for many providers. If it does not, use https-proxy-agent or socks-proxy-agent.
- Request signing happens locally in the SDK. The proxy only forwards the finished request.
- SDKs do not rotate proxies for you. Handle that in your app or at the proxy provider.
- Load credentials from environment variables or a secret manager. Never hardcode them.




## Why proxies matter {#why-proxies-matter}

### Rate limiting and IP reputation {#rate-limiting-and-ip-reputation}

Exchanges like [Binance](/sdk/binance/javascript/tutorial) and [Bybit](/sdk/bybit/javascript/tutorial) track request volume per IP. Go over the limit and you get HTTP 429 responses. Keep pushing and the IP can end up blocked entirely.

A proxy pool spreads REST polling across multiple IPs. That helps with public market data workloads where one server IP cannot carry the full request load.

### Regional restrictions {#regional-restrictions}

Some endpoints only work from certain regions. That affects [okx-api](/sdk/okx/javascript), [@siebly/kraken-api](/sdk/kraken/javascript), [gateio-api](/sdk/gate/javascript), and [kucoin-api](/sdk/kucoin/javascript) depending on which market or region you target. A proxy in the right location lets your app reach those gateways without moving your main compute.

### Signing is not affected {#signing-is-not-affected}

Exchanges like [OKX](/sdk/okx/javascript) and [Kraken](/sdk/kraken/javascript) require accurate timestamps in signed requests. Extra proxy latency can trigger recv window errors if you are close to the limit.

The SDK signs the request before it hits the network. The proxy does not rewrite auth headers. If you see timestamp errors after adding a proxy, increase the recv window. The Bybit SDK documents this directly in its proxy examples (recv_window defaults to 5000 ms).

Before touching private endpoints, call a public method like a ticker or server time check to confirm routing works.

## Install dependencies {#install-dependencies}

npm install https-proxy-agent socks-proxy-agent

Most Siebly SDKs use axios under the hood. These agent libraries plug into axios and into the ws package used by WebSocket clients.

## REST API proxy setup {#rest-api-proxy-setup}

REST clients follow the same constructor shape across the SDKs:

new SomeRestClient(restOptions, networkOptions);

- restOptions: API keys, testnet flags, recv window, and other SDK settings.
- networkOptions: axios config, including proxy settings.

### Option 1: axios native proxy config {#option-1-axios-native-proxy-config}

This pattern comes from the [bybit-api proxy example](https://github.com/tiagosiebler/bybit-api/blob/master/examples/Rest/rest-v5-proxies.ts) and matches what the SDK test suites use:

import { RestClientV5 } from "bybit-api";

const client = new RestClientV5( { key: process.env.BYBIT_API_KEY, secret: process.env.BYBIT_API_SECRET, testnet: true, // Extra latency from a proxy can cause recv window errors // recv_window: 10000, }, { proxy: { protocol: "http", host: process.env.PROXY_HOST!, port: Number(process.env.PROXY_PORT), auth: { username: process.env.PROXY_USER!, password: process.env.PROXY_PASS!, }, }, }, );

The same second-argument pattern works for:

| Package | Common REST client |
| --- | --- |
| binance | MainClient, USDMClient, CoinMClient |
| bybit-api | RestClientV5 |
| okx-api | RestClient |
| @siebly/kraken-api | SpotClient, DerivativesClient |
| bitget-api | RestClientV2 |
| bitmart-api | RestClient |
| gateio-api | RestClient |
| kucoin-api | SpotClient, FuturesClient |
| coinbase-api | CBAdvancedTradeClient, CBExchangeClient, etc. |

Binance example:

import { MainClient } from "binance";

const client = new MainClient( { testnet: true }, { proxy: { protocol: "http", host: process.env.PROXY_HOST!, port: Number(process.env.PROXY_PORT), auth: { username: process.env.PROXY_USER!, password: process.env.PROXY_PASS!, }, }, }, );

const serverTime = await client.getServerTime();

Kraken example:

import { SpotClient } from "@siebly/kraken-api";

const client = new SpotClient( { apiKey: process.env.KRAKEN_API_KEY, apiSecret: process.env.KRAKEN_API_SECRET, }, { proxy: { protocol: "http", host: process.env.PROXY_HOST!, port: Number(process.env.PROXY_PORT), auth: { username: process.env.PROXY_USER!, password: process.env.PROXY_PASS!, }, }, }, );

Coinbase example:

import { CBAdvancedTradeClient } from "coinbase-api";

const client = new CBAdvancedTradeClient( {}, { proxy: { protocol: "http", host: process.env.PROXY_HOST!, port: Number(process.env.PROXY_PORT), auth: { username: process.env.PROXY_USER!, password: process.env.PROXY_PASS!, }, }, }, );

### Option 2: HttpsProxyAgent {#option-2-httpsproxyagent}

Some proxy providers do not work with axios proxy config. Use https-proxy-agent instead, as shown in [bybit-api rest-v5-proxies2.ts](https://github.com/tiagosiebler/bybit-api/blob/master/examples/Rest/rest-v5-proxies2.ts):

import { HttpsProxyAgent } from "https-proxy-agent"; import { RestClientV5 } from "bybit-api";

const client = new RestClientV5( { key: process.env.BYBIT_API_KEY, secret: process.env.BYBIT_API_SECRET, testnet: true, }, { httpAgent: proxyAgent, httpsAgent: proxyAgent, }, );



## WebSocket proxy setup {#websocket-proxy-setup}

WebSocket clients accept a proxy through wsOptions.agent.

### SOCKS5 example (Binance) {#socks5-example-binance}

From the [binance ws-proxy-socks example](https://github.com/tiagosiebler/binance/blob/master/examples/WebSockets/Misc/ws-proxy-socks.ts):

import { WebsocketClient } from "binance"; import { SocksProxyAgent } from "socks-proxy-agent";

const agent = new SocksProxyAgent(process.env.SOCKS_PROXY_URL!);

const wsClient = new WebsocketClient({ beautify: true, wsOptions: { agent, }, });

wsClient.on("open", (data) => { console.log("connected:", data.wsKey); });

wsClient.subscribeAll24hrTickers("usdm");

### When you need requestOptions as well {#when-you-need-requestoptions-as-well}

Most WebSocket clients only need `wsOptions.agent`. Some also make internal REST calls (listen keys, WS auth tokens). For those, set both:

- `wsOptions.agent` for the socket connection
- `requestOptions` for axios-backed REST calls inside the client

| Package | WS proxy knobs |
| --- | --- |
| bybit-api, okx-api, bitget-api, bitmart-api, gateio-api, coinbase-api | `wsOptions.agent` only |
| kucoin-api, @siebly/kraken-api | `wsOptions.agent` + `requestOptions` (token fetch) |
| binance | `wsOptions.agent`; add `requestOptions` for private user-data / listen keys (WebsocketClient and WebsocketAPIClient) |

Kraken / KuCoin example (token fetch over REST):

import { HttpsProxyAgent } from "https-proxy-agent"; import { WebsocketClient } from "kucoin-api";

const wsClient = new WebsocketClient({ apiKey: process.env.KUCOIN_API_KEY, apiSecret: process.env.KUCOIN_API_SECRET, apiPassphrase: process.env.KUCOIN_API_PASSPHRASE, wsOptions: { agent: proxyAgent, }, requestOptions: { httpAgent: proxyAgent, httpsAgent: proxyAgent, }, });

Bybit needs only the socket agent:

import { HttpsProxyAgent } from "https-proxy-agent"; import { WebsocketClient } from "bybit-api";

const wsClient = new WebsocketClient({ key: process.env.BYBIT_API_KEY, secret: process.env.BYBIT_API_SECRET, wsOptions: { agent: proxyAgent, }, });

Binance private streams (listen keys) need the same split on WebsocketClient or WebsocketAPIClient. From the SDK test suite:

import { WebsocketAPIClient } from "binance";

const wsAPIClient = new WebsocketAPIClient({ api_key: process.env.BINANCE_API_KEY, api_secret: process.env.BINANCE_API_SECRET, wsOptions: { agent: proxyAgent, }, requestOptions: { proxy: { protocol: "http", host: process.env.PROXY_HOST!, port: Number(process.env.PROXY_PORT), auth: { username: process.env.PROXY_USER!, password: process.env.PROXY_PASS!, }, }, }, });

### HTTP vs SOCKS5 for WebSockets {#http-vs-socks5-for-websockets}

HTTP proxies work for REST and for many WebSocket setups. SOCKS5 is often a better fit for long-lived private streams because it tunnels raw TCP with less overhead.

For [okx-api](/sdk/okx/javascript), [bitget-api](/sdk/bitget/javascript), [bitmart-api](/sdk/bitmart/javascript), [gateio-api](/sdk/gate/javascript), [bybit-api](/sdk/bybit/javascript), and [coinbase-api](/sdk/coinbase/javascript), pass the agent through `wsOptions.agent` only.

Gate.io example:

import { WebsocketClient } from "gateio-api"; import { SocksProxyAgent } from "socks-proxy-agent";

const agent = new SocksProxyAgent(process.env.SOCKS_PROXY_URL!);

const ws = new WebsocketClient({ apiKey: process.env.GATE_API_KEY, apiSecret: process.env.GATE_API_SECRET, wsOptions: { agent }, });

## Per-SDK examples {#per-sdk-examples}

### Binance (binance) {#binance-binance}

- REST: new MainClient(restOptions, networkOptions)
- WebSocket (public streams): wsOptions.agent
- WebSocket private user-data / listen keys: wsOptions.agent + requestOptions
- WebSocket API (order commands over WS): wsOptions + requestOptions
- Test with testnet: true or demoTrading: true in restOptions

### Bybit (bybit-api) {#bybit-bybit-api}

- REST: new RestClientV5(restOptions, networkOptions)
- Official proxy examples: examples/Rest/rest-v5-proxies.ts and rest-v5-proxies2.ts
- WebSocket: wsOptions.agent only (requestOptions.agent is a legacy alias for the same WS agent)
- Test with testnet: true on the v5 testnet

### OKX (okx-api) {#okx-okx-api}

- REST: new RestClient(restOptions, networkOptions)
- WebSocket: wsOptions.agent
- WebSocket API client: WebsocketAPIClient with the same agent pattern
- Demo trading: demoTrading: true (not market: 'demo')

### Kraken (@siebly/kraken-api) {#kraken-siebly-kraken-api}

- REST: new SpotClient(restOptions, networkOptions) or DerivativesClient
- WebSocket: wsOptions.agent + requestOptions for axios REST token fetches
- Testnet: testnet: true (derivatives demo environment)

### Bitget (bitget-api) {#bitget-bitget-api}

- REST: new RestClientV2(restOptions, networkOptions)
- WebSocket: wsOptions.agent on WebsocketClientV2
- WS API commands (order placement over WS) need a stable tunnel; SOCKS5 is a solid default

### BitMart (bitmart-api) {#bitmart-bitmart-api}

- REST: new RestClient(restOptions, networkOptions)
- WebSocket: wsOptions.agent

### Gate.io (gateio-api) {#gate-io-gateio-api}

- REST: new RestClient(restOptions, networkOptions)
- WebSocket: wsOptions.agent only
- Sandbox: useTestnet: true

### KuCoin (kucoin-api) {#kucoin-kucoin-api}

- REST: new SpotClient(restOptions, networkOptions)
- WebSocket: wsOptions.agent + requestOptions (bullet token over REST)
- Regional routing: apiRegion: 'EU' | 'AU' in restOptions when needed

### Coinbase (coinbase-api) {#coinbase-coinbase-api}

- REST: second constructor arg on CBAdvancedTradeClient, CBExchangeClient, CBPrimeClient, etc.
- WebSocket: wsOptions.agent on WebsocketClient
- Sandbox: useSandbox: true where supported

## Production notes {#production-notes}

Treat the proxy as infrastructure you monitor, not a black box.

- Health-check public endpoints before enabling private trading logic.
- Rotate to a backup proxy if you see repeated 407 responses or persistent timeouts.
- Halt order placement if proxy latency crosses a threshold you define.
- Never grant withdrawal permissions on automation API keys.
- Keep proxy and exchange credentials in environment variables or a secret manager.

For a broader view of how this fits into a full system, see the [algorithmic trading system architecture guide](/blog/algorithmic-trading-system-architecture-in-nodejs-a-2026-engineering-guide).

## Frequently Asked Questions {#frequently-asked-questions}

### How do I use an HTTP proxy with the Bybit SDK? {#how-do-i-use-an-http-proxy-with-the-bybit-sdk}

Pass axios networking config as the second constructor argument. You can use the native proxy object or an HttpsProxyAgent via httpAgent/httpsAgent. See examples/Rest/rest-v5-proxies.ts in the [bybit-api](/sdk/bybit/javascript/tutorial) repo.

### Does using a proxy affect request signing? {#does-using-a-proxy-affect-request-signing}

No. The SDK signs locally before the request leaves your process. The proxy only forwards the payload.

### Can I use a SOCKS5 proxy for WebSocket streams? {#can-i-use-a-socks5-proxy-for-websocket-streams}

Yes. Pass a SocksProxyAgent through wsOptions.agent. This works across Binance, Bybit, OKX, Kraken, Bitget, BitMart, Gate.io, KuCoin, and Coinbase WebSocket clients.

### Will a proxy help me avoid Bybit or Binance rate limits? {#will-a-proxy-help-me-avoid-bybit-or-binance-rate-limits}

It helps with IP-based limits by spreading traffic across multiple addresses. It does not bypass account-level limits tied to your API key.

### What Node.js libraries should I use for proxy agents? {#what-node-js-libraries-should-i-use-for-proxy-agents}

https-proxy-agent for HTTP/HTTPS proxies and socks-proxy-agent for SOCKS5. Both integrate with the axios config that Siebly SDKs accept.

### Do Siebly SDKs rotate proxies automatically? {#do-siebly-sdks-rotate-proxies-automatically}

No. Build rotation in your application, or use a provider that rotates at the gateway.

### Is it safe to pass proxy credentials in the SDK constructor? {#is-it-safe-to-pass-proxy-credentials-in-the-sdk-constructor}

Yes, as long as the values come from environment variables or a secret manager at runtime, not from source code.

### How much latency does a proxy add? {#how-much-latency-does-a-proxy-add}

Usually 5 to 50 ms depending on geography and protocol. For [coinbase-api](/sdk/coinbase/javascript), pick a proxy region close to the exchange gateway you are hitting.

Article by Siebly.io

## Related articles

- [Handling Exchange API Rate Limits in JavaScript: A 2026 Engineering Guide](/blog/handling-exchange-api-rate-limits-in-javascript-a-2026-engineering-guide)
- [Paper Trading API Node.js: A Professional Engineering Guide](/blog/paper-trading-api-nodejs-a-professional-engineering-guide)
- [Stream Real-Time Crypto Market Data with TypeScript SDKs](/blog/stream-real-time-crypto-market-data-with-typescript-sdks)


## Related Siebly Resources

- [Binance JavaScript SDK](/sdk/binance/javascript)
- [Bybit JavaScript SDK](/sdk/bybit/javascript)
- [OKX JavaScript SDK](/sdk/okx/javascript)
- [Siebly SDK directory](/sdk)
- [Exchange State Management](/ai/exchange-state)
