Skip to main content

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"

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.

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

macos_messages-0.1.1.tar.gz (74.1 kB view details)

Uploaded Source

Built Distribution

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

macos_messages-0.1.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file macos_messages-0.1.1.tar.gz.

File metadata

  • Download URL: macos_messages-0.1.1.tar.gz
  • Upload date:
  • Size: 74.1 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

Hashes for macos_messages-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ec997c65a6686cb3192ac910c68a0cee0386d3fd3040992e9c3340ede88906d9
MD5 0f2d28dc59c74ef99c2c874dd0d0ab9f
BLAKE2b-256 b212767452ffffcd7e5c637931f7635f12534f6cec7a3bacdfde438fbe574799

See more details on using hashes here.

File details

Details for the file macos_messages-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: macos_messages-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 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

Hashes for macos_messages-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eac3ed1d618826c22a1f559752403c65c8a242a34d119eb2dd15dc2bc36427db
MD5 a9180d88de911bcf86a8075d20572f6b
BLAKE2b-256 b703b4246dc8e4fdc0a0b4988889e439c65254a65fb7e8a5d36e17ba9e611241

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