DEV Community

Алексей Спинов
Алексей Спинов

Posted on

Hacker News Has a Free Search API — Here's How to Use It

Hacker News has a powerful search API powered by Algolia. No authentication, no rate limits, instant results.

Search Stories

curl 'https://hn.algolia.com/api/v1/search?query=web+scraping&tags=story&hitsPerPage=5'
Enter fullscreen mode Exit fullscreen mode

Returns: title, points, comments, author, URL, date.

Search by Date

# Stories from the last 24 hours
curl 'https://hn.algolia.com/api/v1/search_by_date?query=AI&tags=story&numericFilters=created_at_i>1711000000'
Enter fullscreen mode Exit fullscreen mode

Node.js Example

async function searchHN(query, limit = 25) {
  const url = `https://hn.algolia.com/api/v1/search?query=${encodeURIComponent(query)}&tags=story&hitsPerPage=${limit}`;
  const res = await fetch(url);
  const data = await res.json();

  return data.hits.map(hit => ({
    title: hit.title,
    url: hit.url,
    points: hit.points,
    comments: hit.num_comments,
    author: hit.author,
    date: hit.created_at,
    hn_url: `https://news.ycombinator.com/item?id=${hit.objectID}`
  }));
}

const stories = await searchHN('startup funding');
stories.forEach(s => console.log(`${s.points}pts: ${s.title}`));
Enter fullscreen mode Exit fullscreen mode

What You Can Search

  • tags=story — front page posts
  • tags=comment — all comments
  • tags=ask_hn — Ask HN threads
  • tags=show_hn — Show HN launches
  • tags=author_pg — posts by specific user

Use Cases

  1. Trend detection — what topics are gaining traction?
  2. Content research — what gets upvoted in your niche?
  3. Competitor monitoring — track mentions of any company
  4. Community sentiment — how does HN feel about a topic?

I used this API to create a free dataset of 498 HN stories about AI, web scraping, and startups.

More Free APIs


Need HN data or community analysis? $20 flat rate. Email: Spinov001@gmail.com | Hire me

Top comments (0)