This contains the source code for my website.
/books displays highlights I've enjoyed in the Apple Books I've read so far.
This is done using a small script that exports your Apple Books highlights into static/data/books-highlights.json, which powers the /books page.
- macOS (Apple Books stores its data locally in macOS app container databases)
- Node.js + npm
From the repo root:
npm run sync-booksThis will:
- Read Apple Books SQLite databases from
~/Library/Containers/com.apple.iBooksX/Data/Documents/ - Write the generated JSON to
static/data/books-highlights.json - Preserve spotlight highlights: The sync automatically saves and restores any
spotlightflags andspotlightNotedata
If you need to run a raw sync without preserving spotlight data:
npm run sync-books-rawA helper script exists to create a daily sync runner:
bash scripts/setup-cron.shThen follow the printed instructions to add the generated daily-sync.sh script to your crontab.
- No highlights exported
- Make sure you actually have highlights in Apple Books.
- Open Apple Books once before syncing (so the databases exist locally).
- Permissions / file not found
- Apple may restrict access to
~/Library/Containers/...depending on your macOS privacy settings. - Confirm the folders exist:
~/Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation/~/Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary/
- Apple may restrict access to