langchain-anyapi
LangChain tools for AnyAPI: hundreds of data and scraping APIs (Reddit, Instagram, TikTok, YouTube, Google search, web scraping, and more) behind one key, billed per request in USD, no subscriptions.
pip install langchain-anyapi
Set ANYAPI_API_KEY, or pass api_key= to a tool or the toolkit. A key with
starter credit is free at https://getanyapi.com.
The whole loop in one line
from langchain.agents import create_agent
from langchain_anyapi import ANYAPI_INSTRUCTIONS, AnyAPIToolkit
agent = create_agent(
"anthropic:claude-sonnet-4-5",
tools=AnyAPIToolkit().get_tools(),
system_prompt=ANYAPI_INSTRUCTIONS,
)
Or take one tool at a time:
from langchain_anyapi import AnyAPIGetAPI, AnyAPIRunAPI, AnyAPISearchAPIs
AnyAPISearchAPIs().invoke({"query": "reddit trending posts"})
AnyAPIGetAPI().invoke({"sku_id": "reddit.trending_posts"})
AnyAPIRunAPI().invoke({"sku_id": "reddit.trending_posts", "input": {"limit": 2}})
Five tools, not one per API
| Tool | Charges? | What it does |
|---|---|---|
anyapi_search_apis |
no | ranked search over the catalog, descriptions kept, schemas omitted |
anyapi_list_apis |
no | browse summaries, optionally filtered by category |
anyapi_get_api |
no | one API in full: strict input schema, output schema, per-lane USD pricing, 30-day latency |
anyapi_run_api |
YES | execute one API with a normalized input payload |
anyapi_get_balance |
no | remaining wallet balance in USD |
AnyAPI publishes hundreds of APIs. One tool per API would not fit an agent's
context, so these five teach the loop instead: search or list to find an API,
anyapi_get_api to read its strict input schema, then anyapi_run_api. Input
schemas reject unknown fields rather than ignoring them, so an input built from
a description instead of a schema usually fails.
Money
Prices are USD and come off the wire exactly as the gateway published them.
Every static price is quoted in both denominations: maxUsd is what one
request is billed, and maxPer1kUsd is the same price per 1,000 requests.
Nothing in this package multiplies one into the other. A run reports its actual
charge as costUsd.
There is no quote tool here. The AnyAPI MCP server has one, but the published
getanyapi SDK exposes no quote method, and adding one would mean hand-rolling
an authenticated HTTP call beside the SDK. anyapi_get_api already publishes
pricing.from.maxUsd, the most a first-choice run is billed, and
pricing.failoverMaxUsd, the ceiling for any run, so an agent can bound its
spend before it calls. Two further differences from the MCP server's tools:
search results carry no heavy marker, and search requires a query.
Behavior worth knowing
- Both
_runand_arunare real. The async path usesAsyncAnyAPI, not the sync client on a thread. - The client is built on first use. Importing this package and constructing a tool need neither a key nor a socket, so a missing key surfaces only when a tool is actually called.
- A failed call returns a readable payload with
error,status, and where the gateway sent themcodeandrequestId, rather than aborting the run. response_formatis"content". LangChain serializes the returned dict to JSON for the tool message either way, so an artifact would only carry a second copy of the same payload.anyapi_run_apitakesfields,max_items, andsummaryto trim a large response. None of them change what you are charged.
Development
pip install -e ".[dev]"
ruff check . && ruff format --check . && mypy && pytest
Unit tests run with sockets blocked and no key. The integration tests call the
live gateway and are skipped unless ANYAPI_API_KEY is set; they cover the free
tools only, because the standard suite invokes a tool repeatedly and every run
of an API charges the wallet.
Links
- Homepage: https://getanyapi.com
- Docs: https://getanyapi.com/docs
- Support: support@getanyapi.com
MIT licensed.
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 langchain_anyapi-0.1.0.tar.gz.
File metadata
- Download URL: langchain_anyapi-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cf49ad4da96cd4800d70a06bea4a9e1940bdd20a2c3894e59097b9c48cdd3be
|
|
| MD5 |
a6bc06971973b65226ddfff4e5b04284
|
|
| BLAKE2b-256 |
0287e1d7a73291e46ea9518bf5f5ccfefa317b2c87e0d9ce96f53f98ee7f5773
|
Provenance
The following attestation bundles were made for langchain_anyapi-0.1.0.tar.gz:
Publisher:
release-langchain-anyapi.yml on getanyapi-com/integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_anyapi-0.1.0.tar.gz -
Subject digest:
2cf49ad4da96cd4800d70a06bea4a9e1940bdd20a2c3894e59097b9c48cdd3be - Sigstore transparency entry: 2715756358
- Sigstore integration time:
-
Permalink:
getanyapi-com/integrations@79a47e832aeef04626211bba43799cff3900c577 -
Branch / Tag:
refs/tags/langchain-anyapi-v0.1.0 - Owner: https://github.com/getanyapi-com
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-langchain-anyapi.yml@79a47e832aeef04626211bba43799cff3900c577 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_anyapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_anyapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6a881aeb7362c0159cd93f54bd6e7552a9ffc80f7b88a57d42af92714335fdc
|
|
| MD5 |
6b4bf847cd009753e7fee3bfb9302029
|
|
| BLAKE2b-256 |
ee41aceb052744f229813aca932fd2d8fd65478c741c635bd7abb114d94bceb5
|
Provenance
The following attestation bundles were made for langchain_anyapi-0.1.0-py3-none-any.whl:
Publisher:
release-langchain-anyapi.yml on getanyapi-com/integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_anyapi-0.1.0-py3-none-any.whl -
Subject digest:
b6a881aeb7362c0159cd93f54bd6e7552a9ffc80f7b88a57d42af92714335fdc - Sigstore transparency entry: 2715757203
- Sigstore integration time:
-
Permalink:
getanyapi-com/integrations@79a47e832aeef04626211bba43799cff3900c577 -
Branch / Tag:
refs/tags/langchain-anyapi-v0.1.0 - Owner: https://github.com/getanyapi-com
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-langchain-anyapi.yml@79a47e832aeef04626211bba43799cff3900c577 -
Trigger Event:
push
-
Statement type: