{"id":9799727,"url":"https://github.com/upstash/ratelimit-js","last_synced_at":"2025-05-14T09:12:05.036Z","repository":{"id":39883618,"uuid":"483551930","full_name":"upstash/ratelimit-js","owner":"upstash","description":"Rate limiting library for serverless runtimes","archived":false,"fork":false,"pushed_at":"2025-01-24T10:10:59.000Z","size":1085,"stargazers_count":1858,"open_issues_count":4,"forks_count":41,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-11T16:33:45.774Z","etag":null,"topics":["rate-limiting","redis","serverless","upstash","upstash-ratelimit","upstash-sdk"],"latest_commit_sha":null,"homepage":"https://ratelimit-with-upstash.vercel.app/","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/upstash.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":"2022-04-20T07:29:46.000Z","updated_at":"2025-04-11T03:25:29.000Z","dependencies_parsed_at":"2022-08-11T17:40:09.832Z","dependency_job_id":"260ecda4-e7cd-4440-9654-75ef85fa8ba7","html_url":"https://github.com/upstash/ratelimit-js","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":0.09230769230769231,"last_synced_commit":"a8394c773a1e01dc87852f17c61cacbe94e4eb06"},"previous_names":["upstash/ratelimit-js","upstash/ratelimit"],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fratelimit-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fratelimit-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fratelimit-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fratelimit-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upstash","download_url":"https://codeload.github.com/upstash/ratelimit-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248889717,"owners_count":21178283,"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":["rate-limiting","redis","serverless","upstash","upstash-ratelimit","upstash-sdk"],"created_at":"2024-05-17T15:02:21.412Z","updated_at":"2025-04-14T13:39:34.826Z","avatar_url":"https://github.com/upstash.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Upstash Rate Limit\n\n[![npm (scoped)](https://img.shields.io/npm/v/@upstash/ratelimit)](https://www.npmjs.com/package/@upstash/ratelimit)\n[![Tests](https://github.com/upstash/ratelimit/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/ratelimit/actions/workflows/tests.yaml)\n\n\u003e [!NOTE]\n\u003e  **This project is in GA Stage.**\n\u003e The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes. The Upstash team is committed to maintaining and improving its functionality.\n\nIt is the only connectionless (HTTP based) rate limiting library and designed\nfor:\n\n- Serverless functions (AWS Lambda, Vercel ....)\n- Cloudflare Workers \u0026 Pages\n- Vercel Edge\n- Fastly Compute@Edge\n- Next.js, Jamstack ...\n- Client side web/mobile applications\n- WebAssembly\n- and other environments where HTTP is preferred over TCP.\n\n## Quick Start\n\n### Install\n\n#### npm\n\n```bash\nnpm install @upstash/ratelimit\n```\n\n#### Deno\n\n```ts\nimport { Ratelimit } from \"https://cdn.skypack.dev/@upstash/ratelimit@latest\";\n```\n\n### Create database\n\nCreate a new redis database on [upstash](https://console.upstash.com/). See [here](https://github.com/upstash/upstash-redis#quick-start) for documentation on how to create a redis instance.\n\n### Basic Usage\n\n```ts\nimport { Ratelimit } from \"@upstash/ratelimit\"; // for deno: see above\nimport { Redis } from \"@upstash/redis\"; // see below for cloudflare and fastly adapters\n\n// Create a new ratelimiter, that allows 10 requests per 10 seconds\nconst ratelimit = new Ratelimit({\n  redis: Redis.fromEnv(),\n  limiter: Ratelimit.slidingWindow(10, \"10 s\"),\n  analytics: true,\n  /**\n   * Optional prefix for the keys used in redis. This is useful if you want to share a redis\n   * instance with other applications and want to avoid key collisions. The default prefix is\n   * \"@upstash/ratelimit\"\n   */\n  prefix: \"@upstash/ratelimit\",\n});\n\n// Use a constant string to limit all requests with a single ratelimit\n// Or use a userID, apiKey or ip address for individual limits.\nconst identifier = \"api\";\nconst { success } = await ratelimit.limit(identifier);\n\nif (!success) {\n  return \"Unable to process at this time\";\n}\ndoExpensiveCalculation();\nreturn \"Here you go!\";\n```\n\nFor more information on getting started, you can refer to [our documentation](https://upstash.com/docs/oss/sdks/ts/ratelimit/gettingstarted).\n\n[Here's a complete nextjs example](https://github.com/upstash/ratelimit/tree/main/examples/nextjs)\n\n## Documentation\n\nSee [the documentation](https://upstash.com/docs/redis/sdks/ratelimit-ts/overview) for more information details about this package.\n\n## Contributing\n\n### Database\n\nCreate a new redis database on [upstash](https://console.upstash.com/) and copy\nthe url and token.\n\n### Running tests\n\nTo run the tests, you will need to set some environment variables. Here is a list of\nvariables to set:\n- `UPSTASH_REDIS_REST_URL`\n- `UPSTASH_REDIS_REST_TOKEN`\n- `US1_UPSTASH_REDIS_REST_URL`\n- `US1_UPSTASH_REDIS_REST_TOKEN`\n- `APN_UPSTASH_REDIS_REST_URL`\n- `APN_UPSTASH_REDIS_REST_TOKEN`\n- `EU2_UPSTASH_REDIS_REST_URL`\n- `EU2_UPSTASH_REDIS_REST_TOKEN`\n\nYou can create a single Upstash Redis and use its URL and token for all four above.\n\nOnce you set the environment variables, simply run:\n```sh\npnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstash%2Fratelimit-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupstash%2Fratelimit-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstash%2Fratelimit-js/lists"}