Hacker News
Hacker News front page, stories, comment threads and users
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available Β· $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/hackernews/index.md to help me query Hacker News with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Read todayβs top stories and discussion counts
Example output Β· captured
- Connector release
- v0.4.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
ORDER BY rank
LIMIT 30
| rank | title | score | comments |
|---|---|---|---|
| 1 | Initial Assessment of Anthropic's Findings on Lattice Cryptography | 488 | 281 |
| 2 | Best Buy will officially sell physical media in stores again | 335 | 208 |
| 3 | Cloudflare Clairic System One Extraction Models Are Now Open-Weight | 60 | 13 |
| 4 | Galactic quasi-polynomial quantum algorithms for integral and module lattices [β¦ | 225 | 114 |
| 5 | Red heads are linked to a mutation that makes them resistant to anesthesia (202β¦ | 96 | 66 |
Quick start
Choose where to run Hacker News, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'hackernews' AS hackernews (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-hackernews'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'hackernews' AS hackernews (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-hackernews:0.4.0'
);
3. Run a query
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
ORDER BY rank
LIMIT 30
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connectorβs deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'hackernews' AS hackernews
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
ORDER BY rank
LIMIT 30
Query Farm operates Hacker News for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use hackernews as the catalog alias for the query below.
4. Run a query
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
ORDER BY rank
LIMIT 30
Technical details
- Verified connector release
- v0.4.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until youβre ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'hackernews' AS hackernews (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-hackernews'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'hackernews' AS hackernews (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-hackernews:0.4.0'
);
Overview
Hacker News front page, stories, comment threads and user profiles, read live from the official API
Hacker News is a link-sharing and discussion site run by Y Combinator. Members submit stories β links, Ask HN questions, Show HN launches, job ads β and discuss them in threaded comments; votes decide what reaches the front page.
How the data is shaped
Everything posted is an item with a numeric id: stories, comments, polls, poll options and jobs share one id sequence and one set of columns. Items point at each other by id β a comment names its parent, a story lists its replies in kids β so reading a discussion means following ids, which the thread function does for you.
Freshness and cost
This is the live site through its official API, not an archive: every query reads the current state, and nothing is cached unless you ask. The API has no search and no batch endpoint, so each item costs one request; requests run 32 at a time and rows stream in pages, so a LIMIT stops early. A whole ranking reads in a second or two, a large thread in a few seconds.
Access
The API is public and unauthenticated, and this worker only reads. Content belongs to its authors.
Catalog
Everything hackernews exposes once attached β read straight from the worker's
released build.
main 9 tables Β· 7 functions
Live, read-only Hacker News data from the public Firebase API β no credentials required
Schema examples (7)
The front page right now, with each story's discussion size
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
ORDER BY rank
LIMIT 30;
| rank | title | score | comments |
|---|---|---|---|
| 1 | Initial Assessment of Anthropic's Findings on Lattice Cryptography | 488 | 281 |
| 2 | Best Buy will officially sell physical media in stores again | 335 | 208 |
| 3 | Cloudflare Clairic System One Extraction Models Are Now Open-Weight | 60 | 13 |
| 4 | Galactic quasi-polynomial quantum algorithms for integral and module lattices [β¦ | 225 | 114 |
| 5 | Red heads are linked to a mutation that makes them resistant to anesthesia (202β¦ | 96 | 66 |
Which sites dominate the front page
SELECT regexp_extract(url, '^https?://(?:www\.)?([^/]+)', 1) AS site,
count(*) AS stories
FROM hackernews.main.top_stories
WHERE url IS NOT NULL
GROUP BY site
ORDER BY stories DESC, site
LIMIT 15;
Read the whole discussion of the current top story, as displayed
SELECT depth, author, hackernews.main.html_to_text(text) AS comment
FROM hackernews.main.comments((SELECT id FROM hackernews.main.top_stories WHERE rank = 1))
WHERE NOT deleted
ORDER BY path;
The karma of each front-page poster
SELECT s.rank, s.author, u.karma
FROM (SELECT rank, author FROM hackernews.main.top_stories WHERE rank <= 30) s,
LATERAL hackernews.main.user(s.author, cache_ttl => 300) u
ORDER BY s.rank;
3 more examples
Front-page stories the change feed lists as active right now (new votes, replies or edits), with their current score and comment count
SELECT t.rank, t.title, u.score, u.descendants AS comments
FROM hackernews.main.top_stories t
JOIN hackernews.main.updated_items u USING (id)
ORDER BY t.rank;
The busiest commenters among the newest 300 items site-wide, with their karma and account age
SELECT r.author, count(*) AS comments, u.karma, u.created_at AS joined
FROM (SELECT author FROM hackernews.main.recent_items(300) WHERE type = 'comment' AND author IS NOT NULL) r,
LATERAL hackernews.main.user(r.author, cache_ttl => 300) u
GROUP BY r.author, u.karma, u.created_at
ORDER BY comments DESC, r.author
LIMIT 10;
Who and what a user's latest comments were replying to
SELECT c.created_at, p.type AS replying_to, p.author AS to_whom,
coalesce(p.title, hackernews.main.html_to_text(p.text)) AS what
FROM (SELECT * FROM hackernews.main.submissions('dang') LIMIT 20) c,
LATERAL hackernews.main.item(c.parent) p
WHERE c.type = 'comment'
ORDER BY c.created_at DESC;
ask_stories
Ask HN questions currently listed, as the Ask HN page ranks them
The Ask HN questions drawing the most answers
SELECT title, descendants AS answers,
hackernews.main.html_to_text(text) AS question
FROM hackernews.main.ask_stories
ORDER BY answers DESC
LIMIT 10;
best_stories
Hacker News' 'best' list: the highest-voted recent stories
The ten highest-scoring stories of the last few days
SELECT title, score, descendants AS comments
FROM hackernews.main.best_stories
ORDER BY score DESC
LIMIT 10;
job_stories
Job ads from Y Combinator companies currently on the Hacker News jobs page
Current job ads, newest first
SELECT title, url, created_at
FROM hackernews.main.job_stories
ORDER BY created_at DESC;
max_item
The id of the newest item on Hacker News, as a single row
The newest item on the site, fetched in full
SELECT i.type, i.author, i.created_at
FROM hackernews.main.max_item m,
LATERAL hackernews.main.item(m.id) i;
SELECT id AS items_posted FROM hackernews.main.max_item();
new_stories
The 500 most recently submitted Hacker News stories, newest first
The newest submissions that are already drawing votes
SELECT title, author, score, created_at
FROM hackernews.main.new_stories
WHERE score > 1
ORDER BY created_at DESC
LIMIT 20;
show_stories
Show HN posts currently listed: things members have built, as the Show HN page ranks them
The Show HN launches getting the strongest response
SELECT title, url, score, descendants AS comments
FROM hackernews.main.show_stories
ORDER BY score DESC
LIMIT 10;
top_stories
The Hacker News front page ranking: up to 500 stories and job ads, in the order the site shows them
The first page of Hacker News, stories only
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.top_stories
WHERE type = 'story'
ORDER BY rank
LIMIT 30;
updated_items
Items Hacker News reports as just changed β new replies, votes, edits β in their current state
Which stories are gaining activity right now
SELECT title, score, descendants AS comments
FROM hackernews.main.updated_items
WHERE type = 'story'
ORDER BY score DESC;
Front-page stories the change feed lists as active right now (new votes, replies or edits), with their current score and comment count
SELECT t.rank, t.title, u.score, u.descendants AS comments
FROM hackernews.main.top_stories t
JOIN hackernews.main.updated_items u USING (id)
ORDER BY t.rank;
SELECT type, count(*) AS changed
FROM hackernews.main.updated_items()
GROUP BY type
ORDER BY changed DESC;
updated_users
User profiles Hacker News reports as just changed, usually because their karma moved
Recently active users, by karma
SELECT username, karma, created_at, len(submitted) AS posts
FROM hackernews.main.updated_users
ORDER BY karma DESC;
SELECT username, karma, len(submitted) AS posts
FROM hackernews.main.updated_users()
ORDER BY karma DESC;
html_to_text (value VARCHAR)
Turn Hacker News' HTML (comment bodies, text posts, profiles) into plain text
Decode a snippet of comment HTML
SELECT hackernews.main.html_to_text('Don't <i>panic</i> & carry on') AS plain;
Search comment text on a thread without tripping over HTML entities
SELECT id, author
FROM hackernews.main.comments(8863)
WHERE hackernews.main.html_to_text(text) ILIKE '%don''t%'
ORDER BY path;
comments (id BIGINT, max_depth := BIGINT)
The whole discussion under a Hacker News story or comment, one row per reply
The Dropbox launch thread, read top to bottom
SELECT depth, author, hackernews.main.html_to_text(text) AS comment
FROM hackernews.main.comments(8863)
WHERE NOT deleted AND NOT dead
ORDER BY path;
Who talked most in the discussion of the current top story
SELECT author, count(*) AS comments
FROM hackernews.main.comments((SELECT id FROM hackernews.main.top_stories WHERE rank = 1))
WHERE author IS NOT NULL
GROUP BY author
ORDER BY comments DESC, author
LIMIT 10;
How many direct replies each of the top five stories has drawn
SELECT s.rank, s.title, count(c.id) AS replies
FROM (SELECT rank, id, title FROM hackernews.main.top_stories WHERE rank <= 5) s,
LATERAL hackernews.main.comments(s.id, max_depth => 1) c
GROUP BY s.rank, s.title
ORDER BY s.rank;
item (id BIGINT, cache_ttl := BIGINT)
Look up any Hacker News story, comment, job or poll by its numeric id
The Dropbox launch post, from 2007
SELECT title, author, created_at, url FROM hackernews.main.item(8863);
The top-level comments on the current number one story, in display order
SELECT k.position, c.author, hackernews.main.html_to_text(c.text) AS comment
FROM (SELECT unnest(kids) AS kid, generate_subscripts(kids, 1) AS position FROM hackernews.main.top_stories WHERE rank = 1) k,
LATERAL hackernews.main.item(k.kid) c
ORDER BY k.position;
How a poll's votes split across its options
SELECT o.text AS option, o.score AS votes
FROM (SELECT unnest(parts) AS part FROM hackernews.main.item(126809)) p,
LATERAL hackernews.main.item(p.part) o
ORDER BY votes DESC;
recent_items (count BIGINT)
The latest items posted anywhere on Hacker News, comments and stories alike
What has been posted in the last few hundred items, by type
SELECT type, count(*) AS items, min(created_at) AS since
FROM hackernews.main.recent_items(500)
GROUP BY type
ORDER BY items DESC;
The newest stories submitted anywhere on the site
SELECT id, title, author, created_at
FROM hackernews.main.recent_items(1000)
WHERE type = 'story'
ORDER BY id DESC;
The busiest commenters among the newest 300 items site-wide, with their karma and account age
SELECT r.author, count(*) AS comments, u.karma, u.created_at AS joined
FROM (SELECT author FROM hackernews.main.recent_items(300) WHERE type = 'comment' AND author IS NOT NULL) r,
LATERAL hackernews.main.user(r.author, cache_ttl => 300) u
GROUP BY r.author, u.karma, u.created_at
ORDER BY comments DESC, r.author
LIMIT 10;
stories (feed VARCHAR)
The stories on one Hacker News list, chosen by name, in the order the site ranks them
The first page of Hacker News as it stands right now
SELECT rank, title, score, descendants AS comments
FROM hackernews.main.stories('top')
ORDER BY rank
LIMIT 30;
Stories on both the front page and the best list
SELECT t.rank AS top_rank, b.rank AS best_rank, t.title
FROM hackernews.main.stories('top') t
JOIN hackernews.main.stories('best') b USING (id)
ORDER BY t.rank;
submissions (username VARCHAR)
Everything one Hacker News user has posted β stories, comments, polls β newest first
Paul Graham's highest-scoring stories among his latest 200 posts
SELECT title, score, created_at
FROM (SELECT * FROM hackernews.main.submissions('pg') LIMIT 200)
WHERE type = 'story'
ORDER BY score DESC
LIMIT 10;
What a user has been commenting on lately
SELECT created_at, parent, hackernews.main.html_to_text(text) AS comment
FROM (SELECT * FROM hackernews.main.submissions('dang') LIMIT 20)
WHERE type = 'comment'
ORDER BY created_at DESC;
Who and what a user's latest comments were replying to
SELECT c.created_at, p.type AS replying_to, p.author AS to_whom,
coalesce(p.title, hackernews.main.html_to_text(p.text)) AS what
FROM (SELECT * FROM hackernews.main.submissions('dang') LIMIT 20) c,
LATERAL hackernews.main.item(c.parent) p
WHERE c.type = 'comment'
ORDER BY c.created_at DESC;
user (username VARCHAR, cache_ttl := BIGINT)
Look up a Hacker News user's public profile and karma by username
Paul Graham's account
SELECT username, created_at, karma, len(submitted) AS posts
FROM hackernews.main.user('pg');
Karma of the people who posted today's front page
SELECT s.rank, s.author, u.karma, u.created_at AS joined
FROM (SELECT rank, author FROM hackernews.main.top_stories WHERE rank <= 30) s,
LATERAL hackernews.main.user(s.author, cache_ttl => 300) u
ORDER BY s.rank;
Try these queries
an_old_item_is_stable β Item 8863 is Dropbox's 2007 launch post; its title and author never change.
SELECT title, author, type FROM hackernews.main.item(8863);
Uses item
unix_time_becomes_a_timestamp β created_at is a real instant: pg's account dates from 1160418092 in Unix time.
SELECT username, CAST(epoch(created_at) AS BIGINT)
FROM hackernews.main.user('pg');
Uses user
a_thread_is_rooted_and_nested β Every comment in a thread names its root, and the walk starts at depth 1.
SELECT bool_and(root_id = 8863), min(depth), bool_and(len(path) = depth)
FROM hackernews.main.comments(8863);
Uses comments
a_limit_stops_a_ranking_early β A ranking streams in pages, so a LIMIT yields its rows without reading the rest.
SELECT count(*) FROM (SELECT id FROM hackernews.main.top_stories LIMIT 30);
Uses top_stories
ranks_are_dense_from_one β A list's ranks run 1..n with no gaps or repeats.
SELECT min(rank) = 1 AND max(rank) = count(*) AND count(DISTINCT rank) = count(*)
FROM hackernews.main.job_stories;
Uses job_stories
html_is_decoded β html_to_text decodes entities and drops markup.
SELECT hackernews.main.html_to_text('Don't <i>panic</i> & carry on');
Uses html_to_text
4 more examples Hide 4 more
an_unassigned_id_is_no_row β An id with no item behind it returns nothing rather than an error.
SELECT count(*) FROM hackernews.main.item(999999999999);
Uses item
a_poll_lists_its_options β A poll carries the ids of its options in parts.
SELECT type, len(parts) FROM hackernews.main.item(126809);
Uses item
a_depth_cap_stops_the_walk β max_depth => 1 returns exactly the story's direct replies.
SELECT (SELECT count(*) FROM hackernews.main.comments(8863, max_depth => 1)) = (SELECT len(kids) FROM hackernews.main.item(8863));
the_site_has_tens_of_millions_of_items β max_item is the newest id, and ids are assigned in sequence.
SELECT id > 40000000 FROM hackernews.main.max_item;
Uses max_item
34 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- What are the titles of the five stories at the top of the Hacker News front page right now, in order?
- Which three stories were submitted to Hacker News most recently? Give their titles and authors.
- How many stories are on the Hacker News front page and on its 'best' list at the same time?
- Which story on Hacker News' 'best' list has the highest score at the moment?
- Of the Ask HN questions currently listed, which one has drawn the most comments?
- What is the highest-scoring Show HN post currently listed on Hacker News?
Hacker News is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Bluesky
News, social & research
Bluesky posts, threads, profiles, followers, feeds, trends and the live Jetstream firehose
News
News, social & research
Search worldwide news articles from SQL via GDELT (free) or NewsAPI (with a key)
Open Graph
News, social & research
Parse Open Graph, Twitter Card and HTML link-preview metadata from HTML text or URLs