Hacker News hub

Hacker News Comment Context API

Start from a comment id and walk up to the root story — comment, ancestors, and story card in one lookup.

GET /v1/hackernews/comments/{id}/context

2 credits per successful request.

About this endpoint

Alerts and moderation tools often surface a deep comment URL first. Without the parent chain and root story, the text is hard to interpret — reply context, original title, and outbound link are missing. Walking parentId yourself across N item gets is brittle when nodes are deleted or dead.

`GET /v1/hackernews/comments/{id}/context` resolves a comment id to `data.comment`, an `ancestors` chain toward the root, and the root `story` when available. Send `x-api-key` and branch on `data.lookupStatus` before you write. `found` populates the comment (and typically story); `not_found` and `not_comment` return typed misses. HTTP 200 still means the request finished.

Credit pricing for this operation comes from the API registry and appears on this page, and `meta.creditsCharged` is the billing source of truth. To page an entire thread, use story comments instead of calling context once per node.

Hacker News Comment Context API FAQ

How do I get Hacker News comment context by id?

Call GET /v1/hackernews/comments/{id}/context with your Social Fetch API key in the x-api-key header. Pass the numeric comment id. Read data.lookupStatus, then data.comment, data.ancestors, and data.story.

How many credits does comment context cost?

Pricing is documented on the operation in the API registry (shown on this page). Confirm on every response with meta.creditsCharged — that field is the billing source of truth.

What does lookupStatus mean on comment context?

found means the id resolved as a comment and context fields may be populated. not_found means the id does not exist. not_comment means the id exists but is not a comment. Always branch before treating the payload as found context.

What is in the ancestors array?

Ancestors are intermediate items between the comment and the root story, ordered toward the story. Combined with data.story, they reconstruct the path a reader would see climbing the thread.

Comment context vs story comments?

Use context when you start from a comment id and need upward context. Use GET /v1/hackernews/stories/{id}/comments when you start from a story and need to page the full discussion tree.

Do I need a Hacker News account?

No. Social Fetch authenticates with your Social Fetch API key only. The route reads public item data; it does not act as a logged-in HN user.

Can I use this for alert enrichment?

Yes. Teams expand comment-deep links into title, URL, and parent text before notifying Slack or a CRM. Persist meta.requestId when a miss needs support review.