{"id":38171363,"url":"https://github.com/zeroae/zae-limiter","last_synced_at":"2026-02-23T04:00:51.633Z","repository":{"id":331547950,"uuid":"1131427733","full_name":"zeroae/zae-limiter","owner":"zeroae","description":"Token bucket rate limiter backed by DynamoDB","archived":false,"fork":false,"pushed_at":"2026-02-15T01:39:32.000Z","size":13594,"stargazers_count":0,"open_issues_count":66,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-15T01:40:21.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://zeroae.github.io/zae-limiter/","language":"Python","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/zeroae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing/architecture.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-10T01:56:31.000Z","updated_at":"2026-02-15T01:13:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zeroae/zae-limiter","commit_stats":null,"previous_names":["zeroae/zae-limiter"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/zeroae/zae-limiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroae%2Fzae-limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroae%2Fzae-limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroae%2Fzae-limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroae%2Fzae-limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeroae","download_url":"https://codeload.github.com/zeroae/zae-limiter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroae%2Fzae-limiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29736978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T02:24:00.660Z","status":"ssl_error","status_checked_at":"2026-02-23T02:22:56.087Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-16T23:27:07.443Z","updated_at":"2026-02-23T04:00:51.628Z","avatar_url":"https://github.com/zeroae.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/zeroae/zae-limiter/main/docs/assets/zae-limiter-dark-bg.svg\"\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/zeroae/zae-limiter/main/docs/assets/zae-limiter-white-bg.svg\"\u003e\n    \u003cimg alt=\"zae-limiter\" src=\"https://raw.githubusercontent.com/zeroae/zae-limiter/main/docs/assets/zae-limiter-white-bg.svg\" width=\"50%\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n[![PyPI version](https://img.shields.io/pypi/v/zae-limiter?style=flat-square)](https://pypi.org/project/zae-limiter/)\n[![Conda version](https://img.shields.io/conda/v/conda-forge/zae-limiter?style=flat-square)](https://anaconda.org/conda-forge/zae-limiter)\n[![Python versions](https://img.shields.io/pypi/pyversions/zae-limiter?style=flat-square)](https://pypi.org/project/zae-limiter/)\n[![License](https://img.shields.io/pypi/l/zae-limiter?style=flat-square)](https://github.com/zeroae/zae-limiter/blob/main/LICENSE)\n[![Lint](https://img.shields.io/github/actions/workflow/status/zeroae/zae-limiter/ci-lint.yml?branch=main\u0026style=flat-square\u0026label=lint)](https://github.com/zeroae/zae-limiter/actions/workflows/ci-lint.yml)\n[![Tests](https://img.shields.io/github/actions/workflow/status/zeroae/zae-limiter/ci-tests.yml?branch=main\u0026style=flat-square\u0026label=tests)](https://github.com/zeroae/zae-limiter/actions/workflows/ci-tests.yml)\n[![codecov](https://img.shields.io/codecov/c/github/zeroae/zae-limiter?style=flat-square)](https://codecov.io/gh/zeroae/zae-limiter)\n[![Docs](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://zeroae.github.io/zae-limiter/)\n\nA rate limiting library backed by DynamoDB using the token bucket algorithm.\n\n## Installation\n\n```bash\npip install zae-limiter\n# or\nconda install -c conda-forge zae-limiter\n```\n\n## Usage\n\n```python\nfrom zae_limiter import Repository, RateLimiter, SyncRepository, SyncRateLimiter, Limit\n\n# Auto-provisions infrastructure if needed\nrepo = await Repository.open()\nlimiter = RateLimiter(repository=repo)\n\n# Sync\nsync_repo = SyncRepository.open()\nsync_limiter = SyncRateLimiter(repository=sync_repo)\n\n# Define default limits (can be overridden per-entity)\ndefault_limits = [\n    Limit.per_minute(\"rpm\", 100),\n    Limit.per_minute(\"tpm\", 10_000),\n]\n\nasync with limiter.acquire(\n    entity_id=\"api-key-123\",\n    resource=\"gpt-4\",\n    limits=default_limits,  # Multiple limits in a single atomic transaction\n    consume={\"rpm\": 1, \"tpm\": 500},  # Estimate tokens upfront\n) as lease:\n    response = await call_llm()\n    # Reconcile actual usage (can go negative for post-hoc adjustment)\n    await lease.adjust(tpm=response.usage.total_tokens - 500)\n    # Tokens written to DynamoDB on enter | Rolled back on exception\n\n# Hierarchical entities: create project with stored limits, then API key under it\nawait limiter.create_entity(entity_id=\"proj-1\", name=\"Production\")\nawait limiter.set_limits(\"proj-1\", [Limit.per_minute(\"tpm\", 100_000)])  # Project-level\nawait limiter.create_entity(entity_id=\"api-key-456\", parent_id=\"proj-1\", cascade=True)\n\n# cascade is an entity property — acquire() auto-cascades to parent\nwith sync_limiter.acquire(\n    entity_id=\"api-key-456\",\n    resource=\"gpt-4\",\n    limits=default_limits,\n    consume={\"rpm\": 1, \"tpm\": 500},\n):\n    call_api()\n\n# Multi-tenant: each tenant gets an isolated namespace\ntenant_repo = await Repository.open(\"tenant-alpha\")\ntenant_limiter = RateLimiter(repository=tenant_repo)\n\n# Cleanup (removes all data)\nawait repo.delete_stack()\n```\n\n## Documentation\n\n**[Full Documentation](https://zeroae.github.io/zae-limiter/)**\n\n| Guide | Description |\n|-------|-------------|\n| [Getting Started](https://zeroae.github.io/zae-limiter/getting-started/) | Installation, first deployment |\n| [Basic Usage](https://zeroae.github.io/zae-limiter/guide/basic-usage/) | Rate limiting patterns, error handling |\n| [Hierarchical Limits](https://zeroae.github.io/zae-limiter/guide/hierarchical/) | Parent/child entities, cascade mode |\n| [LLM Integration](https://zeroae.github.io/zae-limiter/guide/llm-integration/) | Token estimation and reconciliation |\n| [CLI Reference](https://zeroae.github.io/zae-limiter/cli/) | Deploy, status, delete commands |\n| [Multi-Tenant Guide](https://zeroae.github.io/zae-limiter/infra/production/#multi-tenant-deployments) | Namespace isolation, per-tenant IAM |\n| [Production Guide](https://zeroae.github.io/zae-limiter/infra/production/) | Security, monitoring, cost |\n\n## Production Deployment\n\nThe default deployment includes CloudWatch alarms and usage aggregation. For production, add data recovery and alert routing:\n\n```bash\nzae-limiter deploy --name my-app --region us-east-1 \\\n    --pitr-recovery-days 7 \\\n    --alarm-sns-topic arn:aws:sns:us-east-1:123456789012:alerts\n```\n\nFor security best practices, multi-region considerations, and cost estimation, see the [Production Guide](https://zeroae.github.io/zae-limiter/infra/production/).\n\n## Contributing\n\n```bash\ngit clone https://github.com/zeroae/zae-limiter.git \u0026\u0026 cd zae-limiter\nuv sync --all-extras\npytest\n```\n\nSee the [Contributing Guide](https://zeroae.github.io/zae-limiter/contributing/) for development setup, testing, and architecture details.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroae%2Fzae-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeroae%2Fzae-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroae%2Fzae-limiter/lists"}