feat(): add V2 REST client with initial endpoints

This commit is contained in:
Tiago Siebler
2023-11-13 17:31:18 +00:00
parent 8960b17151
commit 62aad4e2b8
7 changed files with 938 additions and 5 deletions

View File

@@ -19,17 +19,40 @@ type NetworkMap<
export const WS_BASE_URL_MAP: Record<
WsKey,
Record<'all', NetworkMap<'livenet'>>
Record<'all' | 'public' | 'private', NetworkMap<'livenet'>>
> = {
mixv1: {
all: {
livenet: 'wss://ws.bitget.com/mix/v1/stream',
},
public: {
livenet: 'N/A',
},
private: {
livenet: 'N/A',
},
},
spotv1: {
all: {
livenet: 'wss://ws.bitget.com/spot/v1/stream',
},
public: {
livenet: 'N/A',
},
private: {
livenet: 'N/A',
},
},
v2: {
all: {
livenet: 'N/A',
},
public: {
livenet: 'wss://ws.bitget.com/v2/ws/public',
},
private: {
livenet: 'wss://ws.bitget.com/v2/ws/private',
},
},
};
@@ -37,6 +60,7 @@ export const WS_BASE_URL_MAP: Record<
export const WS_KEY_MAP = {
spotv1: 'spotv1',
mixv1: 'mixv1',
v2: 'v2',
} as const;
/** Any WS keys in this list will trigger auth on connect, if credentials are available */
@@ -88,7 +112,8 @@ export function getWsKeyForTopic(
export function getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null {
switch (wsKey) {
case 'mixv1':
case 'spotv1': {
case 'spotv1':
case 'v2': {
// Technically there doesn't seem to be a documented cap, but there is a size limit per request. Doesn't hurt to batch requests.
return 15;
}