Skip to main content

clawfetch

Python SDK for ClawFetch — Web Intelligence API for AI Agents.

Pay-per-request via x402 (gasless USDC on Base). No API keys, no subscriptions.

Install

pip install clawfetch

Quick Start

Sync

from clawfetch import ClawFetch

with ClawFetch(private_key="0x...") as cf:
    # Fetch any URL as clean markdown ($0.001)
    page = cf.fetch("https://example.com")

    # Extract structured data ($0.008)
    btc = cf.extract("https://coingecko.com/en/coins/bitcoin")
    print(btc["data"])

    # Multi-source research ($0.02)
    report = cf.research("latest AI agent frameworks")

Async

import asyncio
from clawfetch import AsyncClawFetch

async def main():
    async with AsyncClawFetch(private_key="0x...") as cf:
        page = await cf.fetch("https://example.com")
        btc = await cf.extract("https://coingecko.com/en/coins/bitcoin")
        report = await cf.research("latest AI agent frameworks")

asyncio.run(main())

Both clients have identical APIs — all 7 endpoints, full x402 payment flow, retry with exponential backoff, and typed error hierarchy.

API

Method Price Description
fetch(url) $0.001 URL → clean markdown
render(url) $0.005 JS-rendered page → markdown
extract(url) $0.008 Structured data from 17+ sites
research(topic) $0.02 Multi-source topic research
domains_check(domains) $0.003 Domain availability check
domains_suggest(keywords) $0.003 Domain name suggestions
parse(source) $0.005 Office document (docx/pptx/xlsx/pdf/…) → markdown
company(domain) $0.02 Company profile from a domain: socials, emails, phones, tech stack, key pages
extractors() $0.001 List available extractors
health() Free API status check

Error Handling

from clawfetch import (
    ClawFetch,
    ClawFetchError,    # Base class
    PaymentError,      # 402 — insufficient USDC
    NetworkError,      # Connection/timeout failures
    RateLimitError,    # 429 — includes retry_after_ms
    ApiError,          # Other 4xx/5xx errors
)

Configuration

from clawfetch import ClawFetch, RetryOptions

cf = ClawFetch(
    private_key="0x...",
    base_url="https://api.clawfetch.ai",  # default
    timeout=30.0,                          # seconds
    retry=RetryOptions(
        max_retries=3,
        initial_delay_ms=500,
        max_delay_ms=10000,
        backoff_multiplier=2.0,
    ),
    debug=False,
)

Requirements

  • Python 3.9+
  • A wallet with USDC on Base (even $1 gives you 1,000+ requests)

License

MIT


Original README below

Python SDK for ClawFetch — Web Intelligence API for AI Agents.

Pay-per-request via x402 (gasless USDC on Base). No API keys, no subscriptions.

Install

pip install clawfetch

Quick Start

from clawfetch import ClawFetch

cf = ClawFetch(private_key="0x...")

# Fetch any URL as clean markdown ($0.001)
page = cf.fetch("https://example.com")

# Extract structured data ($0.008)
btc = cf.extract("https://coingecko.com/en/coins/bitcoin")
print(btc["data"])  # {'name': 'Bitcoin', 'price': 98432.12, ...}

# JS-rendered pages ($0.005)
rendered = cf.render("https://app.uniswap.org")

# Multi-source research ($0.02)
report = cf.research("latest AI agent frameworks")

# Company enrichment from a domain ($0.02)
acme = cf.company("vercel.com")
print(acme["name"], acme["socials"]["linkedin"], acme["techStack"])

# Domain availability ($0.003)
domains = cf.domains_check(["coolstartup.com", "coolstartup.ai"])

# List extractors ($0.001)
extractors = cf.extractors()

Configuration

from clawfetch import ClawFetch, RetryOptions

cf = ClawFetch(
    private_key="0x...",
    base_url="https://api.clawfetch.ai",  # default
    timeout=30.0,                           # request timeout in seconds
    retry=RetryOptions(                     # or False to disable retries
        max_retries=3,
        initial_delay_ms=500,
        max_delay_ms=10_000,
        backoff_multiplier=2.0,
    ),
    debug=False,                            # enable debug logging
)

Error Handling

All errors extend ClawFetchError for easy catching:

from clawfetch import ClawFetch, ClawFetchError, PaymentError, NetworkError, RateLimitError, ApiError

cf = ClawFetch(private_key="0x...")

try:
    result = cf.fetch("https://example.com")
except PaymentError as e:
    print(f"Payment failed ({e.status_code}): {e}")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after_ms}ms")
except NetworkError as e:
    print(f"Network error: {e}")
except ApiError as e:
    print(f"API error {e.status_code}: {e}")
except ClawFetchError as e:
    print(f"ClawFetch error: {e}")
Error Status Retried
PaymentError 402 No
RateLimitError 429 Yes (with Retry-After)
ApiError 400, 401, 404 No
ApiError 500, 502, 503, 504 Yes
NetworkError Connection/timeout Yes

Retry Behavior

By default, retries are enabled with exponential backoff + jitter:

Attempt Delay
1st retry ~500ms
2nd retry ~1,000ms
3rd retry ~2,000ms

Respects Retry-After headers on 429 responses. Non-retryable errors (400, 401, 402, 404) fail immediately.

Disable retries:

cf = ClawFetch(private_key="0x...", retry=False)

How It Works

  1. SDK makes a request to ClawFetch
  2. Server returns 402 Payment Required with USDC amount
  3. SDK auto-signs an EIP-3009 gasless USDC transfer on Base
  4. Request is retried with payment header
  5. You get structured data back

No gas fees. No API keys. Just USDC on Base.

Context Manager

with ClawFetch(private_key="0x...") as cf:
    data = cf.extract("https://coingecko.com/en/coins/bitcoin")
# Client is automatically closed

Requirements

  • Python 3.9+
  • A wallet with USDC on Base (even $1 gives you 1,000+ requests)

Development

pip install -e ".[dev]"
pytest tests/ -v

License

MIT

Metadata

Release files for clawfetch 0.3.0

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

Source distribution (sdist)

Source distribution for clawfetch 0.3.0
File Size Uploaded Provenance Actions
clawfetch-0.3.0.tar.gz 23.8 kB Without provenance Details for clawfetch-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 39.6 kB

Release files / clawfetch-0.3.0.tar.gz

Download URL clawfetch-0.3.0.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
745e8545455d6565fa715d55fbd1617168da089c1803c8b1f9c7cebae781b5de
BLAKE2b-256 checksum
How to use checksums
cb4cf1a352afaa10128b3f92cf5a9e80aa80edf1154a75b510a4e0237d4f48cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / clawfetch-0.3.0-py3-none-any.whl

Download URL clawfetch-0.3.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8275c256368ada52c758e46ba978b12657656168934ea0f301147998d8ce0c69
BLAKE2b-256 checksum
How to use checksums
249d5b08c18a157eeae11f7150f359db73eb3604be93ee72b129c05087ee8bd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for clawfetch 0.3.0

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.

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

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