Skip to content

Proxies ​

Proxy configuration belongs on the server. Use proxies only for networks and exchange access you are authorized to use; they do not change account eligibility or regional restrictions.

REST HTTP proxy ​

Pass Axios proxy options as the second REST constructor argument:

ts
import { RestClientV3 } from 'bitget-api';

export const client = new RestClientV3({}, {
  timeout: 20_000,
  proxy: {
    protocol: 'http',
    host: '127.0.0.1',
    port: 8080,
  },
});

This routes REST only. It does not configure WebSockets.

Shared HTTPS proxy agent ​

Install the agent dependency:

sh
npm install https-proxy-agent

Set PROXY_URL in your private server environment, then use an agent for both transports:

ts
import { HttpsProxyAgent } from 'https-proxy-agent';
import { RestClientV3, WebsocketClientV3 } from 'bitget-api';

const proxyUrl = process.env.PROXY_URL;
if (!proxyUrl) {
  throw new Error('Set PROXY_URL to your HTTP or HTTPS proxy URL.');
}
const agent = new HttpsProxyAgent(proxyUrl);

export const client = new RestClientV3({
  keepAlive: false,
}, {
  httpsAgent: agent,
  proxy: false,
  timeout: 20_000,
});
export const ws = new WebsocketClientV3({
  wsOptions: {
    agent,
  },
});

proxy: false disables Axios's separate proxy handling so the supplied agent routes requests. keepAlive: false prevents the SDK from replacing the custom agent. The examples use V3 clients; the same approach applies to Classic V2 clients.

Do not print proxy URLs containing credentials, commit them, or put them in a browser bundle. These Node.js agents are not supported in browsers or Cloudflare Workers.

Configuration · Production usage

Built by Siebly. Open source SDKs for exchange APIs.