1.4.0 • Published 11 months ago

axios-rate-limit v1.4.0

Weekly downloads
19,847
License
MIT
Repository
github
Last release
11 months ago

axios-rate-limit

npm version npm downloads npm bundle size build status code coverage install size known vulnerabilities

A rate limit for Axios: set how many requests per interval should perform immediately, other will be delayed automatically.

Installing

npm install axios-rate-limit

Usage

import axios from 'axios';
import rateLimit from 'axios-rate-limit';

// sets max 2 requests per 1 second, other will be delayed
// note maxRPS is a shorthand for perMilliseconds: 1000, and it takes precedence
// if specified both with maxRequests and perMilliseconds
const http = rateLimit(axios.create(), { maxRequests: 2, perMilliseconds: 1000, maxRPS: 2 })
http.getMaxRPS() // 2
http.get('https://example.com/api/v1/users.json?page=1') // will perform immediately
http.get('https://example.com/api/v1/users.json?page=2') // will perform immediately
http.get('https://example.com/api/v1/users.json?page=3') // will perform after 1 second from the first one

// options hot-reloading also available
http.setMaxRPS(3)
http.getMaxRPS() // 3
http.setRateLimitOptions({ maxRequests: 6, perMilliseconds: 150 }) // same options as constructor

Alternatives

Consider using Axios built-in rate-limiting functionality.

@musicplayce/sdkcall-of-duty-api-es6@infinitebrahmanuniverse/nolb-axi@media-fetch-project/animecharactersdatabase-source@media-fetch-project/dev-lib@media-fetch-project/mangadex-source@everything-registry/sub-chunk-1196dr-snap-in-utilstest-dusame-plugin-brightpearlstoryblokerstoryblok-nextjs-bolerplate-clistoryblok-nextjs-helpers-components@code.store/arcxp-sdk-tstmdb-info-reacttooter@burro/get@1xtr/apiapi1login@abyss-project/monitor@bolt-app/gatsby-source-wordpress-experimental@boundlessdigital/meraki-sdk@devrev-grow/snap-in-utils@devrev-grow/snap-in-utils-latest@devrev-growth/snap-in-utils@danny-jin/fetch-nftyookassa-sdkwebwalker-xts4dev@filum-ai/platform-apps-ui@filum-ai/utilities@feedzai/repo-analyzer@edesofthub/apis@edesofthub1/apis@fnmain/lark@fck-foundation/ton@ftw-cloud/cod-mw-api@inspex/poctous@lleewwiiss/safe-cex@ldhertert/harness-cli@lpgroup/feathers-utils@lexiang/mystique-shared@itfin/bridge@itfin/community-apps@itfin/finance-providers@itfin/rest@itfin/tracking-providers@intercroneswap/java-tron-provider@luxwallet/lux-api@luxfi/lux-api@magecom/gatsby-source-wordpress-experimental-fork-media-items-fix@miaz/poisun@mvp-rockets/namma-external-wrapper@musicplayce/intercom-ts@musicplayce/ts-sdk@marshallofsound/call-of-duty-api@easylayer/core@keepkey/market-service@jorsek/ezd-client@jorsek/content-portal-configs@kgs-research/utils@kaguya-anime/parsers@progital/gatsby-source-wordpress-experimental@rabby-wallet/rabby-api@rixw/strapi-client@phmu/gatsby-source-wordpress-experimental@pixel-point/gatsby-source-wordpress@pixel-point/gatsby-source-wordpress-experimental@pkorsholm/medusa-plugin-brightpearl@pendle/sdk-v2@sincronia/core@silencerweb/gatsby-source-wordpress-experimental@sectester/bus@sectester/core@secbox/repeater@secbox/reporter@secbox/scan@sec-tester/bus@sec-tester/repeater@sec-tester/reporter@sec-tester/scan@secbox/bus@robotevents/client@ronmu/axios@shapeshiftoss/market-servicemkto-managerminervaai-sdkosm2pdfoparl-sdkone-cexrosiebotsec-data-fetchersafe-cexnode-red-contrib-shellynode-twstocknodesubpgx-sdkreconcilergacidentify-media-react-dropigdb-ts
1.3.3

11 months ago

1.3.2

11 months ago

1.4.0

11 months ago

1.3.1

12 months ago

1.3.0

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago