This Hacker News search app is for developers who want to pull Hacker News discussions on a topic into their own scripts or a small web page. Type a topic like "sqlite in production" and get item links, titles, snippets and the most relevant comments, with JSON and CSV export. It uses one Desearch call and the Python standard library.
The problem
Hacker News threads are a good record of what developers think about a tool, a database or a pattern. Finding the right threads by hand means several searches, opening each item and copying links and quotes into notes. Getting that into a spreadsheet or a script is more work again. A search you can call from code, with clean item links, removes the copying.
What the Hacker News search app does
- Takes a topic, 1 to 300 characters. Alternatives go in parentheses:
(sqlite OR duckdb) production. - Returns 10, 20 or 30 Hacker News results per call: stories and single comments.
- Keeps only
news.ycombinator.com/item?id=links and removes duplicate items. - Shows each result's title, link, snippet and highlights (the most relevant comments).
- Exports the same results as JSON or CSV, from the CLI or the web page.
- Serves the same request again within 10 minutes from memory at no cost.
How it works
- Check the input. A blank topic, a bad count or unbalanced parentheses gets HTTP 400 before any call.
- Search Hacker News.
POST /desearch/ai/searchwithtools: ["hackernews"],result_type: "ONLY_LINKS"andcount10, 20 or 30.ONLY_LINKSskips the AI summary. - Filter and dedupe. Keep item page links only and dedupe by item id, so the output is safe to join with other data.
- Serve or export. The CLI writes JSON and CSV; the local server shows an HTML page with export links and answers
/searchand/search.csv.
The code
The core call, copied from the example's README. The key is read from the DESEARCH_API_KEY env var:
curl -s https://api.desearch.ai/desearch/ai/search \
-H "Authorization: $DESEARCH_API_KEY" -H "Content-Type: application/json" \
-d '{"prompt": "rust async runtime", "tools": ["hackernews"], "streaming": false, "result_type": "ONLY_LINKS", "count": 10}'The request body is built by body in core.py:
def body(query, count=10, date_filter=""):
"""Request body for POST /desearch/ai/search with only the hackernews tool, links only, no streaming."""
b = {"prompt": query, "tools": ["hackernews"], "streaming": False, "result_type": "ONLY_LINKS", "count": count}
if date_filter:
b["date_filter"] = date_filter
return bThe response holds search (each result's title, link, snippet and highlights) plus cost_usd. The cost is also in the X-Desearch-Cost-Usd header.
The folder layout:
core.py: input checks, request body, item filter, dedupe, CSV and JSON export, HTML. No network.app.py: the CLI, the HTTP page and the Desearch client.test_core.py: offline tests.samples/: a JSON and CSV export and an HTML page for one search.
Endpoints
POST /desearch/ai/search
Example output
Saved sample from a run on 2026-10-16 for "sqlite in production" with count 10. This page shows that stored request and response. It does not run a live demo.
Sample request
{
"prompt": "sqlite in production",
"tools": ["hackernews"],
"streaming": false,
"result_type": "ONLY_LINKS",
"count": 10
}Sample response
The saved run cost $0.004.
| What came back | Count |
|---|---|
| Links returned | 10 |
| Hacker News item pages kept | 10 of 10 |
| Duplicates removed | 0 |
The top results, as returned:
- How (and why) to run SQLite in production
- Ask HN: Who uses SQLite database in production?
- Ask HN: SQLite in Production?
Titles, snippets and highlights are Hacker News text, quoted as returned. The full export is in samples/sqlite-in-production.json and .csv.
Run it yourself
git clone https://github.com/Desearch-ai/desearch-py-examples && cd desearch-py-examples/hacker-news-search-app
export DESEARCH_API_KEY=... # from console.desearch.ai
python3 app.py --cli "rust async runtime" --count 10 --csv out.csv --json out.jsonFor the web page, run python3 app.py --port 8000 and open http://127.0.0.1:8000/.
--count: 10, 20 or 30 results per call.--csvand--json: save the results as a spreadsheet or as data.--log-dir runs/today: save each API call with the key removed.
What it costs
Measured on 2026-10-16 from the X-Desearch-Cost-Usd header: $0.004 for 10 results and $0.008 for 20, so $0.0004 per result. Repeat requests within 10 minutes come from memory and cost nothing. See pricing.
Ideas to extend it
- Track what Hacker News has said about your product and its category, saved to CSV each week.
- Feed the highlights into a summary step to get a short "what developers think" note per topic.
- Join the CSV with your own docs search to answer support questions with real threads.
