Skip to main content

langchain-apish

LangChain tools for API.SH. API.SH turns public web pages from around 1,000 websites into clean JSON: search engines, social media, e-commerce, real estate, jobs, travel, news and sports (Google, Amazon, TikTok, Zillow, LinkedIn and more). With this package an agent can find the right endpoint and call it.

pip install -U langchain-apish
export APISH_API_KEY="..."        # https://app.api.sh/keys

Every account gets free monthly credits. Failed calls are free and there are no rate limits.

Tools

Tool What it does
ApishSearchTool (apish_search) Finds endpoints by keywords: route, what it returns, parameters, price. Free, needs no key
ApishCallTool (apish_call) Runs any endpoint (route + params) and returns its JSON
ApishTool(route=...) One endpoint as a tool, with its parameters as typed, validated arguments
ApishToolkit apish_search + apish_call, plus one ApishTool per route you list

Two generic tools cover the whole catalog and keep the prompt short. When an agent only needs a few endpoints, give it typed tools instead: models fill typed arguments more reliably.

Agent example

create_agent builds a LangGraph agent that calls tools in a loop until it can answer:

from langchain.agents import create_agent
from langchain_apish import ApishToolkit

tools = ApishToolkit().get_tools()  # apish_search + apish_call
agent = create_agent("openai:gpt-5-mini", tools)

result = agent.invoke(
    {
        "messages": [
            {"role": "user", "content": "How many followers does NASA have on TikTok, and what are the top 3 posts on r/python right now?"}
        ]
    }
)
print(result["messages"][-1].content)

Install the model provider you use (pip install langchain langchain-openai, or any other chat model with tool calling). To limit the agent to fixed endpoints:

toolkit = ApishToolkit(
    routes=["/zillow/v1/search", "/zillow/v1/property"],
    include_generic=False,
)
agent = create_agent("openai:gpt-5-mini", toolkit.get_tools())

Calling a tool directly

from langchain_apish import ApishSearchTool, ApishTool

print(ApishSearchTool().invoke({"query": "tiktok profile", "limit": 3}))

profile = ApishTool(route="/tiktok/v1/profile")
print(profile.args)  # {'username': {...}}
print(profile.invoke({"username": "nasa"}))  # JSON text

As a tool call (what an agent sends), the result is a ToolMessage: content is the JSON text for the model, and artifact holds the parsed data with the request id and credits used:

msg = profile.invoke({"name": profile.name, "args": {"username": "nasa"}, "id": "1", "type": "tool_call"})
msg.artifact["data"]["followers"], msg.artifact["credits_used"], msg.artifact["request_id"]

Async

Every tool supports ainvoke, using the async client of apish-sdk:

hits = await ApishSearchTool().ainvoke({"query": "google search"})
page = await ApishTool(route="/google/v1/search").ainvoke({"q": "best running shoes", "country": "us"})

Options

All tools take api_key (default: APISH_API_KEY), client / async_client (your own apish.Apish / apish.AsyncApish), raw (default False: leave out the bulky raw source blocks), and max_chars (results longer than this are cut, with a note telling the model to ask for less, e.g. with the fields parameter). ApishToolkit passes them to every tool and shares one client between them.

API errors are returned to the model as the tool result (for example api.sh error 400: url is required), so it can fix its parameters and try again.

Relation to apish-sdk

This package is built on apish-sdk, the official Python client: it uses the SDK's clients, endpoint list and tool naming. apish-sdk also ships a small helper, apish.langchain.apish_tools; the same call works here and returns this package's tools:

from apish import Apish
from langchain_apish import apish_tools  # was: from apish.langchain import apish_tools

tools = apish_tools(Apish())

Endpoints released after the installed apish-sdk are found through the live catalog (https://api.api.sh/catalog, free) and their parameters are read from the platform's OpenAPI document.

Development

uv sync --group test --group lint
uv run pytest tests/unit_tests                      # offline, HTTP mocked
APISH_API_KEY=... uv run pytest tests/integration_tests   # live: a few calls, costs credits

License

MIT

Metadata

Release files for langchain-apish 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 langchain-apish 0.1.0
File Size Uploaded Provenance Actions
langchain_apish-0.1.0.tar.gz 12.7 kB Without provenance Details for langchain_apish-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 25.1 kB

Release files / langchain_apish-0.1.0.tar.gz

Download URL langchain_apish-0.1.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
799b61cacead108bb7072a0803011d0f43e7f024798bd51563ee328747288e05
BLAKE2b-256 checksum
How to use checksums
b4db02066de282696b6d442a1b200cc19cc95cfa62a3d3c213feb2526dfdecc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL langchain_apish-0.1.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea551783fd8ebf17abcc651a73777927ab0dbf0bb28a90b5191b3064b5b918bc
BLAKE2b-256 checksum
How to use checksums
5f511f1d02eef0d686119f10d299969fae36222873bdfb4c5733c969520af657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for langchain-apish 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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 No 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