spidra-flask) brings the full Spidra API — scrape, batch scrape, search, crawl, map, parse, templates, presets, and monitors — natively into Flask. It follows Flask extension conventions: direct initialization or the Application Factory pattern, a pre-built Blueprint exposing REST endpoints, an event dispatcher for webhooks, and a flask spidra CLI group for terminal use.
Installation
Get your API key from app.spidra.io under API Keys.
Store it in an environment variable or your Flask app config. Never hardcode it.
Configuration
Configure credentials via environment variables or directly inapp.config:
Initialization
spidra-flask supports both styles.
Direct initialization
Application Factory pattern
SpidraFlask is an alias for Spidra if you prefer a more explicit name.
Scraping
spidra.scrape() extracts content from a URL — plain markdown or structured JSON — with browser rendering, CAPTCHA bypass, and optional residential proxies:
spidra_jsonify() recursively serializes Spidra dataclasses to JSON, including nested stats objects. It accepts any mix of dicts, lists, and Spidra objects.
Searching
sources: "web", "news", "images", "videos", "research", "developer". Defaults to ["web"].
Crawling
Crawl an entire site recursively and extract structured data from every page:Mapping
Discover all URLs on a domain without scraping page bodies:Batch scraping
Submit up to 50 URLs in one request and process them in parallel:Parsing documents
Parse PDFs, Word, Excel, and other documents into Markdown or structured JSON:Async Flask views
Flask 2.0+ supports nativeasync def views. Access the async client via spidra.async_client:
Webhooks
Spidra sends signed webhook events (e.g.crawl.page, crawl.completed) to your endpoint. Use the @spidra_webhook_required decorator to verify HMAC-SHA256 signatures automatically:
SPIDRA_WEBHOOK_SECRET from config, verifies the X-Spidra-Signature header against the raw body, and returns 401 if the signature is invalid.
Event listeners
Register handlers that fire automatically when a verified webhook arrives. Pair this with the Blueprint’s built-in/spidra/webhooks endpoint:
Pre-built Blueprint
Register a Blueprint that exposes a complete Spidra REST API under/spidra:
Flask CLI
spidra-flask adds a flask spidra CLI group:
Error handling
All Spidra exceptions inherit fromSpidraError and are re-exported from spidra_flask:
FastAPI
Native async-first integration with dependency injection, Pydantic models, and OpenAPI docs.
Django
Full Django integration with management commands, Django Signals, and built-in URL routing.

