Introducing PyAppleBooks!

A Python library that makes interacting with AppleBooks data easy.

Jan 09, 2024

Post cover

Few weeks ago, I released PyAppleBooks in the official PyPi repository. It is an API build on top of Apple Books that makes it very easy to access your Apple books data. The inspiration to build package came from my intent to remember and go through all my annotations from the books I read. It was a slight discomfort going through annotations for all the books from the app and I wished to have all them to be listed as a notion document that I can access anytime.

I found a few repositories that provided a nice way to exported apple books data to notion (1, 2). However, it gathered only a subset from the plethora of the data the apple books had. I thought it would be cool to write a package that would provide an intuitive interface.

I discovered that Apple Books uses sqlite3 files to maintain local databases for books data. It uses a WAL (Write-Ahead-Log) file which it uses to append temporary interactions which are eventually written to the main database. It later syncs with the local databases in you other devices. It is like a multi-data center replication setup where the data centers here are your Apple devices which go intermittently offline and replicate information when they are back online. Interesting analogy right?

Here is a brief about how to use the package.

Installation

pip install py_apple_books

Using PyAppleBooks

Here are some basic examples of how to use PyAppleBooks

from py_apple_books import PyAppleBooks

api = PyAppleBooks()

Get list of all books

books = api.list_books()
for book in books:
    print('-'*50)
    print(f"Title: {book.title}")
    print(f"Author: {book.author}")
# Sample output
--------------------------------------------------
Title: Think & Grow Rich
Author: Napoleon Hill
--------------------------------------------------
Title: Autobiography of a Yogi (Complete Edition)
Author: Paramahansa Yogananda
--------------------------------------------------
Title: Sapiens
Author: Yuval Noah Harari

Checkout the project page to view the source code and the comprehensive documentation.

Found any issues?

Raise an issue with a terse description.

Final thoughts

PyAppleBooks is very early stage and there are a lot of room for new additions. I encourage everyone to use the package, and report any issues/bugs or requests for new features. Any contribution is highly appreciated.

Subscribe to my RSS feed to get notified about new posts.