← All site APIs · updated 2026-09-21

Hacker News API

news.ycombinator.com · 1 credit when fetched live, 0 from the shared store · needs an API key

Front page stories and item threads as clean JSON — no HTML parsing on your side.

GET /v1/structured/hackernews/front

Front page. Stories on the front page, in rank order.

ParameterTypeRequiredDescription
pagenumbernoPage number (1-based). e.g. 1
max_agenumbernoAccept a stored copy up to this many seconds old (credits: 0). Defaults to 600 s (10 min); 0 forces a fresh fetch.
Example
curl "https://api.webscrapingapi.dev/v1/structured/hackernews/front?page=1" -H "X-API-Key: wsa_your_key"
Response
{
  "site": "hackernews",
  "action": "front",
  "data": {
    "count": 30,
    "stories": [
      {
        "rank": 1,
        "title": "Samsung is expected to more than double …",
        "points": 125,
        "commentCount": 84
      },
      // 29 more
    ]
  },
  "source": "live", "age": 0, "credits": 1
}

Returns data shaped like: stories[] { id, rank, title, url, site, points, author, commentCount, age }. The envelope also carries site, action, params, source (live or cache), age in seconds, fetchedAt, elapsedMs and credits.

Caching. Results are stored and shared for 10 min by default. A response served from the store costs 0 credits and says "source": "cache"; pass max_age=0 to force a fresh fetch, or a smaller max_age when you need something newer.

GET /v1/structured/hackernews/item

Item thread. A story with its comment thread (flattened, with depth).

ParameterTypeRequiredDescription
idnumberyesHacker News item id. e.g. 1
max_agenumbernoAccept a stored copy up to this many seconds old (credits: 0). Defaults to 600 s (10 min); 0 forces a fresh fetch.
Example
curl "https://api.webscrapingapi.dev/v1/structured/hackernews/item?id=1" -H "X-API-Key: wsa_your_key"
Response
{
  "site": "hackernews",
  "action": "item",
  "data": {
    "id": 1,
    "title": "Y Combinator",
    "commentsParsed": 3,
    "comments": [ { "id": 15, "author": "sama", "depth": 0, "text": "…" } ]
  },
  "source": "live", "age": 0, "credits": 1
}

Returns data shaped like: { id, title, url, points, author, age, comments[] { id, author, age, depth, text } }. The envelope also carries site, action, params, source (live or cache), age in seconds, fetchedAt, elapsedMs and credits.

Caching. Results are stored and shared for 10 min by default. A response served from the store costs 0 credits and says "source": "cache"; pass max_age=0 to force a fresh fetch, or a smaller max_age when you need something newer.


Layout changes on news.ycombinator.com can break parsing; the API then returns SITE_PARSE_FAILED. If you see it, tell us on the board and it will be fixed.