Skip to main content

Django Rate limiter for Admin panel, with synchronization towards Redis. Currently supports OpenResty as a rate limit server

Project description

Django Rate Limiter

  • Tested on: Python 3.11.5
  • Django 5.2.12

![High Level Design principle of library](django-api-rate-limiter principle.png)

Start by installing the package:

pip install django-api-rate-limiter

Then add in your settings.py

INSTALLED_APPS = [
    # rest of the apps..
    'django_api_rate_limiter'
]

# you will need to configure the default cache to point to Redis 

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/1",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        }
    }
}

Navigate to your /admin page and visit section "Admin_Limiter"->"Api limiters".

There you can set up your own limits specified in "values per second". For example, you can fill up as:

Speed Value: 10 Method: Get Url: /api/limited

This translates to: For every anonymous & logged in user apply the limit of 10 requests per second for GET requests going to /api/limited

If your project is using django-oauth-toolkit, you can specify per-user limits, which are linked to the oauth tokens issued to users

Please install OpenResty if you would like to use the Lua files from "nginx_lua" folder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_api_rate_limiter-0.0.3.tar.gz (68.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_api_rate_limiter-0.0.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file django_api_rate_limiter-0.0.3.tar.gz.

File metadata

  • Download URL: django_api_rate_limiter-0.0.3.tar.gz
  • Upload date:
  • Size: 68.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_api_rate_limiter-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8f47da0ae4afe63599acd397b9c089fbac9ea6ff249503f7ebf448d5a9f4de73
MD5 c6872d19b74a65b1643c55647a582e1c
BLAKE2b-256 e37e3d496d629de069e78e5f9c42177a1690de8a311289d8885b1fbdbda0596f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_api_rate_limiter-0.0.3.tar.gz:

Publisher: python-publish.yml on FallenAngel97/django-rate-limiter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_api_rate_limiter-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_api_rate_limiter-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2400c7ae4e7a942517ed2302b72be0facc121c01d17486388939e7d79bcd7a6d
MD5 d500258fe4a0e9ff1d30ea3498428b5b
BLAKE2b-256 c19e6bcc6fafd6113029064e846419bd887e0687572fb25042043d48b973d07d

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_api_rate_limiter-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on FallenAngel97/django-rate-limiter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page