Search Hacker News stories and comments · Hacker News API
Full-text search over Hacker News stories, comments, polls and jobs with filters for type, author, domain, date range and points. Paginate with `cursor`.
Using ChatGPT, Claude Code or another client? See the setup steps
curl https://api.unifapi.com/hacker-news/search \ -H "Authorization: Bearer $UNIFAPI_KEY"
Parameters
- queryquery
- Full-text search query. Required unless `front_page_only`, `author`, `domain`, or `url` is set.
- typequery
- Restrict search results to a Hacker News content type. `ask_hn`: Ask HN posts (questions to the community). `show_hn`: Show HN posts (projects/work being shared). `launch_hn`: Launch HN posts (YC-affiliated company launches). Default: `all`.
- sortquery
- Ranking mode. Default: `popularity`.
- date_rangequery
- Creation-time window. Default: `all`.
- limitquery
- Hits per page. Must be one of 10, 20, 30, 50. Default: 20. Prefer this over `page_size`.
- front_page_onlyquery
- When true, restrict results to current front-page items. Allows omitting `query`.
- search_story_textquery
- Include story/comment text in searchable fields. Default: true. Set false to search title/URL only.
- search_authorquery
- When true, include author username in the searchable fields.
- prefixquery
- When true, enable prefix matching for query tokens.
- typo_tolerancequery
- Enable typo tolerance. Default: true.
- authorquery
- Restrict results to items by this Hacker News username.
- domainquery
- Restrict search to story URLs matching this domain (e.g. example.com). Can omit `query`.
- urlquery
- Restrict search to story URLs matching this URL substring. Can omit `query`.
- min_pointsquery
- Minimum points/score filter.
- cursorquery
- Opaque pagination cursor from a previous response's `pagination.next_cursor`. Omit for the first page.
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
- Search Hacker News for public mentions, creators, posts, or topics matching a user query.
- Feed ranked Hacker News results into research, monitoring, and enrichment workflows.
- 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.
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 3 credits ($0.003) 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
Billing
This operation charges 1 credit per billable record, with a 3 credits ($0.003) 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.
Fields on each record in data
A successful Search Hacker News stories and comments call returns data as an array; each record carries these fields (12 of 13 shown — the docs list the full schema).
- idnumber | null
- Hacker News item ID.
- typestring | null
- Item type, such as story, comment, poll or job.
- authorstring | null
- Username of the author.
- created_atnumber | null
- When the item was posted. Unix seconds.
- titlestring | null
- Story title. Null for comments.
- textstring | null
- Item text as HTML. Null for link stories.
- urlstring | null
- Linked URL for link stories.
- scorenumber | null
- Points.
- comment_countnumber | null
- Number of comments.
- story_idnumber | null
- ID of the story this item belongs to.
- parent_idnumber | null
- ID of the parent item. Null for stories.
- tagsstring[]
- Search index tags.
Agents & Skills built on Hacker News
You rarely call Search Hacker News stories and comments 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.
More Hacker News operations
Combine endpoints from the same platform, then join the results with other UnifAPI categories without changing authentication or response parsing.
Get largest Hacker News item ID
Return the ID of the most recently created Hacker News item. Useful as an upper bound for walking the full item range or detecting new activity since a previous poll.
List Hacker News story IDs
List Hacker News story ids from a named feed. Use `/hacker-news/items/{id}` to fetch item details.
Get Hacker News item by ID
Fetch a single Hacker News item. Stories, comments, jobs, polls, and poll options share the same item shape.
List the comment tree of a Hacker News story
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.
Get a Hacker News comment with its thread
Returns a Hacker News comment with its ancestor chain up to the root story. Returns `not_found` when the comment does not exist.
List jobs from Who is Hiring
Returns the top-level job posts from the monthly Hacker News "Who is Hiring" thread, for the latest month or a given `month` (YYYY-MM). Paginate with `cursor`.