Skip to main content

Python bindings for iMessage and Contacts database access

Project description

Text Imp

Python bindings for iMessage and Contacts database access. Requires MacOS and full file system access to run.

Requirements

  • Python >= 3.8
  • macOS (for iMessage database access)
  • uv package manager (recommended) or pip

Installation

This package requires Python 3.8 or later. We recommend using uv for package management.

Using uv (Recommended)

uv pip install text_imp

Using pip

pip install text_imp

Development Setup

  1. Clone the repository:
git clone https://github.com/yourusername/text_imp.git
cd text_imp
  1. Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create a virtual environment and install dependencies:
uv venv
source .venv/bin/activate  # On Unix/macOS
# or
.venv\Scripts\activate  # On Windows

# Install the package in editable mode with all dependencies
uv pip install -e .

Usage Example

import text_imp

# Get messages
messages = text_imp.get_messages()
print(messages)

# Get contacts
contacts = text_imp.get_contacts()
print(contacts)

# Get attachments
attachments = text_imp.get_attachments()
print(attachments)

# To join with messages table, use guid version of
# attachments with message guid
attachments_with_id = get_attachments_with_guid()
print(attachments_with_id)

# Get chats
chats = text_imp.get_chats()
print(chats)

# Get  handles
handles = text_imp.get_handles()
print(handles)

# Get chat handles
chat_handles = text_imp.get_chat_handles()
print(handles)

Example Data

Each function returns a Polars DataFrame with structured data. Here are examples of what the returned data looks like:

Messages DataFrame

Columns: date, text, is_from_me, handle_id, chat_id, guid, thread_originator_guid, thread_originator_part, service_type, variant, expressive, announcement_type, num_attachments, is_deleted, group_title, is_edited, is_tapback, is_reply, num_replies, date_delivered, date_read, is_url, has_replies, body

Message DataFrame Example

Contacts DataFrame

Columns: contact_id, first_name, last_name, state, city, normalized_contact_id

Contacts DataFrame Example

Attachments DataFrame

Columns: rowid, filename, uti, mime_type, transfer_name, emoji_description, is_sticker, path, extension, display_filename, file_size

Attachments DataFrame Example

Chats DataFrame

Columns: rowid, chat_identifier, service_name, display_name, name, resolved_display_name

Chats DataFrame Example

Handles DataFrame

Columns: rowid, id, person_centric_id

Handles DataFrame Example

Chat Handles DataFrame

Columns: chat_id, handle_id

Chat Handles DataFrame Example

Project Structure

text_imp/
├── src/           # Rust source code
├── text_imp/      # Python package directory
├── examples/      # Usage examples
├── tests/         # Test files
├── Cargo.toml     # Rust dependencies and configuration
└── pyproject.toml # Python package configuration

Building from Source

The package uses Maturin for building the Rust extensions. To build from source:

# Using uv
uv pip install -e .

# Or verify the installation
uv run --with text_imp --no-project -- python -c "import text_imp"

Troubleshooting

If you encounter the error AttributeError: module 'text_imp' has no attribute 'get_messages', try the following:

  1. Make sure you're on macOS (this package only works on macOS)
  2. Reinstall the package:
uv pip uninstall text_imp
uv pip install text_imp
  1. If installing from source, rebuild the package:
uv pip install -e .

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

text_imp-0.2.0.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

text_imp-0.2.0.1-cp312-cp312-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file text_imp-0.2.0.1.tar.gz.

File metadata

  • Download URL: text_imp-0.2.0.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for text_imp-0.2.0.1.tar.gz
Algorithm Hash digest
SHA256 da9eab5d6419fc1e4fcb31f4c0f713ac17c1cb2277fdaa90fa1077c4f287d57b
MD5 c79854244964fabb79b50ea5b3092719
BLAKE2b-256 0ebae7c2dc981f6a43bd048bb6533ac81d1ca4c794513713a4032a65cc6dfcca

See more details on using hashes here.

File details

Details for the file text_imp-0.2.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for text_imp-0.2.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1f71604d880c370212b936361146114f42998b12914a8152f45ac9058bb1b51
MD5 b9bd85e5695688028e57318c52d2e0cf
BLAKE2b-256 37daf2bbfd54009ed85ffa4e9b9fe9551a8eb647def078c1de2808737d5c474b

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