UNPKG

bitget-api

Version:

Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.

50 lines 1.54 kB
export function serializeParams(params, strict_validation = false, encodeValues = true, prefixWith = '') { if (!params) { return ''; } const queryString = Object.keys(params) .sort() .map((key) => { const value = params[key]; if (strict_validation === true && typeof value === 'undefined') { throw new Error('Failed to sign API request due to undefined parameter'); } const encodedValue = encodeValues ? encodeURIComponent(value) : value; return `${key}=${encodedValue}`; }) .join('&'); // Only prefix if there's a value return queryString ? prefixWith + queryString : queryString; } export function getRestBaseUrl(useTestnet, restInverseOptions) { const exchangeBaseUrls = { livenet: 'https://api.bitget.com', livenet2: 'https://capi.bitget.com', testnet: 'https://noTestnet', }; if (restInverseOptions.baseUrl) { return restInverseOptions.baseUrl; } if (useTestnet) { return exchangeBaseUrls.testnet; } return exchangeBaseUrls.livenet; } export function isWsPong(msg) { // bitget if (msg?.data === 'pong') { return true; } return false; } /** * Used to switch how authentication/requests work under the hood (primarily for SPOT since it's different there) */ export const REST_CLIENT_TYPE_ENUM = { spot: 'spot', futures: 'futures', broker: 'broker', v2: 'v2', v3: 'v3', }; //# sourceMappingURL=requestUtils.js.map