{"id":16698072,"url":"https://github.com/arlac77/fetch-rate-limit-util","last_synced_at":"2025-03-21T19:32:28.939Z","repository":{"id":37792871,"uuid":"293444035","full_name":"arlac77/fetch-rate-limit-util","owner":"arlac77","description":"handle fetch rate limits","archived":false,"fork":false,"pushed_at":"2025-03-15T11:00:49.000Z","size":3211,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T12:18:28.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arlac77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-07T06:42:00.000Z","updated_at":"2025-03-15T11:00:51.000Z","dependencies_parsed_at":"2023-10-16T12:11:16.954Z","dependency_job_id":"adc15d7a-8ff5-446e-9a2f-c36dcbc0c400","html_url":"https://github.com/arlac77/fetch-rate-limit-util","commit_stats":{"total_commits":640,"total_committers":4,"mean_commits":160.0,"dds":"0.18593749999999998","last_synced_commit":"ee31647a2f81c9b47cdf3c08ae1a3ce26bd99fb5"},"previous_names":[],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Ffetch-rate-limit-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Ffetch-rate-limit-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Ffetch-rate-limit-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Ffetch-rate-limit-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arlac77","download_url":"https://codeload.github.com/arlac77/fetch-rate-limit-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244153550,"owners_count":20407002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T17:50:38.666Z","updated_at":"2025-03-21T19:32:28.912Z","avatar_url":"https://github.com/arlac77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/fetch-rate-limit-util.svg)](https://www.npmjs.com/package/fetch-rate-limit-util)\n[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)\n[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\\\u0026label\\\u0026labelColor=blue\\\u0026color=555555)](https://typescriptlang.org)\n[![bundlejs](https://deno.bundlejs.com/?q=fetch-rate-limit-util\\\u0026badge=detailed)](https://bundlejs.com/?q=fetch-rate-limit-util)\n[![downloads](http://img.shields.io/npm/dm/fetch-rate-limit-util.svg?style=flat-square)](https://npmjs.org/package/fetch-rate-limit-util)\n[![GitHub Issues](https://img.shields.io/github/issues/arlac77/fetch-rate-limit-util.svg?style=flat-square)](https://github.com/arlac77/fetch-rate-limit-util/issues)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Ffetch-rate-limit-util%2Fbadge\\\u0026style=flat)](https://actions-badge.atrox.dev/arlac77/fetch-rate-limit-util/goto)\n[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/fetch-rate-limit-util/badge.svg)](https://snyk.io/test/github/arlac77/fetch-rate-limit-util)\n[![Coverage Status](https://coveralls.io/repos/arlac77/fetch-rate-limit-util/badge.svg)](https://coveralls.io/github/arlac77/fetch-rate-limit-util)\n\n# fetch-rate-limit-util\n\nHandle fetch errors and rate limits and caching.\n\nWaits and retry after rate limit rest time has reached.\n\n*   [auth0 API](https://auth0.com/docs/policies/rate-limit-policy)\n*   [github API](https://developer.github.com/v3/#rate-limiting)\n*   [Zalando API](https://opensource.zalando.com/restful-api-guidelines/#153)\n*   [Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After)\n\n```js\nimport { stateActionHandler } from \"fetch-rate-limit-util\";\n\nconst response = await stateActionHandler(someURL, options);\n\n// if rate limit occurs waits and retires\n\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [HandlerResult](#handlerresult)\n    *   [Properties](#properties)\n*   [RequestReporter](#requestreporter)\n    *   [Properties](#properties-1)\n*   [wait](#wait)\n    *   [Parameters](#parameters)\n*   [stateActionHandler](#stateactionhandler)\n    *   [Parameters](#parameters-1)\n*   [calculateRepeatAfter](#calculaterepeatafter)\n    *   [Parameters](#parameters-2)\n*   [rateLimitHandler](#ratelimithandler)\n    *   [Parameters](#parameters-3)\n*   [retryTimes](#retrytimes)\n*   [retryHandler](#retryhandler)\n    *   [Parameters](#parameters-4)\n*   [redirectHandler](#redirecthandler)\n    *   [Parameters](#parameters-5)\n*   [defaultHandler](#defaulthandler)\n    *   [Parameters](#parameters-6)\n*   [errorHandler](#errorhandler)\n    *   [Parameters](#parameters-7)\n*   [cacheHandler](#cachehandler)\n    *   [Parameters](#parameters-8)\n*   [DEFAULT\\_MIN\\_WAIT\\_MSECS](#default_min_wait_msecs)\n*   [DEFAULT\\_MAX\\_RETRIES](#default_max_retries)\n*   [defaultOptions](#defaultoptions)\n\n## HandlerResult\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** what to fetch next\n*   `repeatAfter` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** of milliseconds to wait befor next try\n*   `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** to report\n*   `done` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** op is finished return\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)**\u0026#x20;\n*   `postprocess` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** exec postprocess\n\n## RequestReporter\n\nFunction to provide progress report.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n### Properties\n\n*   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** to be requested\n*   `method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** http method name\n*   `status` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error))** result of the last request\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** how often have we retried\n\n## wait\n\n### Parameters\n\n*   `url` **([URL](https://developer.mozilla.org/docs/Web/API/URL/URL) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**\u0026#x20;\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `result` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n## stateActionHandler\n\nExecutes fetch operation and handles response.\n\n### Parameters\n\n*   `url` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [URL](https://developer.mozilla.org/docs/Web/API/URL/URL))**\u0026#x20;\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n    *   `options.reporter` **[RequestReporter](#requestreporter)**\u0026#x20;\n    *   `options.cache` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**\u0026#x20;\n    *   `options.maxRetries` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\u0026#x20;\n    *   `options.method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\u0026#x20;\n    *   `options.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**\u0026#x20;\n    *   `options.body` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\u0026#x20;\n    *   `options.postprocess` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**\u0026#x20;\n    *   `options.stateActions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003c[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)\u003e** from fetch\n\n## calculateRepeatAfter\n\n### Parameters\n\n*   `response` **any**\u0026#x20;\n\nReturns **([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** msecs to wait\n\n## rateLimitHandler\n\n*   **See**: \u003chttps://auth0.com/docs/policies/rate-limit-policy\u003e\n*   **See**: \u003chttps://developer.github.com/v3/#rate-limiting\u003e\n*   **See**: \u003chttps://opensource.zalando.com/restful-api-guidelines/#153\u003e\n\nWaits and retries after rate limit reset time has reached.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[HandlerResult](#handlerresult)**\u0026#x20;\n\n## retryTimes\n\nRetry timeouts with\nincreasing delay for each retry.\nValues in msecs.\n\n## retryHandler\n\nTry several times with a increasing delay.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[HandlerResult](#handlerresult)**\u0026#x20;\n\n## redirectHandler\n\nRedirect to given header location.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[HandlerResult](#handlerresult)**\u0026#x20;\n\n## defaultHandler\n\nPostprocessing if response is ok.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[HandlerResult](#handlerresult)**\u0026#x20;\n\n## errorHandler\n\nNo postprocessing.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[HandlerResult](#handlerresult)**\u0026#x20;\n\n## cacheHandler\n\nProvide cached data.\n\n### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** from fetch\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n*   `nthTry` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003c[HandlerResult](#handlerresult)\u003e**\u0026#x20;\n\n## DEFAULT\\_MIN\\_WAIT\\_MSECS\n\nMinimum wait time in msecs.\n\nType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\n\n## DEFAULT\\_MAX\\_RETRIES\n\nMax # of retries.\n\nType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\n\n## defaultOptions\n\nDefault options\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```shell\nnpm install fetch-rate-limit-util\n```\n\n# license\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Ffetch-rate-limit-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farlac77%2Ffetch-rate-limit-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Ffetch-rate-limit-util/lists"}