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 Bybit Testnet client.
ts
import { RestClientV5 } from 'bybit-api';
const key = process.env.BYBIT_API_KEY;
const secret = process.env.BYBIT_API_SECRET;
if (!key || !secret) throw new Error('Set BYBIT_API_KEY and BYBIT_API_SECRET.');
export const client = new RestClientV5({ key, 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
Live, Testnet and demo use separate credentials. Match the key to the selected environment and check its permissions and IP restrictions.
Signing and timestamps
The SDK signs private requests. Keep the host clock synchronized, since signed requests include a timestamp.
Configuration · Troubleshooting · Exchange authentication documentation