Skip to main content

FetchNode Python & Django SDK

PyPI version Python Versions Django Versions License: MIT Typing: Typed

Official Python and Django client SDK for FetchNode — the focused operations workspace for developers and teams managing multiple production Django websites.

FetchNode captures unhandled exceptions, error logs, slow database queries, N+1 query patterns, Celery background tasks, and authoritative business conversions with zero bloat and privacy-safe defaults.


Table of Contents


Installation

Install via pip:

pip install fetchnode

Or using uv:

uv add fetchnode

(For Celery support, you can optionally install fetchnode[celery])


Quickstart (Django)

1. Add to INSTALLED_APPS

In your Django settings.py:

INSTALLED_APPS = [
    # ...
    "fetchnode",
]

2. Add the Middleware

Add FetchNodeMiddleware near the top of your MIDDLEWARE list for comprehensive request, query, and exception coverage:

MIDDLEWARE = [
    "fetchnode.middleware.FetchNodeMiddleware",
    "django.middleware.security.SecurityMiddleware",
    # ...
]

3. Configure settings.FETCHNODE

FETCHNODE = {
    "API_KEY": "fn_live_your_project_key_here",
    "ENVIRONMENT": "production",  # e.g. "production", "staging"
}

That's it! Django will automatically initialize FetchNode upon startup and capture unhandled exceptions, slow queries, and request telemetry.


Configuration Options

Configure via settings.FETCHNODE or environment variables:

Setting Key Environment Variable Default Description
API_KEY FETCHNODE_API_KEY "" Required. Your FetchNode project key (starts with fn_live_ or fn_test_).
ENDPOINT / API_URL FETCHNODE_ENDPOINT https://monitor.fetchnode.com/api/events/ingest/ Processing server URL. Point to your self-hosted instance if applicable.
ENVIRONMENT FETCHNODE_ENVIRONMENT "development" Active environment name ("production", "staging").
RELEASE FETCHNODE_RELEASE "" Release tag or git commit hash (e.g. git rev-parse HEAD).
ENABLED FETCHNODE_ENABLED True if API_KEY present Master toggle for event sending.
CAPTURE_TRANSACTIONS — True Track request duration and database query counts.
CAPTURE_BODY — False Privacy safeguard: request bodies are excluded by default.
CAPTURE_HEADERS — False Privacy safeguard: request headers are excluded by default.
QUERY_SLOW_THRESHOLD_MS — 100 Minimum execution time (ms) to flag an ORM query as slow.
N_PLUS_ONE_THRESHOLD — 5 Identical SELECT query repetition threshold to flag N+1 issues.
SENSITIVE_KEYS — (built-in list) Extra field names to scrub from payloads (additive).

Telemetry & Usage

Conversion & Lead Tracking

Track authoritative business events server-side (form submissions, payments, lead captures) with automatic session and visitor cookie attribution:

import fetchnode

def contact_view(request):
    form = ContactForm(request.POST)
    if form.is_valid():
        lead = form.save()

        # Track authoritative conversion
        fetchnode.track(
            "lead_submitted",
            request=request,
            idempotency_key=f"lead:{lead.id}",
            properties={"email": lead.email},
            conversion=True,
        )
        return redirect("thank_you")

Why idempotency_key matters: Providing an idempotency_key (such as the database record ID or payment provider ID) ensures that retried requests, webhook replays, or browser reloads do not inflate your conversion metrics. FetchNode securely hashes the key client-side to produce a deterministic event ID.

Automatic Error Monitoring

Unhandled exceptions in Django views are caught by FetchNodeMiddleware, decorated with:

  • The exact failing line of code and stack trace.
  • In-app vs. framework/library frame classification.
  • Database query count and execution time during the failing request.
  • Correlated request ID and trace ID.

Manual Exception Capture

Capture handled exceptions or background exceptions:

import fetchnode

try:
    external_service_call()
except ThirdPartyAPIError as exc:
    fetchnode.capture_exception(exc, tags={"provider": "stripe"})

Celery Job Monitoring

FetchNode automatically instruments Celery when installed. You can also explicitly decorate tasks:

from fetchnode import capture_job

@capture_job(name="sync_external_inventory")
def sync_inventory():
    ...

Logging Handler

Send standard logging.ERROR and logging.CRITICAL records to FetchNode:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {
        "fetchnode": {
            "level": "ERROR",
            "class": "fetchnode.handlers.FetchNodeHandler",
        },
    },
    "loggers": {
        "django": {
            "handlers": ["fetchnode"],
            "level": "ERROR",
            "propagate": True,
        },
    },
}

Privacy & Security Defaults

FetchNode is engineered with a strict privacy-first architecture:

  1. Client-side Scrubbing: Sensitive keys (password, token, secret, api_key, authorization, cookie, csrfmiddlewaretoken) and any compound keys like user_password or client_secret are scrubbed before payload transmission.
  2. Safe SQL Normalization: Raw SQL text is stripped of literals and parameters (SELECT * FROM user WHERE id = 123 becomes SELECT * FROM user WHERE id = ?).
  3. No Unintentional PII: Request bodies, query strings, and raw IP addresses are excluded by default.
  4. Inspectable & Lightweight: The entire client is open-source Python with zero compiled binaries and zero unnecessary dependencies.

Testing in Development

In your local test suite (e.g. pytest or python manage.py test), FetchNode can be disabled by omitting the API key or explicitly setting:

# settings_test.py
FETCHNODE = {
    "ENABLED": False,
}

To test that event transmission works in your staging environment, run:

import fetchnode
fetchnode.capture_message("FetchNode verification ping", level="info")
fetchnode.flush()

Compatibility

  • Python: 3.10, 3.11, 3.12, 3.13, 3.14
  • Django: 4.2 LTS, 5.0, 5.1, 5.2
  • Operating Systems: Linux, macOS, Windows


License

MIT License. See LICENSE for details.

Metadata

Release files for fetchnode 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fetchnode 0.4.1
File Size Uploaded Provenance
fetchnode-0.4.1.tar.gz 21.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fetchnode 0.4.1
File Interpreter ABI Platform
fetchnode-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 52.2 kB

Release files / fetchnode-0.4.1.tar.gz

Download URL fetchnode-0.4.1.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
11cdd3bb43b35235f6e0378335f407b124dbf81d782ad4be73e91bb44c68fd05
BLAKE2b-256 checksum
How to use checksums
58ee5baa2a5b6aa9452be43754ed62122653d0083bc5a02d28498e699e8e6f4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / fetchnode-0.4.1-py3-none-any.whl

Download URL fetchnode-0.4.1-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6ed6d96899c3bd34ce3f3fec719df345c675b0b8b1aa787e05590088e5bbb73
BLAKE2b-256 checksum
How to use checksums
daae707401b190f4c2fe2e0fcf0f914b91e00a93bb0c8f5133c08f318d331c2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for fetchnode 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page