{"id":19782091,"url":"https://github.com/express-rate-limit/ratelimit-header-parser","last_synced_at":"2025-10-18T15:00:17.090Z","repository":{"id":189838840,"uuid":"681181799","full_name":"express-rate-limit/ratelimit-header-parser","owner":"express-rate-limit","description":"Parse RateLimit headers of various forms into a normalized format","archived":false,"fork":false,"pushed_at":"2023-10-31T07:20:48.000Z","size":285,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-01T23:17:58.666Z","etag":null,"topics":["api","api-client","deno","header","headers","javascript","nodejs","parser","rate-limit","rate-limiting","rest-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/express-rate-limit.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}},"created_at":"2023-08-21T12:56:41.000Z","updated_at":"2024-08-01T09:45:48.000Z","dependencies_parsed_at":"2023-08-22T02:23:52.028Z","dependency_job_id":"cbdd174d-1882-4a0a-a865-a624f0955856","html_url":"https://github.com/express-rate-limit/ratelimit-header-parser","commit_stats":null,"previous_names":["express-rate-limit/ratelimit-header-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Fratelimit-header-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Fratelimit-header-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Fratelimit-header-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Fratelimit-header-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/express-rate-limit","download_url":"https://codeload.github.com/express-rate-limit/ratelimit-header-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224182202,"owners_count":17269435,"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":["api","api-client","deno","header","headers","javascript","nodejs","parser","rate-limit","rate-limiting","rest-api"],"created_at":"2024-11-12T06:03:47.844Z","updated_at":"2025-10-18T15:00:12.029Z","avatar_url":"https://github.com/express-rate-limit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ratelimit-header-parser\n\n[![CI](https://github.com/express-rate-limit/ratelimit-header-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/express-rate-limit/ratelimit-header-parser/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/ratelimit-header-parser.svg)](https://npmjs.org/package/ratelimit-header-parser 'View this project on NPM')\n\nParse RateLimit headers of various forms into a normalized format. Supports the\ncombined form from\n[draft 7](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers-07)\nof the\n[IETF Rate Limit Headers standard](https://github.com/ietf-wg-httpapi/ratelimit-headers),\nthe uncombined `RateLimit-*` format of earlier drafts, traditional\n`X-RateLimit-*` headers, and a few other formats.\n\n## Usage:\n\n```js\nimport { parseRateLimit } from 'ratelimit-header-parser'\n\nconst response = await fetch(\n\t'https://api.github.com/repos/express-rate-limit/express-rate-limit/contributors?anon=1',\n)\n\nconsole.log('github ratelimit:', parseRateLimit(response))\n// \u003e github ratelimit: { limit: 60, used: 1, remaining: 59, reset: 2023-08-25T04:16:48.000Z }\n```\n\n## API\n\n### parseRateLimit(responseOrHeadersObject, [options]) =\u003e Object | undefined\n\nScans the input for ratelimit headers in a variety of formats and returns the\nresult in a consistent format, or undefined if it fails to find any ratelimit\nheaders.\n\n- `responseOrHeadersObject`: May be either a fetch-style Response or Headers\n  object or a node.js-style response or headers object\n- `options`: Optional object with the following optional fields:\n  - `reset`: How to parse the reset field. If unset, the parser will guess based\n    on the content. Accepts the following strings:\n    - `'date'`: past the value to `new Date(...)` to let the JavaScript engine\n      parse it\n    - `'unix'`: treat the value as the number of seconds since January 1, 1970\n      (A.K.A a unix timestamp)\n    - `'seconds'`: treat the value as the number of seconds from the current\n      time\n    - `'milliseconds'`: treat the value as the number of milliseconds from the\n      current time\n\nReturns a object with the following fields, or undefined if it does not find any\nrate-limit headers.\n\n```\n{\n\tlimit: number\n\tused: number\n\tremaining: number\n\treset: Date or undefined\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpress-rate-limit%2Fratelimit-header-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpress-rate-limit%2Fratelimit-header-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpress-rate-limit%2Fratelimit-header-parser/lists"}