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.0.tar.gz (73.8 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.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: macos_messages-0.1.0.tar.gz
  • Upload date:
  • Size: 73.8 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.0.tar.gz
Algorithm Hash digest
SHA256 5323a0b590ee2639472a6ba0c40f6b26c0b51ac2865933269f61997b25df165a
MD5 0fb10807702af149ec0f5f87973519cd
BLAKE2b-256 bd495823d58e378d84dc20b456614082f13be7a4860c451af3578a7e60ec414f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: macos_messages-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d193a73562dcb4c3ac76e5475a375ce9075761f0f57336da57c44d6386411145
MD5 4648005a30bde1be13929f65eee2ed9f
BLAKE2b-256 648bba9004bd702ccd2c3aaa6eb64f156be532278a486de72e8ea6e49f22c203

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