Hacker News API icon

Hacker News API

Interact with the Hacker News API (Algolia)

Actions3

Search → Search

AI-generated

Summary

Search Hacker News stories, comments, or posts by query, tags, and numeric filters, with optional pagination and result limiting.

Inputs

  • query — Full-text search query
  • tags — Filter by tags. Available tags: story, comment, poll, pollopt, show_hn, ask_hn, front_page, author_:USERNAME, story_:ID. Tags are ANDed by default, can be ORed if between parenthesis. Example: "story,author_pg" or "(story,poll)"
  • numericFilters — Filter on numerical conditions (<, <=, =, >, >=). Available fields: created_at_i, points, num_comments. Example: "points>100,num_comments>10"
  • page — Page number (0-indexed). Only used when "Return All" is disabled.
  • hitsPerPage — Number of results per page
  • returnAll — Whether to return all results or only up to a given limit
  • limit — Max number of results to return
  • requestOptions — Additional request settings such as proxy, timeout, SSL verification, or batching configuration

Output shape

A JSON object containing an array of search hits, each with id, title, url, and other fields, plus pagination metadata (page, hitsPerPage, totalHits).

Pagination is controlled by page and hitsPerPage; when returnAll is true the response may be capped by the limit parameter.

Examples

Example 1: Search for a generic term using default pagination.

query="machine learning", hitsPerPage=20

Example 2: Filter by numeric value and tags.

numericFilters="points>100", tags="story,author_pg"

Example 3: Retrieve all results up to a custom limit.

returnAll=true, limit=100

Links

Discussion