Lately, I’ve been trying to simplify my workflows. Two truths recently hit me like a surreptitious note-taking app subscription:
- I use way too many apps and it stresses me out.
- I am all in on the Apple ecosystem (iPhone, Macbook, iPad, Watch). I’m going to start exploring just using the damn apps that come with my devices (Reminders, Notes, Pages (maybe)). While I still think that Obsidian will remain a part of my toolkit, I’m starting to move more to the Apple native apps for my daily drivers. One of the crucial components of my writing life is Readwise. I highlight pretty much everything I read (even if I need to do it manually, in the case of physical books and magazines). Readwise ingests all of these highlights and makes them available and searchable for me. I use the official Readwise plugin to sync these highlights with Obsidian.
When I thought about using Apple Notes, I quickly realized that there is not an official option for syncing the highlights. However, Readwise does provide a public API. After some quick searching I came upon this Reddit thread. The author gave me exactly what I was looking for via Apple Shortcuts. There was just one thing missing.
Readwise API Pagination
When I first ran the shortcut, it looked like everything was running perfectly. However, I soon found out that the API call was only returning 26 entries. I needed to import my entire Readwise Highlights list.
I was running into API Pagination (I’ll let this Perplexity search handle a deeper dive on the topic.) Basically, the Readwise API was sending the results in “pages” with a page marker number at the end of the entry. I have around 809 books, magazines, podcasts, tweets, etc. in Readwise, so 26 entries barely scratched the surface. I needed a way to do an initial sync of ALL my highlights.
So, I made an adjustment to the shortcut that calls the Readwise API to track pages and keep requesting until I’ve reached the end of the results. The basic logic is this:
- Make an initial API call to get results.
- Store the results in a highlights variable to be used later for ALL the highlights.
- If there is a nextPageCursor value, then make the call again.
- Keep looping the API call and highlights variable update until there is no value for nextPageCursor
- Finally, the results stored in the highlights variable are passed to the next shortcut that actually processes the highlights and creates the notes in Apple Notes. This worked! All of my Readwise highlights are now in Apple Notes.
Still to do:
- Figure out a way to parse the Readwise system tags (for outlining like .h1, .h2, etc.)
- Maybe some aesthetic improvements
The shortcuts can be found here.