Basic Web Search is a short Python example. It runs one web query, sets a start offset, and prints the results. Each result includes a title, snippet and link.
The problem
A web result page is enough to read. A script needs the same rows as data: title, link and snippet, plus a way to ask for the next page.
What the app does
- Sends a query and a start offset.
- Prints the result list.
How it works
The file calls web_search with query and start (no num). It calls GET /web with those two arguments. start is how many results to skip.
The rank checker example uses the same endpoint when you want the best rank of one domain across many keywords.
The code
import asyncio
import os
from desearch_py import Desearch
# Set DESEARCH_API_KEY in your environment to a key from the Desearch console. Do not commit a real key.
API_KEY = os.environ["DESEARCH_API_KEY"]
async def main():
# desearch-py 1.2.1: web_search(query, start) calls GET /web.
# start is how many results to skip. There is no num argument.
async with Desearch(api_key=API_KEY) as desearch:
result = await desearch.web_search(query="latest news on AI", start=0)
print(result)
if __name__ == "__main__":
asyncio.run(main())Set DESEARCH_API_KEY in your environment to a key from the Desearch console. Do not commit a real key.
Endpoints
GET /web
Example output
The script prints the response. The file does not include a saved sample run or a measured cost.
Run it yourself
The file linked above is basic_web_search.py in the examples repository. Install desearch-py 1.2.1, create a key at console.desearch.ai, set DESEARCH_API_KEY in your environment, and call web_search with query and start.
What it costs
This example does not record X-Desearch-Cost-Usd. Current responses include that header. See pricing.
Ideas to extend it
- Page with
startuntil you have the number of new URLs you need. - Pass the links to the page-to-Markdown example.
- Check one domain's best rank with the rank checker.
