News

Search Hacker News stories and comments · Hacker News API

GET/hacker-news/search
$min $0.003

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

Request
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.
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

  • 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.
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 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

200400401402404429500502503

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.

Response fields

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.
Run it

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.