Official typed Python SDK for AnyAPI: any API, one wallet, USD, no subscriptions.
Project description
getanyapi
Official typed Python SDK for AnyAPI: any API, one wallet, USD, no subscriptions. Reach hundreds of scraping and data APIs through one interface and one key; pay per request in real US dollars. httpx + pydantic v2, Python 3.10+, sync and async clients.
pip install getanyapi
Quickstart
from getanyapi import AnyAPI
client = AnyAPI() # reads ANYAPI_API_KEY from the environment
res = client.reddit.search(query="mechanical keyboard")
if res.output.found:
for post in res.output.data.posts:
print(post.title, post.score)
print("charged", res.cost_usd, "USD")
Async:
from getanyapi import AsyncAnyAPI
async with AsyncAnyAPI() as client:
res = await client.google.search(query="best coffee maker")
Inputs vs outputs (naming asymmetry)
Input keyword arguments mirror the wire API verbatim (camelCase where the API uses it), because
they are sent as-is. Output models are Pythonic: attributes are snake_case with a wire alias
(item.reviews_count reads the wire reviewsCount), and model_dump(by_alias=True) reproduces
the wire shape. Open provider records round-trip unknown fields via .model_extra.
Not found vs error
A successful call always returns. For most SKUs the payload is wrapped in a found flag:
res.output.found is False when the upstream had no matching entity (not an error). Use
unwrap to get the data or raise ResultNotFoundError when empty:
from getanyapi import unwrap, ResultNotFoundError
res = client.amazon.reviews(product="B07FZ8S74R")
try:
data = unwrap(res) # the typed data payload, or raises
except ResultNotFoundError:
... # empty result (found: False), not an HTTP failure
ResultNotFoundError subclasses NotFoundError, so except NotFoundError catches both an
HTTP 404 and an empty result; catch ResultNotFoundError to handle only empty results. If a
future committed schema uses a bare output, generated typing returns its data object directly
rather than relying on a hard-coded SKU list.
Discovery
apis = client.catalog(category="search")
matches = client.search(query="web search", platform="google", limit=10)
api = client.describe(matches.results[0].slug)
print(api.pricing.from_offer, api.pricing.failover_max_usd, api.input_schema)
Sync and async clients expose the same category-only catalog, dedicated ranked search, and
schema-bearing describe methods. Prices are nested USD flat/linear offers, lanes are
anonymous, and provider is always "AnyAPI".
Pagination
Paginated SKUs expose an iter_* method that yields validated item models across pages and
follows the cursor for you. Call .pages() on it to walk whole results (each has its own
cost_usd).
for post in client.reddit.iter_search(query="coffee", options={"max_items": 100}):
print(post.title) # a validated model, not a dict
for page in client.reddit.iter_search(query="coffee").pages():
print(page.cost_usd)
Request options (context-cost savers)
Pass options= to shape the response. These trim what comes back but do NOT change the price:
res = client.google.search(
query="coffee",
options={"fields": ["title", "link"], "max_items": 5, "summary": True},
)
options also carries per-call timeout and max_retries overrides.
Errors and retries
| Class | HTTP | Meaning |
|---|---|---|
BadRequestError |
400 | Input failed validation |
AuthenticationError |
401 | Missing or invalid API key |
InsufficientBalanceError |
402 | Wallet balance or per-key cap exceeded |
NotFoundError |
404 | Slug or resource does not exist |
ResultNotFoundError |
- | unwrap on an empty found-data result |
RateLimitedError |
429 | Too many requests (retried automatically) |
UpstreamError |
502 | An upstream backend failed |
ConnectionError |
0 | Network or transport failure (retried) |
TimeoutError |
0 | Request exceeded its timeout (not retried) |
All extend AnyAPIError (with .status and .request_id). Retries cover only 429 and network
failures, with jittered exponential backoff honoring Retry-After. Default max_retries is 2
(up to 3 attempts); set it on the client (AnyAPI(max_retries=...)) or per request via
options. Timeouts are never retried.
Agent signup
Bootstrap a key with no account (for autonomous agents):
from getanyapi import agent_signup, AnyAPI
result = agent_signup(label="my-agent")
client = AnyAPI(api_key=result.secret)
The key ships with a small starter balance and a per-key spend cap; a human funds it by claiming
it at result.claim_url.
Docs
Full API reference and catalog: getanyapi.com/docs.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file getanyapi-0.7.0.tar.gz.
File metadata
- Download URL: getanyapi-0.7.0.tar.gz
- Upload date:
- Size: 152.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
311c4b24c0dc869fd96fc4b7023eff17d5656301047c0f691cc40a7decf80ba7
|
|
| MD5 |
0829f2ca00d5accd2ab96660ad823789
|
|
| BLAKE2b-256 |
9834103524d92c3478fd09ec73c0ecb11f2175102117071cb0e47b4efd05751c
|
Provenance
The following attestation bundles were made for getanyapi-0.7.0.tar.gz:
Publisher:
release.yml on getanyapi-com/sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
getanyapi-0.7.0.tar.gz -
Subject digest:
311c4b24c0dc869fd96fc4b7023eff17d5656301047c0f691cc40a7decf80ba7 - Sigstore transparency entry: 2179284529
- Sigstore integration time:
-
Permalink:
getanyapi-com/sdks@3d62fa1cfa92de4fae7be2851852dd6eb269f65c -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/getanyapi-com
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3d62fa1cfa92de4fae7be2851852dd6eb269f65c -
Trigger Event:
push
-
Statement type:
File details
Details for the file getanyapi-0.7.0-py3-none-any.whl.
File metadata
- Download URL: getanyapi-0.7.0-py3-none-any.whl
- Upload date:
- Size: 203.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e295554ff6c30c2f46e057a3a6958f98b04aa894bf8116a43f35d64b568343fe
|
|
| MD5 |
f10dff3217363a22c5701eeb4e55dc73
|
|
| BLAKE2b-256 |
960712c2bd0756ee5343a703a343e4bec47b58bcfa6ddcc17c7358dcb1461ceb
|
Provenance
The following attestation bundles were made for getanyapi-0.7.0-py3-none-any.whl:
Publisher:
release.yml on getanyapi-com/sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
getanyapi-0.7.0-py3-none-any.whl -
Subject digest:
e295554ff6c30c2f46e057a3a6958f98b04aa894bf8116a43f35d64b568343fe - Sigstore transparency entry: 2179284577
- Sigstore integration time:
-
Permalink:
getanyapi-com/sdks@3d62fa1cfa92de4fae7be2851852dd6eb269f65c -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/getanyapi-com
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3d62fa1cfa92de4fae7be2851852dd6eb269f65c -
Trigger Event:
push
-
Statement type: