Skip to main content

webextract-sdk (Python)

Thin client for the WebExtract API: a public web page in, clean Markdown plus fixed-schema JSON out (article metadata, product and price, tables). It's built for AI agents.

pip install webextract-sdk            # core (httpx only)
pip install "webextract-sdk[x402]"    # + the official x402 SDK, for pay-per-call

The PyPI name is webextract-sdk; the import name is webextract (from webextract import WebExtract).

Billing: pick one

Mode How Cost
Free tier (default) WebExtract() sends X-Billing: free (when WEBEXTRACT_API_KEY is not set) 50 calls/day per IP (shared with MCP)
Prepaid credits WebExtract(api_key="lx_...") or env WEBEXTRACT_API_KEY → Authorization: Bearer /v1/extract 1 credit, /v1/markdown 0.4 credit. Buy at https://webextract.dev/#pricing
x402 pay per call AsyncWebExtract(payment_client=x402HttpxClient(...)) /v1/extract $0.005, /v1/markdown $0.002 in USDC on Base and 6 other chains
x402 sandbox add billing="x402-testnet" Base Sepolia test USDC only. Nothing real is charged

This package never handles private keys. With x402, signing happens inside the client you build with the official x402 SDK.

from webextract import WebExtract, PaymentRequiredError, TargetFetchError

with WebExtract() as we:                      # free tier
    r = we.extract("https://web-scraping.dev/product/1")
    print(r.data["product"], r.meta.free_remaining)

x402 (async, official SDK)

import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm.exact import ExactEvmScheme
from webextract import AsyncWebExtract

async def main():
    signer = Account.from_key(os.environ["X402_PRIVATE_KEY"])    # your key, your process
    xc = x402Client(); xc.register("eip155:8453", ExactEvmScheme(signer=signer))
    async with x402HttpxClient(xc, timeout=60) as pay:
        we = AsyncWebExtract(payment_client=pay)                 # billing="x402"
        r = await we.markdown("https://example.com")
        print(r.meta.payment_response)                           # settlement receipt (tx hash)
asyncio.run(main())

WEBEXTRACT_API_KEY: if api_key isn't passed, the client reads this environment variable. An explicit api_key always wins. The variable is ignored when payment_client is given or billing is anything other than "key", so it never causes the "api_key + payment_client" error.

settlement_retries (default 1): a 402 settlement_failed (payment verified, not settled, not charged) is retried once, and the payment client signs a fresh payment. Other errors are never retried.

For a sync client, pass the requests.Session from x402.http.clients.x402_requests(xc) as payment_client=. The x402 SDK has no sync httpx client.

Errors

Every error is a WebExtractError with status, code, message, charged, retryable, body.

Class When Notes
PaymentRequiredError HTTP 402 .reason is one of x402_required, x402_requested, free_limit_reached, invalid_payment, unsupported_network, settlement_failed (retryable), no_credits. Also has .networks, .payment_required (decoded header), .buy_url, .free_remaining, .hint
TargetFetchError target page failed: upstream_error, blocked_by_site (422), robots_disallowed (451), dns_failed, fetch_failed, too_large, unsupported_type never charged
InvalidRequestError 400 (missing_url, invalid_url, forbidden_host, ...) or client-side URL check never charged
AuthenticationError 401 invalid_api_key
RateLimitError 429 (sandbox limits) .retry_after
ConnectionError no response: network error, timeout, or the payment client raised code is timeout or connection_error

Response fields

The responses are the API JSON as-is (schema_version "1.0"). Fields added on 2026-10-21 (content_source, product.price_detail, product_unresolved) may be missing on older deployments, so read them with .get(). A missing price is never reported as 0. price_detail.unresolved.reason says why it's missing.

License: MIT © TAINCHENG, L.L.C.

Metadata

Release files for webextract-sdk 0.1.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 webextract-sdk 0.1.0
File Size Uploaded Provenance
webextract_sdk-0.1.0.tar.gz 11.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for webextract-sdk 0.1.0
File Interpreter ABI Platform
webextract_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / webextract_sdk-0.1.0.tar.gz

Download URL webextract_sdk-0.1.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3c7693d45386063843d7d469e1f16a0a947777651d4ea9b3f3e1f7daceec1437
BLAKE2b-256 checksum
How to use checksums
63a9f1a7e9e8d3116222ef985a77ce48baf438951475d7c243614ae928831d71
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 21, 2026.

Transparency log

Release files / webextract_sdk-0.1.0-py3-none-any.whl

Download URL webextract_sdk-0.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bbc75d2d67792e0a024f2cec59f4e19486c276fe42981561f90d6352c11e75a
BLAKE2b-256 checksum
How to use checksums
77ecb0a3457fa63e2ef452aa876a675ef96795333160a7fd0b93b8cb756153e0
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 21, 2026.

Transparency log

Security for webextract-sdk 0.1.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.

Full provenance

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

Select from 2 files

Attestation for webextract_sdk-0.1.0.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 21, 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.

Release history Release notifications | RSS feed

This release

0.1.0 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