Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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.