Web search API for AI agents: the clean text of the top pages in one call
When an AI agent needs one fact from the web (a licence status, a regulation date, a company's services, a price on a public page), it usually runs a small pipeline before it can answer:
- Search: send a query to a search engine or search API and get a list of links.
- Choose: pick the 2 or 3 links that look like primary sources.
- Fetch: download each page, which can fail, time out, or return a JavaScript shell.
- Clean: strip the navigation, cookies banners and ads so the model reads the content and not the chrome.
- Pass: feed the text to the model with the question.
That is four or five network calls, four or five places where it can fail, and a lot of tokens spent on boilerplate. This guide explains how to do the same job by hand first, then the one-call version.
The manual method (free)
You can do the whole pipeline yourself with no API key:
- Open a search engine and restrict to official sites when you can, for example
site:gouv.qc.caorsite:canada.ca. - Open the 2 or 3 most relevant results. Prefer primary sources (the registry, the regulator, the company's own site) over aggregators.
- Copy the paragraph that answers the question, and note the URL and the date you read it.
- If a page does not load or shows only a script, try another one. Do not guess the missing fact.
This works well for a human. For an agent that runs hundreds of times a day, the manual method breaks down on steps 3 and 4: fetching and cleaning are where the code gets fragile.
The one-call version with Tolca web-search
Tolca's web-search endpoint does steps 1 to 4 in a single paid call, at 0.008 $ USD per call over x402 (USDC on Base or Solana), with no account:
- It searches, reads the top 3 pages and returns their clean text, with the source URL for each.
- French and Canada by default, and a mode that favours official sources (government, regulators, registries) when you need them.
- No fee if there are zero results.
- Machine-readable: the OpenAPI description is at https://tolca.tonbot.ca/openapi.json and the MCP endpoint is https://tolca.tonbot.ca/mcp/public, if your agent framework already speaks MCP.
Pattern for the agent:
POST https://tolca.tonbot.ca/v1/web-search
(x402 payment on first call; read the parameters in openapi.json)
→ clean text of the top 3 pages + source URL for each
→ the model answers from those texts and cites the URLs
Keep the source URLs in the answer. A fact without its page is hard to audit, for you and for the person who reads the agent's output.
When not to use a search API
- If you already know the exact URL (a registry record, a regulator's page), fetch that page directly. It is cheaper and more precise.
- If the answer must come from a private database, a search over the public web will not give you a reliable answer.
- If you need thousands of pages crawled, use a crawler, not a per-question search.
Checklist before you ship an agent that searches the web
- Log the source URL of every fact the agent states.
- Store the date of the read. Public pages change.
- Treat zero results as "unknown", not as "no".
- Put a limit on the number of search calls per task, so one bad question does not burn your budget.
Related guides on this site: recherche web pour un agent IA, en français and an MCP server for AI agents.
POST https://tolca.tonbot.ca/v1/verify-business (x402, USDC on Base) · free in Claude or ChatGPT through MCP: https://tolca.tonbot.ca/mcp/public