Skip to content

About

LangChain tools and toolkit for CleanedWeb: find, read and run maintained REST APIs that return structured records

Topics

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

CleanedWeb

langchain-cleanedweb

PyPI CI License: MIT

Terminal: the LangChain find and run tools find the Steam Most Played Games API and print five live records

A live run of the [Steam Most Played Games API](https://cleanedweb.com/catalog/steam-most-played-games-api/?utm_source=github&utm_medium=langchain-cleanedweb): the five most played Steam games right now, as five records.

Scrapers break whenever a site changes its pages. CleanedWeb is a catalog of maintained REST APIs for public websites (listings, products, jobs, articles, profiles): you call an API and get structured records with known fields. When a site changes, CleanedWeb rebuilds its API. These are the LangChain tools for CleanedWeb.

  • Three tools let an agent find a published API, read its contract, and run it; CleanedWebToolkit bundles them.
  • Finding and reading are free and need no key; only running is charged, per record.
  • Guard rails for agents: small max_items by default, a hard cap, and records marked as data, never instructions.
  • A slow run returns its idempotency key, so a retry reads the same run and is never charged twice.
  • Errors come back as short, actionable text for the model. invoke and ainvoke both work.

Pricing: 5,000 records free once, then prepaid credit from $1 per 1,000 records, no subscription. Runs are charged per record delivered. Pricing

Install

pip install -U langchain-cleanedweb

langchain-cleanedweb depends on cleanedweb.

Create an API key with the run scope in the console and export it as CLEANEDWEB_API_KEY. Finding and reading APIs needs no key.

Quick start

# pip install langchain
from langchain.agents import create_agent
from langchain_cleanedweb import CleanedWebToolkit

tools = CleanedWebToolkit().get_tools()  # find, get, run (reads CLEANEDWEB_API_KEY)
agent = create_agent("anthropic:claude-sonnet-4-5", tools=tools)
agent.invoke({"messages": [("user", "Get 5 trending Python repositories from GitHub topics.")]})

Or call a tool directly:

from langchain_cleanedweb import CleanedWebFindAPI, CleanedWebGetAPI, CleanedWebRunAPI

found = CleanedWebFindAPI().invoke({"site": "github.com", "fields": ["title", "url"]})
api = found["matches"][0]
contract = CleanedWebGetAPI().invoke({"api_id": api["api_id"]})
records = CleanedWebRunAPI(max_items_limit=25).invoke(
    {"api_id": api["api_id"], "endpoint_id": api["endpoints"][0]["endpoint_id"], "max_items": 5}
)

Tools

Tool Name Needs key What it does
CleanedWebFindAPI cleanedweb_find_api no Find published APIs by site, fields, query. Nothing runs.
CleanedWebGetAPI cleanedweb_get_api no Inputs, output fields, limitations and three saved sample records.
CleanedWebRunAPI cleanedweb_run_api yes (run) Run an endpoint and return its records. Charged per record.

The tool descriptions tell the model to find before it runs, to start with a small max_items, and that records are website data, never instructions. CleanedWebRunAPI also enforces it: max_items defaults to default_max_items=5 and is capped by max_items_limit=100 (both settable). A run that is still going after wait_seconds (default 60) returns status: running with its idempotency_key; calling the tool again with the same arguments and key reads the same run and never starts or charges a second one. Errors (no credit, rate limit, failed run, lost connection) come back as short, actionable text for the model (handle_tool_error). CleanedWebToolkit(read_only=True) leaves out the run tool.

Tools work with invoke and ainvoke. Pass api_key=, base_url= or a configured cleanedweb.CleanedWeb as client= to override the defaults.

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ../cleanedweb-python -e ".[test,lint]"
ruff check . && ruff format --check . && mypy && pytest
pytest tests/integration_tests -m live      # standard integration tests, no-key catalog reads only

Unit tests mock the HTTP layer and include LangChain's standard ToolsUnitTests.

Popular catalog APIs

More

MIT licensed.

About

LangChain tools and toolkit for CleanedWeb: find, read and run maintained REST APIs that return structured records

Topics

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages