Export Hacker News stories to CSV with the official API
Description and use
A Python script using the official Hacker News API exports top stories to CSV, supports keyword and score filtering, and can be scheduled to update the feed hourly.
Problem
Need to pull top Hacker News stories into a CSV, filter by keyword or score, and keep a feed running without scraping.
Outcome
Script outputs hn_top.csv with top 50 stories, supports keyword/score filtering, and can run hourly to maintain a feed.
Workflow
- 1. Set BASE URL to https://hacker-news.firebaseio.com/v0
- 2. GET /topstories.json and take first 50 ids
- 3. For each id, GET /item/
<id>.json - 4. Skip items that are null, dead, or deleted
- 5. Append id, title, url (fallback to discussion link), author, score, comments to rows
- 6. Write rows to hn_top.csv using csv.DictWriter
- 7. Print number of saved stories
- 8. (Optional) Add filter: if keyword not in title.lower() or score < threshold, continue
- 9. Store seen ids in a JSON file to avoid duplicates
- 10. Schedule script via cron or Task Scheduler hourly
Evidence
Hacker News has a free, official API. You don't need to scrape the website.
The script above does the same job for free if you are happy to run it yourself.
- Record date: 2026-11-02T21:14:10.098Z