npm

@rc-ex/rate-limit
TypeScript icon, indicating that this package has built-in type declarations

1.1.18 • Public • Published

Rate Limit Extension

Rate limit extension handles rate limit automatically by delaying and retrying API calls.

This extension is based on the Retry Extension.

Install

yarn add @rc-ex/rate-limit

Usage

import RingCentral from '@rc-ex/core';
import RateLimitExtension from '@rc-ex/rate-limit';

const rc = new RingCentral(...);
const rateLimitExtension = new RateLimitExtension(rateLimitOptions);
await rc.installExtension(rateLimitExtension);

RateLimitOptions

RetryExtension constructor accepts optional RateLimitOptions as parameter:

type RateLimitOptions = {
  maxRetries?: number;
  rateLimitWindow?: number;
};

maxRetries

maxRetries defines maximum times of retries before aborting.

Default value is 3.

rateLimitWindow

rateLimitWindow defines the rate limit window. This parameter will only take effect when there is no x-rate-limit-window HTTP header available.

Default value is 60 (seconds).

Its value is used to determine the retryInterval.

Dependents (0)

Package Sidebar

Install

npm i @rc-ex/rate-limit

Weekly Downloads

9

Version

1.1.18

License

MIT

Unpacked Size

5.12 kB

Total Files

7

Last publish

Collaborators

  • tylerlong