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.0.tar.gz (21.0 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.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lxcor_kotta-0.1.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for lxcor_kotta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7d4dbfd31a6b17dbf1f501a74eb801ac7a94ec80349f342a53d01b88ccbaf820
MD5 2dc25fc9f10fec5ba027e57895f0228a
BLAKE2b-256 6ce6d2a8c804d45207ddfff0721e7d3cc6922755925cc4db7484b2823de08ba6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lxcor_kotta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23b3dec7c03e93b1e5a47588bd488a5bf1a5288dfe48dee7e73c0c36017a9658
MD5 1effbb0ebb210971df3c49da99b770f2
BLAKE2b-256 9c5eb314394751be1bd37b8ee239711ba332c5655a028fe782abf66a11d4e0e0

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