Skip to content

最后更新

更新日志

Hacker News API

正常只读

Hacker News 的帖子列表(首页、最新、Ask HN、Show HN),含排名、标题、链接、来源网站、得分、作者、评论数和发布时长,还可获取任意条目的详情及其完整的嵌套评论树。 来源: news.ycombinator.com.

基础 URL
https://api.maviapi.com/v1/sites/hackernews
7
端点
53 min ago
最近验证
100%
可用率 / 7 天
1388ms
p50 延迟
GET/front5 credits per call

首页

按 HN 排名顺序返回 Hacker News 首页上的帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

Bearer auth. Pass your key as Authorization: Bearer <key> on every request.
integerOptionalin query

page number, 1 to 17 (30 stories per page).

feedstringe.g."front"
pageintegere.g.1
countintegere.g.30
storiesobject[]12 fields
rankintegere.g.1
idintegere.g.50663595
titlestringe.g."The group chat where your AI talks behind your back"
urlstringe.g."https://construct22.com/"
sitestringe.g."construct22.com"
pointsintegere.g.238
authorstringe.g."utiiiD"
comment_countintegere.g.104
agestringe.g."3 hours ago"
posted_atstringe.g."2026-11-27T06:44:34Z"
typestringe.g."story"
hn_urlstringe.g."https://news.ycombinator.com/item?id=50663595"
nextobject1 field
pstringe.g."2"
paginationobject3 fields
countintegere.g.30
has_morebooleane.g.false
next_cursornull
fetched_atstringe.g."2026-11-27T10:11:48.780Z"
ageintegere.g.0
Try itLive
GET
https://api.maviapi.com/v1/sites/hackernews/front?p=1
Request
curl "https://api.maviapi.com/v1/sites/hackernews/front?p=1" \
-H "Authorization: Bearer $MAVI_KEY"
Example670 B
{
  "feed": "front",
  "page": 1,
  "count": 30,
  "stories": [
    {
      "rank": 1,
      "id": 50663595,
      "title": "The group chat where your AI talks behind your back",
      "url": "https://construct22.com/",
      "site": "construct22.com",
      "points": 238,
      "author": "utiiiD",
      "comment_count": 104,
      "age": "3 hours ago",
      "posted_at": "2026-11-27T06:44:34Z",
      "type": "story",
      "hn_url": "https://news.ycombinator.com/item?id=50663595"
    }
  ],
  "next": {
    "p": "2"
  },
  "pagination": {
    "count": 30,
    "has_more": false,
    "next_cursor": null
  },
  "fetched_at": "2026-11-27T10:11:48.780Z",
  "age": 0
}

Get all the data, no code

Collect every page of GET /front into a dataset, for one request or for a whole list of them, then download it as CSV or JSON. A page costs the same as one call of the endpoint; the download is free.

Use Hacker News API from Claude, ChatGPT and your coding tools

Add this URL as a custom connector and sign in to maviapi. Nothing to install.

How to connect
https://mcp.maviapi.com/mcp

Or run it locally, with each endpoint of Hacker News API as its own tool:

claude mcp add maviapi -e MAVIAPI_TOOLS=hackernews -- npx -y '@maviapi/mcp'

Import Hacker News API into Postman and other tools

How to import

Paste a link into Postman, Insomnia, an agent framework or a no-code tool to get every endpoint with its parameters and response fields. The link always serves the current endpoints, so importing it again picks up new ones.

  • OpenAPI 3.1
    https://api.maviapi.com/v1/apis/hackernews/openapi.json
  • Postman
    https://api.maviapi.com/v1/apis/hackernews/postman.json

The Postman collection sends the shared demo key until you put your own key in its maviapi_key variable.

使用 Hacker News API 进行开发

选择一个端点开始

  • 首页 GET /front

    按 HN 排名顺序返回 Hacker News 首页上的帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

    GET /front 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    pinteger / query否page number, 1 to 17 (30 stories per page).
    响应字段
    字段类型说明
    feedstring
    pageinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitestring
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    nextobject
    next.pstring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger
  • Ask HN GET /ask

    按 HN 排名顺序返回 Ask HN 帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

    GET /ask 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    pinteger / query否page number, 1 to 17 (30 stories per page).
    响应字段
    字段类型说明
    feedstring
    pageinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitenull
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    nextobject
    next.pstring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger
  • 条目 GET /item/{id}

    按 id 获取单个 Hacker News 条目(帖子、Ask/Show HN、招聘、投票或单条评论):type、title、url、site、text、points、author、comment_count、age、posted_at(UTC),评论另含 parent_id / story_id / story_title,投票另含 poll_options,并以嵌套树形式返回完整评论串(顶层按 HN 顺序排列,每条评论包含 id、author、age、posted_at、depth、parent_id、纯文本、原始 html、删除标记和 replies)。thread_source 为 "algolia" 表示完整评论树;条目过新尚未被索引时为 "firebase",表示有限范围的实时遍历结果。

    GET /item/{id} 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    idinteger / path是Hacker News item id.
    响应字段
    字段类型说明
    idinteger
    typestring
    titlestring
    urlstring
    sitestring
    textnull
    pointsinteger
    authorstring
    comment_countinteger
    agestring
    posted_atstring
    parent_idnull
    story_idnull
    story_titlenull
    poll_optionsnull
    hn_urlstring
    comments_totalinteger
    commentsobject[]
    comments[].idinteger
    comments[].authorstring
    comments[].agestring
    comments[].posted_atstring
    comments[].depthinteger
    comments[].parent_idinteger
    comments[].textstring
    comments[].htmlstring
    comments[].deletedboolean
    comments[].repliesobject[]
    comments[].replies[].idinteger
    comments[].replies[].authorstring
    comments[].replies[].agestring
    comments[].replies[].posted_atstring
    comments[].replies[].depthinteger
    comments[].replies[].parent_idinteger
    comments[].replies[].textstring
    comments[].replies[].htmlstring
    comments[].replies[].deletedboolean
    comments[].replies[].repliesobject[]
    comments[].replies[].replies[].idinteger
    comments[].replies[].replies[].authorstring
    comments[].replies[].replies[].agestring
    comments[].replies[].replies[].posted_atstring
    comments[].replies[].replies[].depthinteger
    comments[].replies[].replies[].parent_idinteger
    comments[].replies[].replies[].textstring
    comments[].replies[].replies[].htmlstring
    comments[].replies[].replies[].deletedboolean
    comments[].replies[].replies[].repliesobject[]
    comments[].replies[].replies[].replies[].idinteger
    comments[].replies[].replies[].replies[].authorstring
    comments[].replies[].replies[].replies[].agestring
    comments[].replies[].replies[].replies[].posted_atstring
    comments[].replies[].replies[].replies[].depthinteger
    comments[].replies[].replies[].replies[].parent_idinteger
    comments[].replies[].replies[].replies[].textstring
    comments[].replies[].replies[].replies[].htmlstring
    comments[].replies[].replies[].replies[].deletedboolean
    comments[].replies[].replies[].replies[].repliesobject[]
    comments[].replies[].replies[].replies[].replies[].idinteger
    comments[].replies[].replies[].replies[].replies[].authorstring
    comments[].replies[].replies[].replies[].replies[].agestring
    comments[].replies[].replies[].replies[].replies[].posted_atstring
    comments[].replies[].replies[].replies[].replies[].depthinteger
    comments[].replies[].replies[].replies[].replies[].parent_idinteger
    comments[].replies[].replies[].replies[].replies[].textstring
    comments[].replies[].replies[].replies[].replies[].htmlstring
    comments[].replies[].replies[].replies[].replies[].deletedboolean
    comments[].replies[].replies[].replies[].replies[].repliesobject[]
    comments[].replies[].replies[].replies[].replies[].replies[].idinteger
    comments[].replies[].replies[].replies[].replies[].replies[].authorstring
    comments[].replies[].replies[].replies[].replies[].replies[].agestring
    comments[].replies[].replies[].replies[].replies[].replies[].posted_atstring
    comments[].replies[].replies[].replies[].replies[].replies[].depthinteger
    comments[].replies[].replies[].replies[].replies[].replies[].parent_idinteger
    comments[].replies[].replies[].replies[].replies[].replies[].textstring
    comments[].replies[].replies[].replies[].replies[].replies[].htmlstring
    comments[].replies[].replies[].replies[].replies[].replies[].deletedboolean
    comments[].replies[].replies[].replies[].replies[].replies[].repliesstring[]
    thread_sourcestring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
  • 信息流 GET /feed

    按 HN 顺序返回 Hacker News 帖子列表的第一页(30 条帖子),每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type、hn_url 和 comments。传入 comments=true 时,前 `top` 条帖子附带按 HN 顺序排列的顶层评论,每条顶层评论包含其直接回复;其余帖子的 comments 为 null。

    GET /feed 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    typestring / query否which story list: front, newest, ask or show. 可选值: front, newest, ask, show.
    commentsboolean / query否attach top comments to the first `top` stories.
    topinteger / query否how many stories to enrich with comments (1-5). 可选值: 1, 2, 3, 4, 5.
    comments_per_storyinteger / query否top-level comments, and direct replies under each, per enriched story (1, 3, 5 or 10). 可选值: 1, 3, 5, 10.
    响应字段
    字段类型说明
    feedstring
    with_commentsboolean
    enrichedinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitestring
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    stories[].commentsnull
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger
  • 最新 GET /newest

    Hacker News 最新提交的帖子,按时间倒序排列,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

    GET /newest 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    pinteger / query否page number, 1 to 17 (30 stories per page).
    响应字段
    字段类型说明
    feedstring
    pageinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitestring
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    nextobject
    next.pstring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger
  • Show HN GET /show

    按 HN 排名顺序返回 Show HN 帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

    GET /show 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    pinteger / query否page number, 1 to 17 (30 stories per page).
    响应字段
    字段类型说明
    feedstring
    pageinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitestring
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    nextobject
    next.pstring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger
  • 最佳 GET /best

    Hacker News 最佳帖子(近期得票最高),按排名排列,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。data.next 为下一页的参数,最后一页时为 null。

    GET /best 的参数和响应字段
    请求参数
    名称类型 / 位置必填说明
    pinteger / query否page number, 1 to 7 (30 stories per page).
    响应字段
    字段类型说明
    feedstring
    pageinteger
    countinteger
    storiesobject[]
    stories[].rankinteger
    stories[].idinteger
    stories[].titlestring
    stories[].urlstring
    stories[].sitestring
    stories[].pointsinteger
    stories[].authorstring
    stories[].comment_countinteger
    stories[].agestring
    stories[].posted_atstring
    stories[].typestring
    stories[].hn_urlstring
    nextobject
    next.pstring
    paginationobject
    pagination.countinteger
    pagination.has_moreboolean
    pagination.next_cursornull
    fetched_atstring
    ageinteger

将 Hacker News 数据导出为 CSV

下面的每个列表都可以下载为 CSV 文件,每条记录一行。用上方控制台下面的 "Get all the data, no code" 卡片把列表收集到数据集中。数据集会逐页读取列表,之后可下载为 CSV、JSON 或 JSONL。

列表CSV 列
首页GET /frontrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url
Ask HNGET /askrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url
条目GET /item/{id}id, author, age, posted_at, depth, parent_id, text, html, deleted, replies
信息流GET /feedrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url, comments
最新GET /newestrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url
Show HNGET /showrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url
最佳GET /bestrank, id, title, url, site, points, author, comment_count, age, posted_at, type, hn_url

嵌套的值(列表或对象)以 JSON 写入同一个单元格。 数据集和导出如何工作

Hacker News API 常见问题

能获取什么数据、费用多少、如何调用。

Hacker News 有官方 API 吗?

有,Hacker News 提供自己的 API:Hacker News API(核实日期:2026-11-25)。本页的 Hacker News API 与它无关,是非官方 API:它是 maviapi 针对 news.ycombinator.com 上的公开数据提供的独立托管 API,并非由 Hacker News 开发、认可或支持。

Hacker News API 可以获取哪些数据?

Hacker News API 有 7 个端点。每个端点都返回 JSON,参数和字段见上方的文档:

  • GET /front: 按 HN 排名顺序返回 Hacker News 首页上的帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。
  • GET /ask: 按 HN 排名顺序返回 Ask HN 帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。
  • GET /item/{id}: 按 id 获取单个 Hacker News 条目(帖子、Ask/Show HN、招聘、投票或单条评论):type、title、url、site、text、points、author、comment_count、age、posted_at(UTC),评论另含 parent_id / story_id /…
  • GET /feed: 按 HN 顺序返回 Hacker News 帖子列表的第一页(30 条帖子),每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type、hn_url 和 comments。
  • GET /newest: Hacker News 最新提交的帖子,按时间倒序排列,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。
  • GET /show: 按 HN 排名顺序返回 Show HN 帖子,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。
  • GET /best: Hacker News 最佳帖子(近期得票最高),按排名排列,每页 30 条,每条包含 rank、id、title、url、site、points、author、comment_count、age、posted_at(UTC)、type 和 hn_url。

Hacker News API 的价格是多少?

调用用您 maviapi 套餐中的积分支付,只有成功的调用才会计费。此 API 的每个端点每次调用消耗 5 个积分。在 Hobby 套餐下(每月 $49,含 250,000 个积分),1,000 次调用约 $0.98。失败的调用不收费。Free 套餐每月提供 1,000 个积分,无需信用卡。超出部分请查看套餐和积分价格。

如何调用 Hacker News API?

向端点发送 HTTPS 请求,并在 Authorization 请求头中带上您的 API 密钥。例如 GET /front:

cURL
curl 'https://api.maviapi.com/v1/sites/hackernews/front' \
  -H "Authorization: Bearer $MAVI_KEY"

在您的 API 密钥页面创建密钥,或者先在上方的控制台中用免费测试密钥试用任意端点。

以 JSON 获取 Hacker News 数据有哪些方式?

以 JSON 获取 Hacker News 数据的每种方式适合不同的需求:

  • Hacker News API: 需要写入权限、账号数据或与 Hacker News 签订协议时更合适。
  • 自己写爬虫: 完全由自己掌控,不依赖任何服务商,但解析、被拦截的请求以及 news.ycombinator.com 每次改版后的修复都要自己负责。更适合从很少变化的页面一次性获取数据。
  • Apify: 一个 Actor 市场,Actor 由您自己运行,输入、输出和价格由各个 Actor 决定。当已有 Actor 能返回您需要的数据,或者您想托管自己的代码时更合适。参见maviapi 与 Apify 的对比。
  • RapidAPI: 一个汇集了众多提供方 API 的平台,用一个 RapidAPI 密钥调用,每个 API 单独定价。当您已经在使用该平台,并且其中某个 API 能满足需求时更合适。来源:RapidAPI docs。
  • maviapi: 本页的 Hacker News API:7 个带文档的端点、公开的响应结构,以及一个可用于整个目录的密钥。当这些数据是您产品的一部分,而您不想维护爬虫时更合适。

news.ycombinator.com 改版后会怎样?

您的代码不需要改动。news.ycombinator.com 修改页面时,maviapi 会让 Hacker News API 保持可用,您继续调用同样的端点,并得到本页文档所述结构的 JSON。它当前的运行状况见状态页,变更记录见它的更新日志。

更新会破坏我的 Hacker News API 集成吗?

不会。您正在使用的端点,其结构永远不会改变:新的字段、可选参数和端点只会加在旁边,会破坏调用的变更则作为新端点发布。请忽略您不认识的响应字段,新内容请关注更新日志。

  • Hürriyet API

    来自 Hürriyet 的最新土耳其新闻:汇总各栏目(gündem、ekonomi、dünya、spor 等)、按时间从新到旧排列的综合新闻流,包含标题、摘要、图片、栏目、发布时间、作者、URL…

  • Tripadvisor API

    来自 Tripadvisor 的行程规划数据:支持地点搜索,并可按地点(geo_id)获取景点、餐厅和酒店,包含评分、评论、价格和坐标。先用 /search 解析地名,再通过…

  • Google Maps API

    来自 maps.google.com 的结构化数据。