Highlights API?

As I’m getting back into reading, keeping track of books in micro.blog bookshelves has been useful.

I added a micro.blog connector into sync.crosspointreader.com which will add books to currently reading or finished bookshelves (moving them from want to read / currently reading if appropriate).

The upcoming crosspoint release will include “clippings” - the ability to save highlights from a book. These will get sync’d to crosspoint sync as well… so naturally, I’d like to sync them to micro.blog’s highlights. However, I can’t find an API to create highlights, only to read and delete them?

Sounds cool! There’s not a documented API for creating highlights yet. I was worried that because it uses offsets into the text of the post, it would be fragile and just be annoying to work with.

But if you want to use it anyway, this is what Micro.blog currently does when creating highlights. There are actually two flavors: one for bookmarked posts, and one for posts in Inkwell. I’ll assume you mean bookmarks, so it looks like this.

You’ll need the “link ID”, which you can find in one of two authenticated JSON Feeds:

GET /posts/bookmarks
GET /posts/bookmarks/links

Then to create a highlight:

POST /bookmarks/{link_id}/highlights

And pass 3 parameters as either JSON or form-encoded fields:

  • text
  • start
  • end

For example like this:

curl "https://micro.blog/bookmarks/12345/highlights" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Selected text.",
    "start": 120,
    "end": 134
  }'

thanks! I’ll take a look to see if I can make this work :slight_smile:

I think I have to rethink this - maybe creating a clippings post linking the book rather than using highlights