--- license: odc-by task_categories: - text-generation - feature-extraction - text-classification - question-answering language: - en pretty_name: Hacker News — Complete Archive size_categories: - 10M 0 ORDER BY descendants DESC LIMIT 20; ``` ```sql -- Who posts the most Ask HN questions? SELECT by, count(*) AS posts FROM read_parquet('hf://datasets/open-index/hacker-news/data/*/*.parquet') WHERE type = 'story' AND title LIKE 'Ask HN:%' GROUP BY by ORDER BY posts DESC LIMIT 20; ``` ```sql -- Domain popularity over time SELECT extract(year FROM time) AS year, regexp_extract(url, 'https?://([^/]+)', 1) AS domain, count(*) AS stories FROM read_parquet('hf://datasets/open-index/hacker-news/data/*/*.parquet') WHERE type = 'story' AND url != '' GROUP BY year, domain QUALIFY row_number() OVER (PARTITION BY year ORDER BY stories DESC) <= 5 ORDER BY year, stories DESC; ``` ### Python (datasets) ```python from datasets import load_dataset # Stream the full history (no download required) ds = load_dataset("open-index/hacker-news", split="train", streaming=True) for item in ds: print(item["id"], item["type"], item["title"]) # Load a specific year into memory ds = load_dataset( "open-index/hacker-news", data_files="data/2024/*.parquet", split="train", ) print(f"{len(ds):,} items in 2024") ``` ### Python (pandas + DuckDB) ```python import duckdb conn = duckdb.connect() # Compute score percentiles df = conn.sql(""" SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY score) AS p50, percentile_disc(0.90) WITHIN GROUP (ORDER BY score) AS p90, percentile_disc(0.99) WITHIN GROUP (ORDER BY score) AS p99, percentile_disc(0.999) WITHIN GROUP (ORDER BY score) AS p999 FROM read_parquet('hf://datasets/open-index/hacker-news/data/*/*.parquet') WHERE type = 'story' """).df() print(df) ``` ### Download Specific Files ```python from huggingface_hub import snapshot_download # Download only 2024 data snapshot_download( "open-index/hacker-news", repo_type="dataset", local_dir="./hn/", allow_patterns="data/2024/*", ) ``` ```bash # CLI: download a single month huggingface-cli download open-index/hacker-news \ data/2024/2024-01.parquet \ --repo-type dataset --local-dir ./hn/ ``` --- ## Schema Every Parquet file shares the same schema, matching the [HN API](https://github.com/HackerNewsAPI/HN-API) item format: | Column | Type | Description | |--------|------|-------------| | `id` | int64 | Unique item ID (monotonically increasing) | | `deleted` | bool | `true` if soft-deleted by author or moderators | | `type` | string | One of: `story`, `comment`, `job`, `poll`, `pollopt` | | `by` | string | Username of the author | | `time` | timestamp | Post timestamp (UTC) | | `text` | string | HTML body text (comments, Ask HN, jobs) | | `dead` | bool | `true` if flagged/killed by moderators | | `parent` | int64 | Parent item ID (comments only) | | `poll` | int64 | Associated poll ID (poll options only) | | `kids` | list\ | Direct child item IDs | | `url` | string | External URL (stories with links) | | `score` | int64 | Points (upvotes minus downvotes) | | `title` | string | Title text (stories, jobs, polls) | | `parts` | list\ | Poll option item IDs (polls only) | | `descendants` | int64 | Total comment count in the discussion tree | --- ## Data Architecture ### File Layout ``` open-index/hacker-news/ data/ 2006/2006-10.parquet # first HN month with data 2006/2006-12.parquet 2007/2007-01.parquet ... 2026/2026-02.parquet # most recent complete month today/ 2026-03-14_00_00.parquet # 5-minute live blocks 2026-03-14_00_05.parquet ... stats.csv # one row per committed month stats_today.csv # one row per committed 5-min block README.md ``` ### Update Pipeline This dataset is maintained by an automated pipeline: 1. **Historical backfill** — On first run, fetches every month from 2006-10 to the most recent complete month. Each month is committed as a single Parquet file. Months already committed (tracked in `stats.csv`) are skipped, making the process resumable. 2. **Live polling** — After backfill, polls the source every 5 minutes for new items. Each batch is committed as `today/YYYY-MM-DD_HH_MM.parquet`. 3. **Day rollover** — At midnight UTC, all of today's 5-minute blocks are merged into the monthly Parquet file using DuckDB, then the individual blocks are deleted. Data is sourced from the [ClickHouse Playground](https://sql.clickhouse.com) which mirrors the official HN Firebase API. ### Parquet Compression All files use **Zstandard (zstd)** compression at level 22 for optimal size. Monthly files are sorted by `id` for efficient range scans. --- ## Dataset Stats Detailed per-month statistics are available in `stats.csv`: | Column | Description | |--------|-------------| | `year`, `month` | Calendar month | | `lowest_id`, `highest_id` | Item ID range in this file | | `count` | Number of items | | `dur_fetch_s` | Seconds to fetch from source | | `dur_commit_s` | Seconds to commit to Hugging Face | | `size_bytes` | Parquet file size | | `committed_at` | ISO 8601 commit timestamp | ```sql -- Query the stats directly SELECT * FROM read_csv_auto('hf://datasets/open-index/hacker-news/stats.csv') ORDER BY year, month; ``` --- ## License Released under the **Open Data Commons Attribution License (ODC-By) v1.0**. Original content is subject to the rights of its respective authors. Hacker News data is provided by [Y Combinator](https://www.ycombinator.com). This dataset is an independent mirror — it is not affiliated with or endorsed by Y Combinator. --- *Last updated: 2026-03-14 10:23 UTC*