Bitget Auth REST private RSA JavaScript example for the Siebly Bitget SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.
We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.
bitget-api instead of hand-written signing code.Bitget/Auth/rest-private-rsa.ts.RestClientV2, RestClientV3.getBalances().import { RestClientV2, RestClientV3 } from 'bitget-api'; // Import frmo NPM: // or if you prefer require: // Received after creating a new API key with a self-generated RSA public key on Bitgetconst API_KEY = 'bg_0866563123123123123f567e83e52fd'; // The self-generated RSA private key, this is never directly given to Bitget, but used to generate a signature// Note: this MUST include the "BEGIN PRIVATE KEY" header so that the SDK understands this is RSA authconst rsaPrivateKey = `-----BEGIN PRIVATE KEY-----MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC4kNgO71O0xkuHFjHnr5pimpEeiGPAtDTAeJoS55+kVrh3ThHsm0ARf36zimUgwrCWAnKqPlbqzWzs9mH9JvZWrEaOgWy8wMSJ21vtz1rRJhfaUUsOC1KLoWyvzqWW44zKaxoKSqCUMJqDbxIq7RjGlmc8KGJscFWRSdfGEEpvqLlpTLoEtWHZP0pUUamSWrH/IgieFFhKaOPvmED24DJAlqSeEFwz7TW4dfWPRgjCRu4AAfgCtjb+3/7ONeQfx5XFvKFM7VNi/9sRh+alRqpzKrlI79bM1p/egrC4c8KUqrNk2s5c3HIU......THISISANEXAMPLE-----END PRIVATE KEY-----`; // This is set by you when registering your RSA API key in Bitget's website.const API_PASS = 'TestingRSA'; const client = new RestClientV2({ apiKey: API_KEY, apiSecret: rsaPrivateKey, apiPass: API_PASS,}); const clientV3 = new RestClientV3({ apiKey: API_KEY, apiSecret: rsaPrivateKey, apiPass: API_PASS,}); // const wsClient = new WebsocketClientV2({// apiKey: API_KEY,// apiSecret: rsaPrivateKey,// apiPass: API_PASS,// }); (async () => { try { console.log('V2 private api call result: ', await client.getBalances()); } catch (e) { console.error('V2 request failed: ', e); } try { console.log('V3 private api call result: ', await clientV3.getBalances()); } catch (e) { console.error('V3 request failed: ', e); }})(); We use essential cookies and optional analytics. Read the Privacy Policy.
Essential cookies stay on. Toggle analytics if you want to share anonymous usage insights. You can revisit this anytime via Cookie Settings in the footer.