Skip to main content

Agentic Scraper Provider SDK for Python

Server-side SDK for event-driven MCP Market monetization. Use it inside the MCP or API service you publish as a provider. It is separate from the Agentic Scraper client SDK used by consumers.

pip install agentic-scraper-provider-sdk

How charging works

For a Marketplace entry configured with provider_event pricing, the Agentic Scraper proxy forwards a signed x-agentic-charge-token header to your service. Report a configured event and count with charge(). Always use the returned chargedCount; it may be lower than requested when the buyer's remaining run budget is limited.

FastAPI / async example

import os

from fastapi import FastAPI, Request
from agentic_scraper_provider import AsyncAgenticProviderClient

provider = AsyncAgenticProviderClient(api_key=os.environ["AGENTIC_PROVIDER_API_KEY"])
app = FastAPI()

@app.post("/mcp")
async def mcp(request: Request):
    records = await load_records()
    result = await provider.charge(
        charge_token=request.headers["x-agentic-charge-token"],
        event_name="record-returned",
        count=len(records),
        idempotency_key=f"record-export:{request.headers.get('x-request-id')}",
        metadata={"requestedCount": len(records)},
    )
    return records[:result["chargedCount"]]

Flask / sync example

import os

from flask import Flask, request
from agentic_scraper_provider import AgenticProviderClient

provider = AgenticProviderClient(
    api_key=os.environ["AGENTIC_PROVIDER_API_KEY"],
)
app = Flask(__name__)

@app.post("/summarize")
def summarize():
    summary = create_summary(request.json["text"])
    result = provider.charge(
        charge_token=request.headers["x-agentic-charge-token"],
        event_name="summary-created",
        idempotency_key=f"summary:{request.headers.get('x-request-id')}",
    )
    return {"summary": summary} if result["chargedCount"] == 1 else {"summary": None}

Reliability rules

  • Use a stable idempotency_key for every logical event.
  • Return or process at most result["chargedCount"] units.
  • Both clients retry transport failures, HTTP 429, and 5xx responses while preserving the same idempotency key.
  • Validation and other 4xx errors are not retried.
  • Verification and production use the same charge() method. Verification returns verification: true and creates no billing activity.
  • Keep the provider API key and charge token on the server. Never expose or log them.

AgenticProviderClient is synchronous for Flask and other WSGI applications. AsyncAgenticProviderClient is intended for FastAPI and other ASGI services. The default API base URL is https://api.agenticscraper.com/api/v1.

Full REST and SDK documentation is available at https://docs.agenticscraper.com.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentic_scraper_provider_sdk-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentic_scraper_provider_sdk-0.2.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file agentic_scraper_provider_sdk-0.2.0.tar.gz.

File metadata

File hashes

Hashes for agentic_scraper_provider_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 171804981d25d6970b821bb047f150e3e901fef81a41ee2b04def2c61dcfe2cf
MD5 d7fa5931756b1d9872107cf4025c578d
BLAKE2b-256 634dea528b75e59b0ba4a2b19452a1f79bc3d988d91ae5917a8404d05bf2a93b

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_scraper_provider_sdk-0.2.0.tar.gz:

Publisher: provider-sdk-python-release.yml on berkbirkan/agentic-scraper-cloud

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentic_scraper_provider_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_scraper_provider_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ce47840a51abc923e346471b77c007c70d89399e0907f656655a21c34a9b736
MD5 cadab7f6ac62dfec1ead6750212d29bb
BLAKE2b-256 cf6e8301e29a4ce307118f63a78557260f9a5f6908bd6b4a94db408e9227a940

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_scraper_provider_sdk-0.2.0-py3-none-any.whl:

Publisher: provider-sdk-python-release.yml on berkbirkan/agentic-scraper-cloud

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page