Skip to main content

Python library for Apple Books

Project description

PyAppleBooks

PyAppleBooks is a Python API library to access your Apple Books Data.

PyPI License: MIT Buy Me A Coffee

Installation

pip install py_apple_books

Available Functions

Function Description Parameters Return Type
list_collections() List all collections in Apple Books None ModelIterable
get_collection_by_id(collection_id) Get a collection by its ID collection_id: str Collection
get_collection_by_title(title) Get a collection by its title title: str Collection
list_books() List all books in the Apple Books library None ModelIterable
get_book_by_id(book_id) Get a book by its ID book_id: str Book
list_annotations() List all annotations across all books None ModelIterable
get_annotation_by_id(annotation_id) Get an annotation by its ID annotation_id: str Annotation
get_annotations_by_color(color) Get annotations by color color: str ModelIterable
search_annotation_by_highlighted_text(text) Search for annotations by highlighted text text: str ModelIterable
search_annotation_by_note(note) Search for annotations by note note: str ModelIterable
search_annotation_by_text(text) Search for annotations by any text that contains the given text text: str ModelIterable

Examples

Creating a client

from py_apple_books import PyAppleBooks

api = PyAppleBooks()

Get all books from your library

books = api.list_books()
for book in books:
    print('-'*50)
    print(f"Title: {book.title}")
    print(f"Author: {book.author}")
# Sample output
--------------------------------------------------
Title: The Rational Optimist
Author: Matt Ridley
--------------------------------------------------
Title: Einstein: His Life and Universe
Author: Walter Isaacson
--------------------------------------------------
Title: Steve Jobs
Author: Walter Isaacson

Get all annotations

annotations = api.list_annotations()
for annotation in annotations:
    print('-' * 50)
    print(f'Selected text: {annotation.selected_text}')
# sample output
--------------------------------------------------
Selected text: Genomes contain the instructions for building an organism.
--------------------------------------------------
Selected text: Uniqueness is a commodity in oversupply.

Get annotations by color

annotations = api.get_annotations_by_color('green')
for annotation in annotations:
    print('-' * 50)
    print(f'Selected text: {annotation.selected_text}')
    print(f'Color: {annotation.color}')
# sample output
--------------------------------------------------
Selected text: Many things are obvious in retrospect, but still take a flash of genius to become plain.
Color: GREEN
--------------------------------------------------
Selected text: An electron does not have a definite position or path until we observe it.
Color: GREEN

Search for annotations by highlighted text

annotations = api.search_annotation_by_highlighted_text('genomes')
for annotation in annotations:
    print('-' * 50)
    print(f'Selected text: {annotation.selected_text}')
    print(f'Color: {annotation.color}')
# sample output
--------------------------------------------------
Selected text: The human genome - the complete set of human genes - comes packaged in twenty-three separate pairs of chromosomes
Color: YELLOW
--------------------------------------------------
Selected text: Natural selection is the process by which genes change their sequences
Color: GREEN

Get all collections and books

collections = api.list_collections()
for collection in collections:
    print('-'*50)
    print(f"Collection: {collection.title}")
    print(f"Number of books: {len(collection.books)}")
    for book in collection.books:
        print(f"  - {book.title}")
# Sample output
--------------------------------------------------
Collection: Management
Number of books: 1
  - Crucial Conversations
--------------------------------------------------
Collection: Finance
Number of books: 2
  - The Business of the 21st Century Book
  - The Richest Man in Babylon
--------------------------------------------------
Collection: biography
Number of books: 3
  - Elon Musk
  - Steve Jobs
  - Einstein: His Life and Universe

Upcoming Features

  • Adding a book to collection
  • Removing a book from collection
  • Updating annotations

Contribution

Thank you for considering contributing to this project! Your help is greatly appreciated.

Opening Issues

If you encounter a bug, have a feature request, or want to discuss something related to the project, please open an issue on the GitHub repository. When opening an issue, please provide:

Bug Reports: Describe the issue in detail. Include steps to reproduce the bug if possible, along with any error messages or screenshots.

Feature Requests: Clearly explain the new feature you'd like to see added to the project. Provide context on why this feature would be beneficial.

General Discussions: Feel free to start discussions on broader topics related to the project.

Contributing

1️⃣ Fork the GitHub repository https://github.com/vgnshiyer/py-apple-books
2️⃣ Create a new branch for your changes (git checkout -b feature/my-new-feature).
3️⃣ Make your changes and test them thoroughly.
4️⃣ Push your changes and open a Pull Request to main.

Please provide a clear title and description of your changes.

License

PyAppleBooks is licensed under the MIT license. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_apple_books-1.5.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_apple_books-1.5.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file py_apple_books-1.5.0.tar.gz.

File metadata

  • Download URL: py_apple_books-1.5.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for py_apple_books-1.5.0.tar.gz
Algorithm Hash digest
SHA256 d4fc0af7a936d40e7be112245035930ea0125bcb08b4a18462482a89a65818fa
MD5 6fac7537549093c3862881a2e0402e42
BLAKE2b-256 3a87fcfdcddd396c404fe0d44a45641821ee0e4ac23df3c51a74338b1f890f95

See more details on using hashes here.

File details

Details for the file py_apple_books-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: py_apple_books-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for py_apple_books-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30a785cc7c531a1abcfba6cb44ccbe14a8afea090e0c8f3476d6ead2c2576504
MD5 5d807fe0903a7dc4ff17600cc7c74c8f
BLAKE2b-256 d767c9e290c6123969253a57b8a52535909b8bd423a4179e531137ee81b83b8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page