Metadata-Version: 2.4
Name: django-smart-ratelimit
Version: 2.2.0
Summary: A flexible and efficient rate limiting library for Django applications
Project-URL: Homepage, https://github.com/YasserShkeir/django-smart-ratelimit
Project-URL: Documentation, https://django-smart-ratelimit.readthedocs.io
Project-URL: Repository, https://github.com/YasserShkeir/django-smart-ratelimit
Project-URL: Issues, https://github.com/YasserShkeir/django-smart-ratelimit/issues
Project-URL: Discussions, https://github.com/YasserShkeir/django-smart-ratelimit/discussions
Project-URL: Changelog, https://github.com/YasserShkeir/django-smart-ratelimit/blob/main/CHANGELOG.md
Author-email: Yasser Shkeir <shkeiryasser@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: decorator,django,middleware,rate-limiting,redis
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.9
Requires-Dist: asgiref>=3.6.0
Requires-Dist: django>=3.2
Provides-Extra: all
Requires-Dist: hiredis>=2.0; extra == 'all'
Requires-Dist: prometheus-client>=0.14.0; extra == 'all'
Requires-Dist: pyjwt>=2.0; extra == 'all'
Requires-Dist: pymongo>=4.0; extra == 'all'
Requires-Dist: redis>=4.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: bandit>=1.7; extra == 'dev'
Requires-Dist: black>=22.0; extra == 'dev'
Requires-Dist: build>=0.8; extra == 'dev'
Requires-Dist: bump2version>=1.0; extra == 'dev'
Requires-Dist: django-stubs>=4.0; extra == 'dev'
Requires-Dist: flake8-docstrings>=1.7; extra == 'dev'
Requires-Dist: flake8>=5.0; extra == 'dev'
Requires-Dist: isort>=5.0; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pre-commit>=2.20; extra == 'dev'
Requires-Dist: pyjwt>=2.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-django>=4.5; extra == 'dev'
Requires-Dist: pytest-xdist>=3.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: safety>=2.0; extra == 'dev'
Requires-Dist: tox>=4.0; extra == 'dev'
Requires-Dist: twine>=4.0; extra == 'dev'
Requires-Dist: types-redis>=4.0; extra == 'dev'
Provides-Extra: jwt
Requires-Dist: pyjwt>=2.0; extra == 'jwt'
Provides-Extra: mongodb
Requires-Dist: pymongo>=4.0; extra == 'mongodb'
Provides-Extra: prometheus
Requires-Dist: prometheus-client>=0.14.0; extra == 'prometheus'
Provides-Extra: redis
Requires-Dist: hiredis>=2.0; extra == 'redis'
Requires-Dist: redis>=4.0; extra == 'redis'
Description-Content-Type: text/markdown

# Django Smart Ratelimit

[![CI](https://github.com/YasserShkeir/django-smart-ratelimit/workflows/CI/badge.svg)](https://github.com/YasserShkeir/django-smart-ratelimit/actions)
[![Coverage](https://img.shields.io/badge/coverage-73%25-yellow.svg)](https://github.com/YasserShkeir/django-smart-ratelimit)
[![PyPI version](https://img.shields.io/pypi/v/django-smart-ratelimit.svg)](https://pypi.org/project/django-smart-ratelimit/)
[![Downloads](https://img.shields.io/pypi/dm/django-smart-ratelimit.svg)](https://pypi.org/project/django-smart-ratelimit/)
[![License](https://img.shields.io/pypi/l/django-smart-ratelimit.svg)](https://github.com/YasserShkeir/django-smart-ratelimit/blob/main/LICENSE)

> **The checkmate for abusive traffic.**
>
> A high-performance, stateless rate limiting library for Django that protects your API from abuse, optimized for distributed systems with atomic Redis operations and circuit breaking.

## Sponsors

Support the ongoing development of Django Smart Ratelimit!

<div align="center">
  <!-- Platinum and Gold Sponsors will appear here -->
  <p><em><a href="https://www.yasser-shkeir.com/donate">Become a sponsor</a> to see your logo here!</em></p>
</div>

## Key Features

- **🚀 Stateless & Modern**: Dual-mode support (Sync/Async) without database dependencies.
- **🛡️ Enterprise Reliability**: Built-in **Circuit Breaker** and **Automatic Failover** strategies.
- **⚡ Multiple Algorithms**: Choose between **Token Bucket**, **Sliding Window**, and **Fixed Window**.
- **🔌 Flexible Backends**: Redis (recommended), Async Redis, Memory, or Custom backends.
- **🎯 Precise Control**: Rate limit by IP, User, Header, or any custom callable.

## Quick Start

### Installation

```bash
pip install django-smart-ratelimit[redis]
```

### Usage in 30 Seconds

```python
from django_smart_ratelimit import ratelimit

@ratelimit(key='ip', rate='5/m', block=True)
def login_view(request):
    # If limit is exceeded, this code receives a 429 Too Many Requests
    return authenticate(request)
```

## Documentation

We have moved our detailed documentation to the dedicated `docs/` folder:

| Topic                                         | Description                                          |
| :-------------------------------------------- | :--------------------------------------------------- |
| **[📚 Full Documentation](docs/index.md)**    | Start here for the complete guide.                   |
| **[🚀 Migration Guide](docs/migration.md)**   | Upgrading from `django-ratelimit`? clear steps here. |
| **[🧮 Algorithms](docs/algorithms.md)**       | Deep dive into Token Buckets and Windows.            |
| **[⚙️ Configuration](docs/configuration.md)** | Advanced settings, Backends, and Circuit Breakers.   |
| **[🔍 Design Philosophy](docs/design.md)**    | Why we built this and how it compares to others.     |

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and setup your development environment.

## Community & Support

- **[GitHub Discussions](https://github.com/YasserShkeir/django-smart-ratelimit/discussions)**: Ask questions and share ideas.
- **[Issues](https://github.com/YasserShkeir/django-smart-ratelimit/issues)**: Report bugs.
- **[AI Usage Policy](AI_USAGE.md)**: Our transparency commitment.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
