Skip to main content

Purrkey Python SDK

PyPI

The official Python client for Purrkey, a pay-per-call tool marketplace for AI agents. One API key reaches 1,100+ data tools: social media from TikTok, Instagram, YouTube, Xiaohongshu and Douyin, Amazon and eBay listings, Google Maps reviews, SEO data, and web search and scraping. Every tool has a published price, and each call is paid from one balance.

Python 3.10+. Sync and async clients. Fully typed.

Install

pip install purrkey

Quick start

Create a key at purrkey.app/keys and set it as PURRKEY_API_KEY. New accounts get $1 in free credit.

from purrkey import Purrkey

with Purrkey() as purrkey:  # reads PURRKEY_API_KEY
    # 1. Find a tool (free)
    candidates = purrkey.discover("google maps reviews")["candidates"]

    # 2. Read its schema and price (free)
    tool = purrkey.inspect("tikhub.tiktok.app.v3.fetch_video_search_result")
    print(tool["tool"]["price"])  # {'unit': 'call', 'unitPriceMicros': '1000', ...}

    # 3. Run it and wait for the result
    run = purrkey.run(
        "tikhub.tiktok.app.v3.fetch_video_search_result",
        {"query": {"keyword": "matcha latte", "count": 10}},
    )
    print(run["status"])                    # SUCCEEDED
    print(run["billing"]["chargedMicros"])  # 1000 = $0.001
    print(run["result"]["output"])

Async:

import asyncio
from purrkey import AsyncPurrkey

async def main() -> None:
    async with AsyncPurrkey() as purrkey:
        run = await purrkey.run("anyapi.web.scrape", {"url": "https://purrkey.app/about"})
        print(run["result"]["output"]["data"]["markdown"])

asyncio.run(main())

Browse the tool catalog to see what is available.

Paying safely

run() handles the rules that keep a task from being charged twice:

  • Spending cap. Each Run carries maxChargeMicros, the most it may cost (1 USD = 1,000,000 micros). For tools priced per call, the SDK uses the inspected price. When the price depends on the input (per result, per URL, per credit), pass max_charge_micros yourself; otherwise run() raises max_charge_required before anything is charged.

  • Idempotency. Every Run has an idempotencyKey. If a response is lost, the SDK sends the same request again with the same key, and Purrkey returns the original Run instead of running and charging again. Pass your own key to make retries safe across processes:

    purrkey.run(tool_id, payload, idempotency_key=f"report-{report_id}")
    

    A new key means a new, separately charged task.

  • Unknown outcomes. UNKNOWN means the provider's outcome needs reconciliation. The SDK stops waiting and returns the Run. Check it later with get_run(run_id); don't submit the task again.

  • Billing is separate from status. Read run["billing"] (status, heldMicros, chargedMicros). A failed Run can still be charged for verified work when the tool's pricing allows it.

Account-wide daily and per-run caps can be set at purrkey.app/budget.

API

Method What it does Cost
discover(query, *, limit, provider_id, category) Find tool candidates for one task Free
inspect(tool_id, *, tool_revision) Exact input/output schema, price and delivery rules Free
run(tool_id, input, *, max_charge_micros, idempotency_key, wait=True, timeout=120) Inspect, submit and (by default) wait for a final status Tool price
submit_run(request) Submit a prepared RunRequest Tool price
get_run(run_id) Read a Run and its result Free
wait_for_run(run_id, *, timeout) Poll until a final status; returns the Run as it is on timeout Free
cancel_run(run_id) Request cancellation —
list_runs(**filters) List your Runs (status, toolId, cursor, limit, …) Free
balance() Balance and held amounts Free
list_tools(), list_providers(), catalog(), platform_endpoints(platform), rankings() Browse the catalog Free

AsyncPurrkey has the same methods as coroutines. Client options: api_key (default PURRKEY_API_KEY), base_url, timeout, max_retries (default 2; network errors, 429 and 5xx), http_client.

Responses are plain dicts typed with TypedDicts from purrkey.types, generated from the public OpenAPI contract.

Errors

API errors and client-side checks raise PurrkeyError:

from purrkey import PurrkeyError

try:
    purrkey.run(tool_id, payload)
except PurrkeyError as error:
    print(error.status, error.code, error.message, error.request_id)

Common codes: insufficient_balance, schema_invalid (input doesn't match the tool's schema), max_charge_required, network_error.

Other ways to connect

Development

uv sync
uv run pytest
uv run mypy
uv run python scripts/generate.py --fetch   # pull the live contract and regenerate types

src/purrkey/types.py is generated from openapi/openapi.yaml; don't edit it by hand. CI fails when they disagree, and a weekly job checks the vendored contract against the live API.

License

MIT

Metadata

Release files for purrkey 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 purrkey 0.1.0
File Size Uploaded Provenance Actions
purrkey-0.1.0.tar.gz 101.7 kB With provenance Details for purrkey-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 116.5 kB

Release files / purrkey-0.1.0.tar.gz

Download URL purrkey-0.1.0.tar.gz
Size 101.7 kB
Tags Source
SHA-256 checksum
How to use checksums
45f97c7e25b57e754729823ae19c6369d29bd6df93fc538a9ef5482ed965c571
BLAKE2b-256 checksum
How to use checksums
f2778044bf6aca0ccb9a3546d3d4016dbb08d620ef9e84c771ef2c0efbc99223
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 Nov 20, 2026.

Transparency log

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

Download URL purrkey-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa575695a27ce1ec26b4272a6e33b1f209e10e0d9aaaece002a86d8832f0466f
BLAKE2b-256 checksum
How to use checksums
0faa92e47ec270b090ffedacbd57e2b3a5d7afc1876f9d5ac63698f76fea5282
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 Nov 20, 2026.

Transparency log

Security for purrkey 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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for purrkey-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 Nov 20, 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

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