Skip to content

Authentication ​

Public market data needs no credentials. Account queries and trading require an API key with the relevant permissions.

Configure credentials ​

Set the environment variables below to configure a Spot Testnet client.

ts
import { MainClient } from 'binance';

const api_key = process.env.BINANCE_API_KEY;
const api_secret = process.env.BINANCE_API_SECRET;
if (!api_key || !api_secret) throw new Error('Set BINANCE_API_KEY and BINANCE_API_SECRET.');

export const client = new MainClient({ api_key, api_secret, testnet: true });

Store credentials in server-side environment variables or a secret manager, outside source files and browser bundles.

Match the environment and account ​

Use keys for the selected Binance product and environment. Check key permissions and IP restrictions if an account request fails.

Signing and timestamps ​

The SDK signs private requests. Keep the host clock synchronized, since signed requests include a timestamp.

Configuration · Troubleshooting · Exchange authentication documentation

Built by Siebly. Open source SDKs for exchange APIs.