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 Distribution

lxcor_kotta-0.1.2.tar.gz (23.5 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.2-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lxcor_kotta-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ba67bc0459b73219636bf1a9c2b612f0347e212d4c5c69d647f2ab96bee37280
MD5 302a26be5f0a65fed9d1ad09055d3c61
BLAKE2b-256 1aa315accac8d2c755ecadf7720a719e18b8618774f3a2ec21ede3ae2ac0ea78

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lxcor_kotta-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93c72b479c53c166ea4a45d322929fe5e25c6e0d7c157ee8ed401007f9faa3ef
MD5 905dfb8ff32d4f2d546a263046bd1eee
BLAKE2b-256 ec6e498c7f11a44a7a517ea40d75991177a2b32e403e8e13b1134b47fdecfb48

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