UNPKG

@planet-a/affinity-node

Version:
46 lines (45 loc) 1.6 kB
import type { AxiosInstance } from 'axios'; export type RateLimitBoundary = { /** The maximum number of calls for each period. Please note, this can be `Infinity`. */ limit: number | typeof Infinity; /** The number of calls remaining before reset. Please note, this can be `Infinity`. */ remaining: number | typeof Infinity; /** Time in seconds until call count resets. */ reset: number; /** The number of calls that have been used. */ used: number; }; export type RateLimitResponse = { /** * Type of rate limit. */ rate: { /** Monthly rate limit per organization. */ org_monthly: RateLimitBoundary; /** Per minute rate limit per API key. */ api_key_per_minute: RateLimitBoundary; }; }; /** * @module */ export declare class RateLimit { private readonly axios; /** @hidden */ constructor(axios: AxiosInstance); /** * The rate limit endpoint allows you to see your monthly account-level and per minute user-level API limits and usage. * The monthly account-level call limit resets at the end of each calendar month. * * More details [here](https://api-docs.affinity.co/#rate-limits). * * @returns The rate limit resource, a JSON body of data including limits, calls remaining, seconds until reset and call count. * * @example * ```typescript * const rateLimit = await affinity.rateLimit.get() * console.log(`You have ${rateLimit.rate.org_monthly.remaining} calls left this month.`) * ``` */ get(): Promise<RateLimitResponse>; }