Skip to main content

Throttling and quota enforcement for Django REST Framework — per-endpoint rate limits, tier-based quotas, and usage tracking.

Project description

kotta

Throttling and quota enforcement for Django REST Framework.

kotta provides per-endpoint rate limits, tier-based quotas, and usage tracking. Tiers are database-driven so limits can be changed without a deployment. Integrates with lxcor-reggi API keys for per-key tracking.

Part of the lxcor/api-suite.

Install

pip install lxcor-kotta

Setup

# settings.py
INSTALLED_APPS = [
    ...
    'reggi',  # required
    'kotta',
]

MIDDLEWARE = [
    ...
    'kotta.middleware.KottaMiddleware',
]

REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_CLASSES': [
        'kotta.throttle.AnonEndpointThrottle',
        'kotta.throttle.TierThrottle',
    ],
    'EXCEPTION_HANDLER': 'kotta.exceptions.kotta_exception_handler',
}
# urls.py
urlpatterns = [
    path('usage/', include('kotta.urls')),
]

Sync your URL patterns into the kotta endpoint registry:

python manage.py syncendpoints

Settings

Setting Default Description
KOTTA_UPGRADE_MESSAGE '' Message appended to 429 responses pointing users to upgrade

Management commands

Command Description
syncendpoints Register all URL patterns in the kotta endpoint table

License

MIT

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

lxcor_kotta-0.1.3.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

lxcor_kotta-0.1.3-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file lxcor_kotta-0.1.3.tar.gz.

File metadata

  • Download URL: lxcor_kotta-0.1.3.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lxcor_kotta-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8abb64ad1e1c941cfc3041f1f1e28fd7ce0ddd6b64956b128932f58a9233d076
MD5 b721d4963fd4d1f4cd6e0d5abec59175
BLAKE2b-256 12f03a45673ec2da8b24fabb29e23c90b923b335d306e05c164c77873d7e79d4

See more details on using hashes here.

File details

Details for the file lxcor_kotta-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: lxcor_kotta-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lxcor_kotta-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8ca271100ed44ba298d81cb209500a8ad59e0ded2c83cc7f24ca17c896dd080e
MD5 7d3ff35e7738227ffceb2d53ed10a0d7
BLAKE2b-256 ab0cec9778a2e981933cb2fa6662f5cb40e640d5f05bd98a6cb44f1eac57ec8e

See more details on using hashes here.

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