Mathieu Larose

hnsync: A Hacker News Sync Tool

November 2024

hnsync is a tool designed to efficiently sync Hacker News items to a local SQLite database. It aims to provide a reliable and performant solution for those who want to analyze or monitor Hacker News data locally.

Getting Started

Running hnsync is simple. Just execute:

go run github.com/larose/hnsync@latest

By default, the synced data is stored in a file named hn.db in a table called hn_items. This table contains two key columns:

Example Query

You can easily inspect the data using SQLite:

sqlite> SELECT id, data FROM hn_items LIMIT 1;
id  data
--  ------------------------------------------------------------
1   {"by":"pg","descendants":15,"id":1,"kids":[15,234509,487171,
    82729],"score":57,"time":1160418111,"title":"Y Combinator","
    type":"story","url":"http://ycombinator.com"}

How It Works

The design of hnsync is straightforward yet powerful. It uses four types of workers to handle different aspects of syncing:

Get In Touch

If you've built something using hnsync, I'd love to hear about it! Feel free to reach out and share your project.

Like this article? Get notified of new ones: