What your iMessage data says about you
Nowadays we communicate almost exclusively through text messages. Even my 96 year old grandmother is emoji literate and knows the true meaning of š and š„.
What would an analytic dive into those messages look like? What would we learn about relationships?
Weāll find out and look at building an application around these message visualizations in this article!

Have you ever, tilted a phone away as you wrote a private text?
Would you let a stranger scroll through your conversations?
Its almost uncomfortable to think how revealing and intimate our message history can be. It is a direct record of our relationships with those we deem worthy of texting back.
iMessage dominates the online messaging space due to its locked in nature with Apple devices.
Any developer or heavy computer user who owns a MacBook and iPhone know the unbelievable convenience that iMessages auto syncing is.
Okay, cool ā well enough speculation. What does the data say?
Locked down data
Its not a surprise that this data is not easy to access. iOS has messages completely locked down ā and not accessible through their SDK in any way.
Also with the iPhones locked down environment, we donāt have many options for locating and analyzing the messages on the device.
If only, there was a way for us to realtime export these messagesā¦
š”AH HA! - The desktop app!
Our backdoor in
After a bit of research through Apple documentation we locate out iMessage DB on our MacBook.
If we run this simple command in the t erminalā we get the path to the database.
echo /Users/$USER/Library/Messages/chat.db

Exploring/understanding this mess
We open the database and still its kinda confusing where the good data is. We still need to reverse engineer these database fields ā or dig through Apple documentation.
Lets SQL around for awhile with DB Browser for SQLite ā a simple application for messing with SQLite DBs.

After a few hours, I pieced together enough working SQL and clues from Apple docs to extract the information needed.
This work gets wrapped up in a Python class so I can do some analysis in an Jupyter Notebook.
Heres the snippet to extract the data
Now were equip to do some real analysis with Python ā and then move some of that work into useful visualizations.
š¤·š½ā emojis are important too!
Even without including the text in our analysis we can do some emoji fingerprinting.
We can get a good idea of a relationship, just by showing the number of each emoji sent between myself and another person.
This could be even more descriptive if broken out into sent ā received.
Here are three different emoji grids with friends of mine



Pattern finding
Great we have pretty pictures, and did some aggregation counts on emojis.
However, we want to make sure this stuff makes sense the real world and do some sanity checking.
Here weāll do a deeper analysis and try to tie together a few points of data we extracted.
Below is a hour by day chart with a family member I live with. Also the top emojis are shown on the right.
Immediately we notice the darker squares around 9pm, and the high count of dog emojisā¦ To me, this pattern couldnāt be more clear.
My dog Ness; has his last walk around 9ā10PM. Often my family member walks him if I am unavailable ā or far from home.
These texts are asking if Ness needs to be walked, and sometimes come with a dog emoji.
Great ā things are lining up.
āNecesitas que yo camine con Nessš esta noche?ā
ā family member


All of that for this guy

Lets do it again ā make an Application
Now we have this cool tool but want to make it reusable and repeatable. We are going to use NodeJS for the SQLite connection, Express to serve and Electron to package it all up.
We need to:
- Build a UI ā lets get inspiration from the actual iMessage app!
- Classify the DB connector script ā lets use NodeJS
- Build a small sever to connect UI and DB
- Make a small Electron app wrapper

Building the App
We use the python script written earlier as a starting point on the Node version. We do this language conversion because we eventually want to package this whole thing up into a AppStore Mac app. Electron makes this process easier and we want to keep all of our code in the same language.
First, lets make the electron app shell ā a main.js file that will open a window listening to localhost and the port our UI will run on in dev.
Next, we use express to set up a small server. This sever should return the html page of the application, and have two endpoints ā one to get messages and one to get the last messages; the side bar in iMessage.
Youāll notice that this server is instantiating the DataGrabber class that we have not built yet, this is going to be the translated python class.
When we build it, there are some changes because now we use promises to make sure data is returned instead of relying on pythonās synchronous execution flow.
These are essentially all of the pieces needed to build out the app, we still need a lot of CSS, JS and HTML to make the UI. This Iāll leave up to the reader if they are interested.
āQuestions to the readers
- What kind of information do you think we can extract from our conversations?
- How do we do this?
- What is the danger or benefits of doing this?
- Is this information something people want to know about themselves?
Thanks for getting through this adventure with me. Please show support and š (clap) for this article.Remember you can clap up to 50 times, and clapping for this article would be really helpful in the Medium algorithm. Any support is greatly appreciated ā¤ļø
Also, please answer the questions and add to the discussion below