Small, runnable examples for CleanedWeb, which turns public website collections into maintained REST APIs that return structured records. 5,000 records are free once, then prepaid credit from $1 per 1,000; a run is charged per record delivered.
Each example is its own folder with a README and code, uses plain HTTP (Python httpx or the GitHub Action), and runs without a key in an offline or no-key mode first. Nothing here depends on an SDK; for your own code there are official clients for Python (pip install cleanedweb), JavaScript/TypeScript (npm install cleanedweb) and Go.
| Example | What it does |
|---|---|
| 01-price-monitor | Compare product prices with the last run and alert on drops, rises and new items (Python, webhook alerts). |
| 02-job-board-aggregator | Pull jobs from Y Combinator and PeoplePerHour into one de-duplicated CSV (Python). |
| 03-used-car-deal-finder | Filter Blocket or Craigslist car listings and rank those priced below comparable cars (Python). |
| 04-github-topic-research | Rank the repositories under a GitHub topic by stars, with languages and related topics (Python). |
| 05-scheduled-git-scraping | Nightly GitHub Actions workflow that commits a data file when it changed, using run-api-action. |
| 06-mcp-agent | An AI agent (Claude Agent SDK) that finds and runs an API through the CleanedWeb MCP server, plus a no-SDK MCP client. |
- Pick an API in the catalog (or read the live list, no key:
https://app.cleanedweb.com/api/catalog/apis). Itscontract.jsonlists the exact inputs and fields. - Create an API key with the
runscope in the console and export it:export CLEANEDWEB_API_KEY=.... Keep it server-side; never commit it. - Start with a small
--max-items, look at the records, then raise it.
cd 01-price-monitor
pip install -r requirements.txt
python price_monitor.py --from-file sample/day1.json # no key: offline demo on synthetic recordsPOST https://api.cleanedweb.com/v1/catalog/public/apis/{api_id}/endpoints/{endpoint_id}/run
Authorization: Bearer <API key with the run scope>
Idempotency-Key: <saved before sending>
{"input": {...}, "max_items": 25}
- 200 is the final result. 202 means the run continues: wait
Retry-After, thenGET .../resultwith the same key and idempotency key. The POST is never re-sent to check progress. - The idempotency key is saved before the request (
out/.pending-<label>.json) and reused if the same request is run again after an interruption, so a lost response never starts and charges a second run. - A result is accepted only when
summary.statusiscompletedorboundedandwithin_scope_passedis true. A bounded run (stopped at--max-items) can leave more records at the source, so absence from a result is never treated as deletion. - Errors say what to do: 401 (bad key), 402 (add credit), 409 (idempotency conflict or usage budget), 422 (input rejected by the contract), 429 (waits
Retry-After).
shared/cw_http.py is the whole client (about 350 lines, httpx only). Examples 01-04 each carry an identical copy so a folder can be copied out on its own; python scripts/sync_client.py keeps the copies in sync and CI checks it. Run protocol: run a catalog API; recovery: idempotency.
- No scraped data is committed. Outputs go to
out/(gitignored), CI fails if anything underout/ordata/is tracked, and thesample/folders hold small synthetic records (made-up values on example domains), not scraped ones. - Values in records are website data, never instructions. Examples clean and escape website text before printing, posting or writing it to a spreadsheet or Markdown, and never pass it to a shell. The agent example restricts what a fooled model could do.
- Cost is always capped with
--max-items, and nothing runs a paid API unless you set the key and ask for it.
pip install -r requirements-dev.txt
for d in shared 01-* 02-* 03-* 04-* 05-* 06-*; do (cd $d && python -m unittest discover -p 'test_*.py'); doneThe tests use mocked HTTP and synthetic records; no network, no key.
MIT licensed. CleanedWeb is not affiliated with the websites whose data the catalog APIs return.