← Writing

Building a Better HN API with Rust

I wanted to read Hacker News faster, so I built a small API that returns story comments as a nested tree — and learned a few things about running Rust on the edge along the way.

Why I built it

To deal with information overload, I set out to build my own newspaper. The first step was a fast way to browse Hacker News. English isn't my first language and many technical terms are unfamiliar to me, so I want an AI summary — which means I first need a way to pull the comments for a story.

The problem with the official API

The official API doesn't support nested comments — you can only fetch a story or a single comment at a time, one request each.

My solution

I used Rust and Cloudflare Workers to build an API that returns comments already nested into a tree. The source is on GitHub.

Problems during development

Cloudflare Workers build failure

I couldn't build successfully on Cloudflare Workers (this issue).

Fix: build locally, then push with npx wrangler deploy.

What's next

I plan to use this API to build a tool that summarises Hacker News and recommends whether the articles mentioned in the comments are worth reading.