Skip to main content

scrapy-calyprium

Anti-detection Scrapy middleware for web scraping — proxy routing and stealth browser rendering powered by Calyprium.

Install

pip install scrapy-calyprium

Quick Start

# settings.py
import scrapy_calyprium

scrapy_calyprium.configure(api_key="clp_your_key_here")

This auto-configures:

  • VeilProxyMiddleware — routes requests through rotating proxies with TLS fingerprinting
  • MimicBrowserMiddleware — renders JavaScript pages with stealth browser instances
  • S3 feed storage — write spider output to Calyprium storage using Scrapy's built-in S3FeedStorage

Usage

# settings.py
import scrapy_calyprium

scrapy_calyprium.configure(
    api_key="clp_your_key_here",
    mimic_stealth_level="maximum",  # basic, moderate, maximum
)

Manual Configuration

# settings.py
DOWNLOADER_MIDDLEWARES = {
    "scrapy_calyprium.VeilProxyMiddleware": 100,
    "scrapy_calyprium.MimicBrowserMiddleware": 200,
}

CALYPRIUM_API_KEY = "clp_your_key_here"
VEIL_USER_ID = "your-user-id"

Request Tracing

CalypriumTraceMiddleware (added by configure()) gives every request one trace: the wait in Scrapy's queue, each download attempt, the challenge solve if there is one, and the callback that parses the page. The SDK's calls to Mimic and Tessera carry the trace (traceparent), so their steps join it. On the Calyprium platform the trace of every request of a run is shown with its run. To set it up by hand, register it as both a downloader and a spider middleware:

DOWNLOADER_MIDDLEWARES = {"scrapy_calyprium.CalypriumTraceMiddleware": 50}
SPIDER_MIDDLEWARES = {"scrapy_calyprium.CalypriumTraceMiddleware": 50}

Failure Diagnosis and Retries

Every download attempt gets a diagnosis from the fetch layer's shared failure classifier (the same one Mimic and Tessera use), in response.meta["calyprium_diagnosis"]: {"class", "number", "side", "move", "vendor"?, "status"?, "evidence"?, "confidence"?, "retry_after"?}. A transport error leaves it on failure.request.meta for an errback. When Mimic's own call failed and the request fell back to a plain download, meta["calyprium_fallback_diagnosis"] and meta["calyprium_fetch_error"] say why.

MimicBrowserMiddleware retries an attempt when its diagnosis's move is worth another try: retry_elsewhere and climb at once, retry_later after CALYPRIUM_RETRY_DELAY, slow_down after a doubling backoff (a Retry-After wins), fix_ours once, and never a stop (not found, sign-in / geo / consent walls, policy). A retry carries meta["calyprium_attempt_number"] and meta["calyprium_prior_class"], which Mimic receives to resume its ladder. meta["dont_retry"] and meta["max_retry_times"] work as with Scrapy's RetryMiddleware; with that middleware enabled, the statuses in RETRY_HTTP_CODES are left to it. Stats: calyprium/retry/<class> per retry, calyprium/class/<class> per final response.

Saving Output to Calyprium Storage

Spider output is saved to Calyprium's S3-compatible storage using Scrapy's built-in feed export:

# settings.py
import scrapy_calyprium

scrapy_calyprium.configure(api_key="clp_your_key_here")

FEEDS = {
    "s3://calyprium/my-spider/%(time)s.jl": {
        "format": "jsonlines",
    },
}

The S3 credentials are auto-configured by configure() — no additional setup needed.

Browser Rendering

Mark requests that need JavaScript rendering:

import scrapy

class MySpider(scrapy.Spider):
    name = "example"

    def start_requests(self):
        # Regular request (proxy only)
        yield scrapy.Request("https://example.com")

        # Browser-rendered request
        yield scrapy.Request(
            "https://example.com/spa",
            meta={"mimic": True},
        )

Authentication

All middleware requires a valid API key. Set it via:

  1. scrapy_calyprium.configure(api_key="clp_...")
  2. CALYPRIUM_API_KEY environment variable

Settings Reference

Setting Description Default
CALYPRIUM_API_KEY API key for all services —
VEIL_GATEWAY_URL Proxy gateway URL https://proxy.calyprium.com
VEIL_USER_ID User ID for proxy routing —
VEIL_PROFILE Proxy routing profile —
VEIL_PROXY_TYPE datacenter, residential, residential_rotating —
MIMIC_SERVICE_URL Mimic browser service URL https://mimic.calyprium.com
MIMIC_STEALTH_LEVEL basic, moderate, maximum moderate
MIMIC_BROWSER_ENGINE Specific browser engine auto
MIMIC_USE_PROXY Route browser through proxy False
MIMIC_ALL_REQUESTS Render all requests via browser False
MIMIC_USE_SPECTRE Use device fingerprints True
MIMIC_SOLVE_DEADLINE_S How long Mimic's /api/solve may run (Mimic's SOLVE_DEADLINE_S); local-first solves wait this plus 30 s 240
CALYPRIUM_RETRY_ENABLED Retry attempts whose diagnosis says so True
CALYPRIUM_RETRY_TIMES Retries per request 2
CALYPRIUM_RETRY_DELAY Seconds before a retry_later; base of the slow_down backoff 5
CALYPRIUM_RETRY_MAX_DELAY Cap on any retry delay (seconds) 60
PRISM_WAIT_FOR_SCAN_S PrismSitemapSpider: how long to wait for Prism to index an unknown domain before closing as prism_no_urls (ends 30 s before CLOSESPIDER_TIMEOUT) 900

Development

src/scrapy_calyprium/routing/diagnosis.py is vendored: it is Mimic's failure classifier, copied verbatim from the Calyprium monorepo (stealth/mimic/mimic/routing/diagnosis.py). Never edit it here; when Mimic changes it, copy the file again (its VERSION constant says which contract it is) and run the tests. SDK-side adaptations live in routing/block_detect.py.

License

MIT

Metadata

Release files for scrapy-calyprium 1.36.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 scrapy-calyprium 1.36.1
File Size Uploaded Provenance Actions
scrapy_calyprium-1.36.1.tar.gz 244.4 kB With provenance Details for scrapy_calyprium-1.36.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scrapy-calyprium 1.36.1
File Interpreter ABI Platform Actions
scrapy_calyprium-1.36.1-py3-none-any.whl Python 3 none any Details for scrapy_calyprium-1.36.1-py3-none-any.whl

Total release size: 401.7 kB

Release files / scrapy_calyprium-1.36.1.tar.gz

Download URL scrapy_calyprium-1.36.1.tar.gz
Size 244.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cf196cc9de0bf3ba197ceea757e55773239201b313ebec80a773b1a6ed3768ca
BLAKE2b-256 checksum
How to use checksums
0026f901d5489ed88ad547cfcb7ffd319ff1fc64c4f4d9cde6b4fe5a5a1bd346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / scrapy_calyprium-1.36.1-py3-none-any.whl

Download URL scrapy_calyprium-1.36.1-py3-none-any.whl
Size 157.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23293128bb2b8321caed98526991d7234e2a8acc60ed3e17a632361acb1a56e8
BLAKE2b-256 checksum
How to use checksums
6512e6b9d9720f42c690fd1617aa8828ef1e57fcac88c398c5f50e83fd8ad0d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for scrapy-calyprium 1.36.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scrapy_calyprium-1.36.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.36.1 This release

2 release files Full provenance

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