Python library and CLI for reading macOS Messages.app data
Project description
macos-messages
macos-messages is a Python library and CLI for reading your macOS Messages.app data. It gives you quick, easy, read-only access to your iMessage and SMS history.
Why would I want this?
I built this primarily so AI agents (like Claude running in a terminal) can read my messages on my behalf. When I'm working with an AI assistant and I say "find that restaurant recommendation someone texted me last week," I want it to actually be able to go look.
But it's useful for plenty of other things too:
- Search your messages for something you know someone sent you
- Export conversations for safekeeping
- Build tools that analyze your messaging patterns
- Pipe message data into other scripts
The key thing is that it's read-only. macos-messages can't send messages, modify anything, or access your Apple ID. It just reads what's already on your Mac.
What it looks like
From the command line:
# List your conversations
messages chats
# Get messages from a chat
messages --chat 42
messages --chat "Mom"
# Get messages with a contact
messages --with "Mom"
# Search across everything
messages --search "dinner tomorrow"
# Include messages in "Unknown Senders" (excluded by default)
messages --search "discount" --include-unknown-senders
# List only unread messages
messages --unread
Or in Python:
import messages
db = messages.get_db()
# Get your recent conversations
for chat in db.chats(limit=5):
print(f"{chat.display_name}: {chat.message_count} messages")
# Read messages from a specific chat
for msg in db.messages(chat_id=42, limit=10):
sender = "me" if msg.is_from_me else msg.sender.display_name
print(f"{sender}: {msg.text}")
Installation
uv tool install macos-messages
You'll need to grant Full Disk Access to your terminal app before this will work. See the Permissions guide for instructions.
Documentation
Full documentation is available at macos-messages.readthedocs.io, including:
- Installation - Getting set up
- Quickstart - Your first queries
- CLI Reference - All the commands
- Python Library - Full API docs
- Permissions - macOS permissions explained
Requirements
- macOS
- Python 3.12+
- Full Disk Access permission for your terminal
Contributing
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.
License
The library is available as open source under the terms of the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macos_messages-0.2.0.tar.gz.
File metadata
- Download URL: macos_messages-0.2.0.tar.gz
- Upload date:
- Size: 843.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8827ba2bb52d7a8d982021cc0a31173645e88ff84d24de5a92f836f624049cfe
|
|
| MD5 |
f56663b594841adb80e558e2ceccd48b
|
|
| BLAKE2b-256 |
cc171708e03b9a85e23bca3161200e5b26837cc84a26b581549d971bef3c965d
|
File details
Details for the file macos_messages-0.2.0-py3-none-any.whl.
File metadata
- Download URL: macos_messages-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d721bd352690fce589b57afc927d0d1e5be056381945b2541831a601daa42be
|
|
| MD5 |
791e73043fec00de5abb90a6a22a6d55
|
|
| BLAKE2b-256 |
6ac582c65372fefeeaeb0c6348a8999717320be55d615e2198f3f7349b9f5d1a
|