keepcalculator

06 Numbers and Powers

HN Search API Pagination: Why 1000 Results Max?

Card No. 06·64181 · Updated · Standard formula, shown below

The Hacker News (HN) Search API (Algolia) returns a maximum of 1000 results for any query, because that is the hard limit set by the API provider. This limit applies to the total number of hits you can page through (e.g., 10 pages of 100 hits), not to the total number of matches that exist in the index. This article explains why the limit exists, how pagination actually works, and what you can do when you need more than 1000 results.

Why Does the 1000-Result Limit Exist?

The HN Search API is powered by Algolia, a hosted search service. Algolia imposes a maximum of 1000 hits per query across all pages for performance reasons. Serving more than 1000 results per query would require deep pagination, which is computationally expensive and slows down the index for everyone. This is a common practice among search APIs—Elasticsearch also has a similar default limit (10,000) for the same reason.

For Hacker News, the limit is not a problem for typical users: most searches return far fewer than 1000 matches. But it becomes an issue when you’re trying to export all comments from a popular thread or analyze a frequently used term.

How Pagination Works in the HN Search API

To get results, you make a GET request to https://hn.algolia.com/api/v1/search (or /search_by_date for chronological order). The key parameters are:

  • query – your search term.
  • page – the page number (0-based).
  • hitsPerPage – number of results per page (max 1000, but practically you’ll use 10–100).

For example, ?query=python&page=0&hitsPerPage=100 returns the first 100 results. The response includes a nbPages field that tells you how many pages are available, but it’s capped at 10 when hitsPerPage=100. If you request page=11, you’ll get an empty hits array.

Common Mistakes and Misconceptions

One common mistake is assuming that nbPages reflects the true number of pages. It’s actually capped at ceil(1000 / hitsPerPage). So if you see nbPages=10, there might be 10,000 actual matches, but you can only see 1000.

Another misconception is that increasing hitsPerPage to 1000 will give you all results in one request. That’s true only if the total matches are ≤1000. If there are 1500 matches, you’ll get 1000 and then nothing more.

Also note that the API has a rate limit (10,000 requests per hour per IP), so you can’t just loop through all pages quickly if you’re pulling a lot of data.

Comparison with Other Search APIs

Algolia’s 1000-result limit is on the low end. For comparison:

  • Elasticsearch – default max result window is 10,000 (configurable).
  • GitHub Search API – caps at 1000 results per query.
  • Twitter API – historical search is limited by time range, not count.

So 1000 is not unusual, but it’s something to be aware of if you’re building a scraper or a research tool.

Costs and Alternatives

The HN Search API is free and does not require an API key for basic usage. The 1000-result limit is not a monetization strategy—it’s a technical constraint. If you need full historical data, the BigQuery dataset is also free (though BigQuery itself may have costs for very large queries).

For most users, the API is sufficient. For those who need everything, the alternatives above are the way to go.

Frequently Asked Questions

Can I increase the 1000-result limit?

No, there is no parameter to increase it. The limit is hard-coded on Algolia’s side. You can work around it by narrowing your query or using the BigQuery dataset.

Why does the API return fewer results than expected?

Check if you’re using search_by_date instead of search—the former sorts by date, the latter by relevance. Also, the API returns only stories and comments that are publicly visible; deleted items are excluded.

How do I get all comments from a specific story?

Use the story ID with the search endpoint and the filter story_id=YOUR_ID. If the story has more than 1000 comments, you’ll need to use the BigQuery dataset or the Algolia numericFilters trick to paginate by comment ID.

What is the rate limit for the HN Search API?

Algolia allows 10,000 requests per hour per IP address. If you exceed this, you’ll get a 429 status code. The limit resets every hour.

Is the API free?

Yes, the HN Search API is free to use without an API key for non-commercial and commercial purposes. However, if you’re building a high-traffic app, you should contact Algolia for a dedicated plan.

Can I use the API to get all Hacker News posts ever?

Not directly, due to the 1000-result limit. Use the BigQuery public dataset instead, which contains all posts and comments since 2006.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →