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
dumpconfig Export tier and endpoint config to JSON
loadconfig Import tier and endpoint config from JSON

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lxcor_kotta-0.1.1-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lxcor_kotta-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for lxcor_kotta-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 967d85952df0ffe2c2317bffdefa1b91bf696141d76422050ca2712e14e82f72
MD5 68fc3692494b79d5a3e3e4ee92f86bc2
BLAKE2b-256 3c4620eb4255f81f5a22155b288c0212960b895127a77fa299bc170279fae388

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