Open a page, annotation, or bookmark in Apple Books on macOS from DT

Some apps seem to have call-back URLs or a URL scheme. I do not see one for Apple Books.

I would like to put a link in DT that links to a particular, page, bookmark, or annotation, in an EPUB book I have stored in Apple Books. Does anybody know if this is remotely possible?

Here is a scheme for bear. https://bear.app/faq/X-callback-url%20Scheme%20documentation/
Here is some information for iOS. https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html

The only reference I found is a bit dated:

Thank you! This link helped me find more too. Example: https://github.com/bhagyas/app-urls

Did you succeed in doing so, @mmynsted ?
If so, could you please share how?

Google is your friend, as always:

see the 1st answer to the question.
Although I do not believe that this makes it any easier.

Now to the fun part. The URL to open a book in in Books looks like this
ibooks://assetid/451454820
Simple enough, and it works. But (the big but): you have to know the asset id. Two ways for that

  1. If the title is avaiable in the iTunes store, the asset ID is part of its link (says the net, I didn’t check)
  2. Books seems to have an asset ID for all books you throw at it. So you only have to figure that one out …

Easy-peasy. Open terminal, do a
cd ~/Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary
and
ls
You’ll see a file named BKLibrary-xxxx.sqlite. I suppose the xxxx part is different for everyone. Next, do a
sqlite BKLibrary-xxxx.sqlite
That gives you the sqlite> prompt, at which you enter
select ztitle, zassetid from zbklibraryasset;
(yes, the semicolon at the end is required)
And voilà, there’s the list of your book titles with the corresponding asset id.
Still at the sqlite> prompt, type Ctrl-C to exit sqlite.

This procedure is harmless, but still…
WARNING: Follow these steps only if you know what you’re doing. Don’t stray from the path and have a copy of the BKLibrary file stored at a save place. If anything goes awry, restore this copy. As an added precaution, close Books before you meddle with the sqlite file.

2 Likes

Thank you. Using sqlite to find the asset id works and I can then open the item in iBooks.

It seems that ePub documents are dynamic, so it is not possible to open them to a particular numbered page. So a link like ibooks://assetid/888107968#page(10) does not work for ePub books.

Create and format links in iBooks Author

Linking to a specific part of a different book is only supported for non-EPUB format books created with iBooks Author.

When I open an ePub by its iBooks URL the item is opened to the last viewed page. I do not know how this works but it is interesting.

I can see some value in creating a service that would simplify finding the asset id from an ePub item in iBooks. It is too bad that the asset id can not be added to the list view columns. Since deep linking ePubs can’t be done, I am not sure how useful linking to them in iBooks would be.

Thanks again.

1 Like