
Hacker News Top Stories API vs Scraping: Complete Guide
Hacker News Top Stories API vs Scraping: Complete Guide Hacker News is one of the most valuable data sources for tech trends, startup analysis, and developer sentiment. But should you use the official API, the Algolia search API, or scrape the site directly? This guide covers all three approaches with working Python code. The Official HN API Hacker News provides a simple Firebase-based API at https://hacker-news.firebaseio.com/v0/ . It is free, requires no authentication, and has no strict rate limits. Fetching Top Stories import requests import time def get_top_stories ( limit = 30 ): """ Fetch top stories from HN official API. """ top_ids = requests . get ( " https://hacker-news.firebaseio.com/v0/topstories.json " ). json ()[: limit ] stories = [] for story_id in top_ids : item = requests . get ( f " https://hacker-news.firebaseio.com/v0/item/ { story_id } .json " ). json () stories . append ({ " title " : item . get ( " title " ), " url " : item . get ( " url " ), " score " : item .
Continue reading on Dev.to Python
Opens in a new tab

![[MM’s] Boot Notes — The Day Zero Blueprint — Test Smarter on Day One](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1368%2F1*AvVpFzkFJBm-xns4niPLAA.png&w=1200&q=75)

