https://github.com/caleb531/imessage-conversation-analyzer
Gathers metrics of your choice for the entire history of a macOS Messages conversation
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.5%) to scientific vocabulary
Keywords
Repository
Gathers metrics of your choice for the entire history of a macOS Messages conversation
Basic Info
- Host: GitHub
- Owner: caleb531
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://pypi.org/project/imessage-conversation-analyzer/
- Size: 565 KB
Statistics
- Stars: 31
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 16
Topics
Metadata Files
README.md
iMessage Conversation Analyzer
Copyright 2020-2025 Caleb Evans
Released under the MIT license
iMessage Conversation Analyzer (ICA) is a fully-typed Python library (and CLI utility) that will read the contents of an iMessage conversation via the Messages app's database on macOS. You can then gather various metrics of interest on the messages.
Much of this program was inspired by and built using findings from this blog post by Yorgos Askalidis.
Caveats
- Group chats (three or more people) are not supported at this time
- This program only runs on macOS
Installation
Open a Terminal and run the following:
sh
pip3 install imessage-conversation-analyzer
Usage
The package includes both a Command Line API for simplicity/convenience, as well as a Python API for developers who want maximum flexibility.
Command Line API
To use ICA from the command line, run the ica command from the Terminal. The
minimum required arguments are:
- A path to an analyzer file to run, or the name of a built-in analyzer
- The first and last name of the contact, via the
-c/--contactflag- If the contact has no last name on record, you can just pass the first name
Example
sh
ica message_totals -c 'Jane Fernbrook'
The following outputs a table like:
Metric Total
Messages 14535
Messages From Me 7289
Messages From Them 7246
Reactions 5050
Reactions From Me 3901
Reactions From Them 1149
Days Messaged 115
Days Missed 0
Days With No Reply 0
Built-in analyzers
ICA includes several built-in analyzers out of the box:
message_totals: a summary of message and reaction counts, by person and in total, as well as other insightful metricsattachment_totals: lists count data by attachment type, including number of Spotify links shared, YouTube videos, Apple Music, etc.most_frequent_emojis: count data for the top 10 most frequently used emojis across the entire conversationtotals_by_day: a comprehensive breakdown of message totals for every day you and the other person have been messaging in the conversationtranscript: a full, unedited transcript of every message, including reactions, between you and the other person (attachment files not included)count_phrases: count the number of case-insensitive occurrences of any arbitrary strings across all messages in a conversation (excluding reactions); use the-s/--case-sensitiveoption for case-sensitive counts, and the-r/--use-regexoption to enable regular expression mode for all phrases you specify
Filtering
There are several built-in flags you can use to filter messages and attachments.
--from-date: A start date to filter messages by (inclusive); the format must be ISO 8601-compliant, e.g. YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS--to-date: An end date to filter messages by (exclusive); the format must be ISO 8601-compliant, e.g. YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS--from-person: A reference to the person by whom to filter messages; accepted values can beme,them, orboth(the default)
sh
ica message_totals -c 'Jane Fernbrook' --from-date 2024-12-01 --to-date 2025-01-01 --from-person them
Other formats
You can optionally pass the -f/--format flag to output to a specific format
like CSV (supported formats include csv, excel/xlsx, and markdown/md).
sh
ica message_totals -c 'Jane Fernbrook' -f csv
sh
ica ./my_custom_analyzer.py -c 'Jane Fernbrook' -f csv
Writing to a file
Finally, there is an optional -o/--output flag if you want to output to a
specified file. ICA will do its best to infer the format from the file
extension, although you could also pass --format if you have special filename
requirements.
sh
ica transcript -c 'Thomas Riverstone' -o ./my_transcript.xlsx
Python API
The Python API is much more powerful, allowing you to integrate ICA into any
type of Python project that can run on macOS. All of the built-in analyzers
(under the ica/analyzers directory) actually use this API.
Here's a complete example that shows how to retrieve the transcript of an entire iMessage conversation with one other person.
```python
getmytranscript.py
import pandas as pd
import ica
Export a transcript of the entire conversation
def main() -> None:
# Allow your program to accept all the same CLI arguments as the ica
# command; you can skip calling this if have other means of specifying the
# contact name and output format; you can also add your own arguments this
# way (see the countphrases analyzer for an example of this)
cliargs = ica.getcliparser().parseargs()
# Retrieve the dataframes corresponding to the processed contents of the
# database; dataframes include messages and attachments
dfs = ica.getdataframes(
contactname=cliargs.contactname,
timezone=cliargs.timezone,
fromdate=cliargs.fromdate,
todate=cliargs.todate,
fromperson=cliargs.fromperson,
)
# Send the results to stdout (or to file) in the given format
ica.outputresults(
pd.DataFrame(
{
"timestamp": dfs.messages["datetime"],
"isfromme": dfs.messages["isfromme"],
"isreaction": dfs.messages["isreaction"],
# U+FFFC is the object replacement character, which appears as
# the textual message for every attachment
"message": dfs.messages["text"].replace(
r"\ufffc", "(attachment)", regex=True
),
}
),
# The default format (None) corresponds to the pandas default dataframe
# table format
format=cliargs.format,
# When output is None (the default), ICA will print to stdout
output=cliargs.output,
)
if name == "main": main() ```
You can run the above program using the ica command, or execute it directly
like any other Python program.
sh
ica ./get_my_transcript.py -c 'Thomas Riverstone'
sh
python ./get_my_transcript.py -c 'Thomas Riverstone'
sh
python -m get_my_transcript -c 'Thomas Riverstone'
You're not limited to writing a command line program, though! The
ica.get_dataframes() function is the only function you will need in any
analyzer program. But beyond that, feel free to import other modules, send your
results to other processes, or whatever you need to do!
Errors and exceptions
BaseAnalyzerException: the base exception class for all library-related errors and exceptionsContactNotFoundError: raised if the specified contact was not foundConversationNotFoundError: raised if the specified conversation was not foundFormatNotSupportedError: raised if the specified format is not supported by the library
Using a specific timezone
By default, all dates and times are in the local timezone of the system on which
ICA is run. If you'd like to change this, you can pass the --timezone / -t
option to the CLI with an IANA timezone name.
sh
ica totals_by_day -c 'Daniel Brightingale' -t UTC
sh
ica totals_by_day -c 'Daniel Brightingale' -t America/New_York
The equivalent option for the Python API is the timezone parameter to
ica.get_dataframes:
python
dfs = ica.get_dataframes(contact_name=my_contact_name, timezone='UTC')
Developer Setup
The following instructions are written for developers who want to run the package locally, or write their own analyzers.
1. Set up virtualenv
sh
pip3 install virtualenv
sh
virtualenv --python=python3 .virtualenv
source .virtualenv/bin/activate
2. Install project depdendencies
sh
pip install -r requirements.txt
Owner
- Name: Caleb Evans
- Login: caleb531
- Kind: user
- Location: Carlsbad, CA
- Website: https://calebevans.me/
- Twitter: caleb531
- Repositories: 76
- Profile: https://github.com/caleb531
Hi, I'm Caleb, a web developer who lives for Christ by building enjoyable apps and useful tools. I hope you are blessed by what I've made!
GitHub Events
Total
- Release event: 5
- Watch event: 5
- Delete event: 5
- Push event: 104
- Create event: 20
Last Year
- Release event: 5
- Watch event: 5
- Delete event: 5
- Push event: 104
- Create event: 20
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Caleb Evans | c****b@c****e | 416 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 57 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 21
- Total maintainers: 1
pypi.org: imessage-conversation-analyzer
Analyzes the entire history of a macOS Messages conversation
- Documentation: https://imessage-conversation-analyzer.readthedocs.io/
- License: mit
-
Latest release: 2.8.0
published 8 months ago
Rankings
Maintainers (1)
Dependencies
- numpy ==1.22.2
- pandas ==1.3.2
- python-dateutil ==2.8.2
- pytz ==2021.1
- six ==1.16.0
- tabulate ==0.8.9
- urllib3 ==1.26.8
- pandas *
- tabulate *