← projects

Side project · 2025

Hardcover Wrapped

A Spotify-Wrapped-style recap of your reading year, for anyone on Hardcover.

10
cards in the story
0
tokens stored on the server

Why

I track my books on Hardcover. Every December everyone posts their Spotify Wrapped, and I wanted the same thing for reading, something anyone on Hardcover could use and not just me.

Handling the token

You connect with your Hardcover API key, so the design is about treating it carefully: it stays in your browser (only for the tab, unless you tick “remember”), it’s sent in the body of one request rather than a URL, the server forwards it to Hardcover for that request and never logs or stores it, and you can disconnect at any time. Results are cached for two minutes under a hash of the key, so flipping between years doesn’t hammer Hardcover’s API.

No key? “Try it with mine” loads my own shelf instead. This site fetches it with my token on its server and hands Wrapped only the books, so my key never goes near the browser.

// Short in-memory cache so stepping between years does not re-query Hardcover.
// Keyed by a hash of the token; the token itself is never stored or logged.
const TTL_MS = 2 * 60 * 1000
const keyFor = (token: string) => createHash('sha256').update(token).digest('hex')

export async function fetchReadBooks(token: string): Promise<unknown> {
  const key = keyFor(token)
  const hit = cache.get(key)
  if (hit && Date.now() - hit.at < TTL_MS) return hit.body
  // ...one read-only GraphQL query to Hardcover...
}
ts · lib/hardcover.ts

The story

One GraphQL query pulls every book you’ve marked as read with its finish dates, pages, authors, ratings, tags and cover. From that it builds a tap-through story: books finished, pages turned (compared to a famous long book), your busiest month, top author and genre, longest and shortest, five-star picks, and the first and last book of the year. Cards without enough data just get skipped.

The last card is a summary you can download as an image. Covers come from other domains and would break the export, so the image draws little book spines in each cover’s color instead.

Wrapped card: books finished this year
Books finished
Wrapped card: busiest month bar chart
Busiest month
Wrapped card: five-star books with covers
Five stars
Wrapped summary card with download button
The shareable summary

Edge cases that mattered

Rereads (a book finished twice in a year counts as one book but two reads), books you’re rereading right now, books with no page count, years with nothing finished, and expired keys all get their own handling, and there are tests for each.