Skip to main content

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. One further difference from the MCP server's tools: search results carry no heavy marker.

Behavior worth knowing

  • Both _run and _arun are real. The async path uses AsyncAnyAPI, 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 them code and requestId, rather than aborting the run.
  • response_format is "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_api takes fields, max_items, and summary to 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

MIT licensed.

Metadata

Release files for langchain-anyapi 0.2.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 langchain-anyapi 0.2.0
File Size Uploaded Provenance
langchain_anyapi-0.2.0.tar.gz 17.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-anyapi 0.2.0
File Interpreter ABI Platform
langchain_anyapi-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.2 kB

Release files / langchain_anyapi-0.2.0.tar.gz

Download URL langchain_anyapi-0.2.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9f68aec6234cb39ed3c1af29ac52a44c73e619b9e2c647041834c7572327c7ff
BLAKE2b-256 checksum
How to use checksums
43fe7f2262a000b6685b3bbf7ed4e379c1d586e28ef202a5d66b618647503865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 5, 2026.

Transparency log

Release files / langchain_anyapi-0.2.0-py3-none-any.whl

Download URL langchain_anyapi-0.2.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ced97b0a8f3e85808dcfee482bd4404f5e6633a3d17ddc970e14ef139e555317
BLAKE2b-256 checksum
How to use checksums
824904161c2a35b7dbfa41489e857e30dc42ab3fa86f49d8a5c5439d8f9bae68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 5, 2026.

Transparency log

Security for langchain-anyapi 0.2.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 langchain_anyapi-0.2.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 Sep 5, 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.2.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