Web Links Search is a small Python app that turns one prompt into a ranked list of web links. Type a prompt, pick 1 to 10 links, and get each link with its title, domain, snippet and a source date when one is available. There is no summary step. It makes one Desearch call per new prompt and runs on the Python standard library.
The problem
When you want sources, not a written answer, you end up running the same search by hand and copying URLs, titles and snippets into a list. A single call that returns ranked links with their snippets is enough to feed a reading list, a research tool or an agent.
What the app does
- Accepts a prompt of 1 to 200 characters and a count from 1 to 10 links, default 10.
- Returns each link with title, domain, snippet and a source date when one is available.
- Shows only http and https links.
- Caches each prompt for 15 minutes, so the same prompt again, in any letter case and for any count, costs nothing.
- Rejects bad input with HTTP 400 before any call.
- Applies per network and global limits and a daily spend cap, and shows a labelled saved sample while live searches are paused.
How it works
- Check the input. The prompt is trimmed to 1 to 200 characters with no control characters, and the count is 1 to 10.
- Check the cache. Prompts are matched without letter case or extra spaces. A hit returns at no cost.
- Search.
POST /desearch/ai/search/links/webwith the prompt,tools: ["web"]andcount: 10. The endpoint takes a count of 10 or more, so the app always asks for 10 and keeps the number you picked. - Shape and serve. Keep the title, link, domain, snippet and date of each result and return JSON with the cost of the request.
The code
The core call, copied from weblinks/client.py:
def search(self, prompt):
request = urllib.request.Request(
'https://api.desearch.ai/desearch/ai/search/links/web',
data=json.dumps({'prompt': prompt, 'tools': ['web'], 'count': 10}).encode(),
headers={'Authorization': self.key, 'Content-Type': 'application/json',
'User-Agent': 'desearch-py-examples/web-links-search-demo'}, method='POST')The key comes from the DESEARCH_API_KEY environment variable on the server, in weblinks/service.py:
client = self._client or Client(os.getenv('DESEARCH_API_KEY', '').strip())Each result is reduced to the public fields in shape:
results.append({'title': title or domain, 'link': link, 'domain': domain,
'snippet': snippet.strip()[:500] if isinstance(snippet, str) else '',
'date': date if isinstance(date, str) and re.fullmatch(r'[0-9]{4}-[0-9]{2}-[0-9]{2}', date) else None})The response holds search_results, a list of rows with title, link, snippet and often published_date. The app keeps up to 10 shaped rows.
The folder layout:
weblinks/client.py: the Desearch call and result shaping.weblinks/service.py: input checks, the cache, limits and the JSON response.weblinks/guards.pyandweblinks/state.py: limits, the daily cap and the cache, in memory locally or in shared Redis when hosted.api/search.py: the serverless handler for/api/search.app.py: a local server for the page and the API.public/: the search page and a saved sample of fictional links.tests/: offline tests.
Endpoints
POST /desearch/ai/search/links/web
Example output
A live search on 2026-10-26 at 10:12 (Asia/Tbilisi) for open source vector databases with a count of 10. This page shows that stored run.
| What came back | Value |
|---|---|
| Links returned | 10 |
| Distinct domains | 8 |
| Links with a source date | 6 |
Cost from X-Desearch-Cost-Usd | $0.004 |
Same prompt as Open Source Vector Databases, count 3 | 3 links from the cache, $0 |
While live searches are paused, the app shows a saved sample of fictional example.com links, labelled as such.
Run it yourself
Clone desearch-py-examples and open web-links-search-demo. Then run it locally:
python3 -m pip install -r requirements.txt
DEMO_STATE=memory DEMO_LIVE=0 python3 app.pyOpen http://127.0.0.1:8000. A valid prompt shows the saved sample while paused. For live searches, set DESEARCH_API_KEY (from console.desearch.ai) in the server environment and run DEMO_STATE=memory DEMO_LIVE=1 python3 app.py.
curl -s "http://127.0.0.1:8000/api/search?prompt=open+source+vector+databases&count=3": call the API route directly.python3 -m pip install -r requirements.txt && python3 -m pytest -q: run the offline tests.
What it costs
Measured on 2026-10-26 from the X-Desearch-Cost-Usd header: $0.004 for one search that returned 10 links. Picking fewer links does not add a call, because the app trims the same 10. A cached repeat costs $0, and input rejected with HTTP 400 makes no call. See pricing.
Try it
Open the live search. Type a prompt and pick 1 to 10 links to get ranked web links with title, domain, snippet and date when available. Each network gets 5 searches per 10 minutes and 15 per day. Repeat prompts are served from a cache at no extra cost.
Ideas to extend it
- Write the links to a CSV for a reading list.
- Drop links from domains you do not want.
- Pass the links into the page-to-Markdown example.
