Skip to main content

Apirelio Django SDK

Native Django middleware for privacy-safe, customer-aware API analytics. The same package supports regular Django views and Django REST Framework endpoints.

pip install apirelio-django

Add the middleware after Django's authentication middleware so identity resolvers can use request.user:

# settings.py
import os

MIDDLEWARE = [
    # ...
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "apirelio_django.ApirelioMiddleware",
]

APIRELIO = {
    "API_KEY": os.environ.get("APIRELIO_API_KEY", ""),
    "ENDPOINT": os.environ.get("APIRELIO_ENDPOINT", "https://apirelio.com"),
    "SERVICE": "billing-api",
    "ENVIRONMENT": "production",
    "INCLUDE_ROUTES": ("/api/**",),
    "EXCLUDE_ROUTES": ("/api/health/", "/api/internal/**"),
    "RESOLVE_CUSTOMER": "billing.apirelio.resolve_customer",
}

Resolvers receive the completed HttpRequest and may return an Apirelio customer, application or metadata dictionary:

def resolve_customer(request):
    account = getattr(request.user, "account", None)
    if account is None:
        return None
    return {"id": str(account.id), "name": account.name, "plan": account.plan}

The middleware records the final status, duration, resolved URL pattern and DRF error code. Both synchronous and asynchronous Django handlers are supported. Events enter the bounded Python Core background queue and are flushed when the process exits. Bodies, query strings, cookies, authorization values, email addresses and client IP addresses are never captured.

Download files

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

Source Distribution

apirelio_django-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

apirelio_django-0.2.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file apirelio_django-0.2.0.tar.gz.

File metadata

  • Download URL: apirelio_django-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for apirelio_django-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bd0c41d22fd9ea14ee057d4a2c75d36820df67ec45eff3797d5a79352bf9ec68
MD5 f8bdfc6dabe08fe843a6e69bd47a39e4
BLAKE2b-256 04df4411ff83220a88712bb8d63bd1f6d12dbf0530cc1be8b747b978ef0132cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for apirelio_django-0.2.0.tar.gz:

Publisher: publish.yml on pryznar/apirelio-django

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

File details

Details for the file apirelio_django-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for apirelio_django-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75b298064c54650e46de424db5b973a9ed91580f3cf69eef36193ec8c660dc9a
MD5 bec91b5b35272e7729cb55a913836e90
BLAKE2b-256 9960e88b30342f232371b4323f9c1fe6738cfd3b6d21f0b8c3d91f716dd608d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for apirelio_django-0.2.0-py3-none-any.whl:

Publisher: publish.yml on pryznar/apirelio-django

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 Sentry Error logging StatusPage Status page