Skip to main content
The Spidra Django integration (spidra-django) brings the full Spidra API into Django as a proper installed app: configure credentials in settings.py, include ready-made URL patterns in urls.py, receive webhook events as native Django Signals, and run scraping tasks from the terminal with python manage.py spidra_* management commands.

Installation

Requires Python 3.9+ and Django 4.2+.
Get your API key from app.spidra.io under API Keys. Store it in an environment variable and reference it from settings.py. Never hardcode it.

Setup

1. Add to INSTALLED_APPS

2. Configure in settings.py

Using the client

spidra-django exports a global spidra proxy that is ready to use anywhere in your project without passing configuration around:
For factory-style access — useful in tests or multi-tenant setups — use get_spidra() and get_async_spidra():

Scraping

Extract markdown or structured JSON from any URL, with browser rendering, CAPTCHA bypass, and residential proxies:
spidra_json_response() recursively serializes Spidra dataclasses and returns a JsonResponse. It accepts the same arguments as Django’s JsonResponse, including status.

Searching

Available sources: "web", "news", "images", "videos", "research", "developer". Defaults to ["web"].

Crawling

For large crawls, submit without waiting:

Mapping

Batch scraping

Parsing documents

Async views

Django 4.1+ supports native async def views. Use spidra.async_client for non-blocking calls:

Webhooks

Spidra sends signed webhook events to your endpoint. Use @spidra_webhook_required to verify HMAC-SHA256 signatures automatically:
The decorator reads SPIDRA_WEBHOOK_SECRET from settings, verifies X-Spidra-Signature against the raw body, and returns a 401 response if the signature is invalid.

Django Signals

spidra-django dispatches a native Django Signal — spidra_webhook_received — whenever a verified webhook event is received through the built-in URL routes:
Or use the @receiver decorator:

Event listeners

Alternatively, register listeners on the spidra proxy object. These fire when spidra.dispatch_event() is called manually from your own webhook endpoint:

Built-in URL routing

Include the pre-built URL patterns to expose a complete Spidra REST API without writing any views:
This exposes:

Management commands

spidra-django adds management commands for automation scripts, cron jobs, and debugging:

Error handling

All Spidra exceptions inherit from SpidraError and are re-exported from spidra_django:
See the Python SDK for the full exception hierarchy.

Flask

Flask extension with Blueprint routing, flask spidra CLI, and HMAC webhook decorator.

FastAPI

Native async-first integration with dependency injection, Pydantic models, and OpenAPI docs.