This project analyzes heart rate data from Apple Health XML exports and correlates it with events from your Google Calendar.
- Python 3.7 or higher
- A Google Cloud project with access to the Google Calendar API
- Apple Health XML data export
-
Clone the repository:
git clone [email protected]:edeng23/HeartSync.git cd HeartSync
-
Install the required Python packages:
pip install -r requirements.txt
-
Set up Google Calendar API credentials:
- Create a project on the Google Cloud Console.
- Enable the Google Calendar API for your project.
- Download the
credentials.json
file and save it in the project directory.
-
Export Apple Watch data:
- Export Health Data from the iPhone:
- Open the Health app on your iPhone.
- Tap on your profile picture in the top right corner to access your health profile.
- Scroll down and tap on Export All Health Data.
- A confirmation dialog will appear. Tap Export to confirm.
- The Health app will prepare your data, which might take a few minutes.
- Once the data is ready, you'll be given the option to save it to a location of your choice. Save the file (it will be named
export.zip
) to a convenient location.
- Unzip the Exported Data:
- Locate the
export.zip
file on your computer and unzip it. - Inside the unzipped folder, you'll find an XML file named
export.xml
. This file contains all your health data, including heart rate data.
- Locate the
- Move the
export.xml
File:- Copy the
export.xml
file to the directory where your script is located.
- Copy the
- Export Health Data from the iPhone:
-
Ensure you have your Apple Health XML export file and your
credentials.json
file in the project directory. -
Run the script with the following command:
python heartsync.py <export_file_path> <google_credentials_path>
<export_file_path>
: Path to your Apple Health XML export file.<google_credentials_path>
: Path to your Google APIcredentials.json
file.
Example:
python heartsync.py export.xml credentials.json
-
The script will authenticate with Google Calendar, retrieve events, and correlate them with the heart rate data. The results will be displayed in your terminal.