feat(#251): add optional bapi rate limit parsing to REST clients

This commit is contained in:
tiagosiebler
2023-10-30 13:47:40 +00:00
parent eb33084b7f
commit a790fcaf04
4 changed files with 93 additions and 9 deletions

View File

@@ -52,8 +52,8 @@ export interface GetOrderbookParamsV5 {
limit?: number;
}
export interface GetTickersParamsV5 {
category: CategoryV5;
export interface GetTickersParamsV5<TCategory = CategoryV5> {
category: TCategory;
symbol?: string;
baseCoin?: string;
expDate?: string;

View File

@@ -61,18 +61,33 @@ export interface APIResponse<T> {
result: T;
}
export interface APIRateLimit {
/** Remaining requests to this endpoint before the next reset */
remainingRequests: number;
/** Max requests for this endpoint per rollowing window (before next reset) */
maxRequests: number;
/**
* Timestamp when the rate limit resets if you have exceeded your current maxRequests.
* Otherwise, this is approximately your current timestamp.
*/
resetAtTimestamp: number;
}
export interface APIResponseV3<T> {
retCode: number;
retMsg: 'OK' | string;
result: T;
/**
* These are per-UID per-endpoint rate limits, automatically parsed from response headers if available.
*
* Note:
* - this is primarily for V5 (or newer) APIs.
* - these rate limits are per-endpoint per-account, so will not appear for public API calls
*/
rateLimitApi?: APIRateLimit;
}
export interface APIResponseV3WithTime<T> {
retCode: number;
retMsg: 'OK' | string;
result: T;
time: number;
}
export type APIResponseV3WithTime<T> = APIResponseV3<T> & { time: number };
export interface APIResponseWithTime<T = {}> extends APIResponse<T> {
/** UTC timestamp */