News

List the comment tree of a Hacker News story · Hacker News API

GET/hacker-news/items/{id}/comments
$min $0.009

Returns the comments on a Hacker News story, depth-first with parent ids and depth, so a thread can be rebuilt. Paginate with `cursor`. Returns `not_found` when the story does not exist.

Using ChatGPT, Claude Code or another client? See the setup steps

Request
curl https://api.unifapi.com/hacker-news/items/{id}/comments \
  -H "Authorization: Bearer $UNIFAPI_KEY"

Parameters

idpathrequired
Hacker News story id.
limitquery
Maximum comment nodes to return in this page (1–100). Default: 50.
cursorquery
Opaque pagination cursor from a previous response's `pagination.next_cursor`. Omit for the first page.
Overview

This operation is part of the Hacker News API in the news category. It uses the same Bearer token, request tracing, error model, and billing envelope as every UnifAPI endpoint, so agents can switch between platforms without custom per-vendor glue code.

Use it when a workflow needs Hacker News public data alongside other news and community sources, but should still keep one API key, one account balance, and one predictable JSON contract.

Common agent workflows

  • Pull public Hacker News comment threads for sentiment, moderation, or audience-research agents.
  • Collect top-level discussion around a post while preserving pagination and billing metadata.
  • Give an AI agent a stable Hacker News data source without building a per-platform integration.
  • Normalize Hacker News responses into the same UnifAPI envelope used across the catalog.
Response shape

Unified envelope, platform-native fields

  • List-style responses return `data` as an array of top-level records plus optional `pagination` for continuation tokens or cursors.
  • The operation has a 9 credits ($0.009) minimum charge, so `billing.records_charged` can be higher than the visible records returned.
  • If the workspace balance cannot cover every result, the response can be truncated and `billing.truncated_due_to_balance` tells the caller why.

Response status codes

200400401402404429500502503

Billing

This operation charges 1 credit per billable record, with a 9 credits ($0.009) operation minimum. Public responses include billing metadata with credits charged, records charged, and remaining workspace balance. Incorrect Credit deductions caused by platform failures can be restored as billing corrections.

Errors and retries

Authentication, validation, rate-limit, not-found, and provider errors use the unified UnifAPI error format. Agents should log `request_id`, retry only retryable failures, and treat invalid API keys, disabled keys, and expired keys as the same public `unauthorized` error type.

Response fields

Fields on each record in data

A successful List the comment tree of a Hacker News story call returns data as an array; each record carries these fields.

idnumber | null
Comment item id.
parent_idnumber | null
Immediate parent item id (story or comment).
child_idsnumber[]
Child comment ids in ranked display order. Unresolved children may still appear here when traversal is incomplete.
authorstring | null
Author username when available.
created_atnumber | null
Creation time as an ISO-8601 timestamp when available. Unix seconds.
textstring | null
Plain-text body when available (HTML stripped). Null for deleted/tombstone nodes.
is_deadboolean | null
Whether the comment is marked dead.
is_deletedboolean | null
Whether the comment is marked deleted.
item_urlstring | null
Canonical news.ycombinator.com item URL.
Run it

Agents & Skills built on Hacker News

You rarely call List the comment tree of a Hacker News story by hand. These prebuilt agents and skills already read Hacker News data inside Claude or Codex — start from one of them, or call this endpoint yourself.