FetchNode Python & Django SDK
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
Version 0.5.1 adds error triage, performance bottlenecks, and SEO optimization to the Model Context Protocol (MCP) server. See the SDK changelog for changes and upgrade instructions.
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
import os
FETCHNODE = {
"API_KEY": os.environ.get("FETCHNODE_API_KEY", ""),
"API_URL": "https://fetch-node.com/api/events/ingest/",
"ENVIRONMENT": "production", # e.g. "production", "staging"
}
Set FETCHNODE_API_KEY to your private server key in the deployment environment. Keep it out of source control and browser code. Restart or redeploy Django, then verify a request and test error in FetchNode.
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 private server key from project settings. Never use a public browser key here. |
ENDPOINT / API_URL |
FETCHNODE_ENDPOINT |
https://fetch-node.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={"source": "contact_form"},
conversion={"display_name": "Lead submitted", "funnel_order": 1, "primary": 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,
},
},
}
Model Context Protocol (MCP) for AI Agents
FetchNode includes a native Model Context Protocol (MCP) server. When pair programming or maintaining websites with AI agents (Claude Desktop, Cursor, Windsurf, Cline, or Python agents), your agents can query live Google Search Console rankings and technical error health directly:
python manage.py fetchnode_mcp --setup
This single command configures your editor agent and automatically documents the available tools in AGENTS.md / CLAUDE.md.
Available MCP Tools
get_seo_overview: Organic clicks, search views, CTR, average position, and period changes.get_keyword_opportunities: High-potential striking-distance queries (positions 4–20), low-CTR terms, and zero-click keywords.get_page_performance: Landing page traffic, conversions, conversion rate, and driving queries.get_declining_pages: Landing pages and search queries losing organic Google clicks.get_technical_seo_health: Open 500 server errors and 404s affecting landing paths.
In-Code Python Usage
You can also query MCP tools directly in Python (e.g. within Celery tasks, LangChain, CrewAI, or autonomous scripts):
from fetchnode.mcp import get_seo_overview, get_keyword_opportunities
overview = get_seo_overview(period_days=28)
opportunities = get_keyword_opportunities(category="striking_distance")
Privacy & Security Defaults
FetchNode is engineered with a strict privacy-first architecture:
- Client-side Scrubbing: Sensitive keys (
password,token,secret,api_key,authorization,cookie,csrfmiddlewaretoken) and any compound keys likeuser_passwordorclient_secretare scrubbed before payload transmission. - Safe SQL Normalization: Raw SQL text is stripped of literals and parameters (
SELECT * FROM user WHERE id = 123becomesSELECT * FROM user WHERE id = ?). - No Unintentional PII: Request bodies, query strings, and raw IP addresses are excluded by default.
- 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
Links & Resources
- Website & Cloud App: fetchnode.com
- Documentation & Setup Guide: fetchnode.com/guide/
- Changelog: fetchnode.com/changelog/
- GitHub Repository: github.com/remcovanwijk040/fetchnode
- Issue Tracker: github.com/remcovanwijk040/fetchnode/issues
License
MIT License. See LICENSE for details.
SDK changelog
0.5.1 — 2026-10-16
Added
- Error management MCP tools:
list_errors,get_error_details,resolve_error, andignore_error(with feedback and snooze support). - Performance bottleneck analysis MCP tool:
get_performance_bottlenecksanalyzing p95 latency, DB overhead %, N+1 query patterns, and actionable Django recommendations. - Actionable SEO advice MCP tool:
get_seo_optimization_adviceproviding prioritized actions for striking-distance keywords, CTR optimization, and declining pages. - Standard MCP resources and prompts for error triage, performance bottlenecks, and SEO audits.
- Python SDK helpers in
fetchnode.mcp.
Upgrade
python -m pip install --upgrade fetchnode==0.5.1
0.5.0 — 2026-10-16
Added
- Model Context Protocol (MCP) support for AI coding agents (Cursor, Windsurf, Claude Desktop, Cline).
- Django management command
python manage.py fetchnode_mcpwith--setup [all|cursor|windsurf|cline|claude],--print-config,--remote, and--status/--test. - Automatic guideline documentation injection into repository agent prompt files (
AGENTS.md,CLAUDE.md,.cursorrules). - Direct Python SDK helper functions in
fetchnode.mcpandfetchnode_client.mcp(get_seo_overview,get_keyword_opportunities,get_page_performance,get_declining_pages,get_technical_seo_health). - Stdio-to-remote JSON-RPC runner (
fetchnode.mcp.run_stdio_server).
Upgrade
python -m pip install --upgrade fetchnode==0.5.0
0.4.3 — 2026-09-29
Fixed
- Use
https://fetch-node.com/api/events/ingest/as the default ingest endpoint. - Let Django automatically discover the SDK AppConfig when
fetchnodeis inINSTALLED_APPS, so startup installs logging and enabled instrumentation. - Preserve automatic AppConfig discovery for the legacy
fetchnode_clientname. - Correct the documentation URLs to the active FetchNode website.
Documentation
- Configure the private server key through
FETCHNODE_API_KEYand supply an explicit ingest URL. Keep private keys out of browser code and source control. - Show explicit server conversion declarations and non-personal event properties.
- Verify reception after restarting or redeploying Django.
Release checks
- Test the installed wheel outside the repository, including Django AppConfig and automatic logging setup.
- Exercise requests, exceptions, error logs and idempotent conversions against a local FetchNode collector, with project isolation checks.
- Check distribution metadata and the release tag before uploading to PyPI.
Upgrade
python -m pip install --upgrade fetchnode==0.4.3
Update your dependency file or lockfile, restart or redeploy Django, and verify a
request and test error in FetchNode. Existing installations can set API_URL
explicitly if they use their own collector.
Metadata
Release files for fetchnode 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fetchnode-0.5.1.tar.gz | 36.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fetchnode-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.8 kB
Release files / fetchnode-0.5.1.tar.gz
| Download URL | fetchnode-0.5.1.tar.gz |
|---|---|
| Size | 36.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83b1adc63cf5b45bc434bd200da323661183059a71875ed643f53d6aa127dc77
|
|
BLAKE2b-256 checksum How to use checksums |
b38e928c4cab4d6efdabea842fb23d7d011f6fabb42dea648cdce49daf90395f
|
| 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.5.1-py3-none-any.whl
| Download URL | fetchnode-0.5.1-py3-none-any.whl |
|---|---|
| Size | 47.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6989628006f47f42c9f6db8692eeaf69ad808a745ed47adf9262b4503b309f0
|
|
BLAKE2b-256 checksum How to use checksums |
d2c92e80262d56fae2b8f331298e7763fb1ecf15b0d6fa6f5e1c5e1093d419a0
|
| 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.5.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.