Personal tools for extracting my own macOS call and text (iMessage/SMS/RCS) history into structured, analysis-ready data, with a fully de-identified variant.
call_history_analysis.py: reads Apple's local CallHistoryDB and Messageschat.dbdatabases, decodes the modernattributedBodybinary message format (recovers message text that the plaintextcolumn no longer reliably stores), and exports raw CSVs plus a daily communication summary shaped like a behavioral-research daily metric.call_history_analysis_hashed.py: the same pipeline, but every contact identifier is hashed with a locally-generated salt using PBKDF2-HMAC-SHA256 (600,000 iterations), and no raw message text is ever written to disk.
Digital phenotyping research studies use passively collected phone data, including call and text metadata, as a proxy for behaviors like social connectedness. iOS no longer exposes that data to third-party apps, so this was a personal project to see what could still be reconstructed locally on a Mac, with privacy handled properly from the start rather than bolted on afterward.
- macOS, with Full Disk Access granted to whatever runs this (Terminal, an IDE, etc.): System Settings → Privacy & Security → Full Disk Access. That permission is the actual blocker for reading these databases, not encryption.
- Python 3.10+
pip install pandas pytypedstream
python3 call_history_analysis.py # raw export
python3 call_history_analysis_hashed.py # de-identified export
Both write to ~/Desktop/call_message_export/ by default (raw CSVs, a daily summary CSV, and for the hashed variant, a local salt file that's never included in any export).
The hashed variant never writes raw message text or unhashed contact identifiers to disk. The salt file is generated locally, permissioned chmod 600, and should never be committed or shared alongside the hashed CSVs, since a salted hash of a small keyspace like a phone number is only as safe as the salt staying private.
ZCALLTYPEcodes and the message table's timestamp scale (nanoseconds vs. seconds) were verified empirically against real data on the machine this was built on, and should be re-checked if run on a different macOS version.- The
~/Library/Application Support/CallHistoryDBschema is undocumented and could change between macOS releases.