Skip to main content

macos-messages viewing the last 4 messages from a contact named Nick Wangler. The messages are an excited discussion about a new AI product release.

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:

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.

Metadata

Release files for macos-messages 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for macos-messages 0.2.0
File Size Uploaded
macos_messages-0.2.0.tar.gz 843.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for macos-messages 0.2.0
File Interpreter ABI Platform
macos_messages-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 866.2 kB

Release files / macos_messages-0.2.0.tar.gz

Download URL macos_messages-0.2.0.tar.gz
Size 843.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8827ba2bb52d7a8d982021cc0a31173645e88ff84d24de5a92f836f624049cfe
BLAKE2b-256 checksum
How to use checksums
cc171708e03b9a85e23bca3161200e5b26837cc84a26b581549d971bef3c965d
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / macos_messages-0.2.0-py3-none-any.whl

Download URL macos_messages-0.2.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d721bd352690fce589b57afc927d0d1e5be056381945b2541831a601daa42be
BLAKE2b-256 checksum
How to use checksums
6ac582c65372fefeeaeb0c6348a8999717320be55d615e2198f3f7349b9f5d1a
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page