fitfile

raw JSON →
1.2.0 verified Sat May 09 auth: no python maintenance

Python library for decoding and reading Garmin FIT file format data. Current version 1.2.0, no longer actively updated (use 'fitdecode' or 'garmin-fit' instead).

pip install fitfile
error ImportError: cannot import name 'FitFile'
cause Wrong import path or version mismatch.
fix
Use: from fitfile import FitFile
error AttributeError: 'FitFile' object has no attribute 'get_messages'
cause Trying to call get_messages on the wrong object or old version.
fix
Ensure fitfile >= 1.0; use fit.get_messages() not FitFile.get_messages()
deprecated fitfile is no longer actively maintained. Consider using fitdecode or garmin-fit for new projects.
fix pip install fitdecode then use from fitdecode import FitReader
gotcha Common mistake: calling get_messages() multiple times re-reads the file. Must re-open or store list.
fix messages = list(fit.get_messages()) # store once
breaking Removed Python 2 support. Requires Python >= 3.0
fix Use Python 3.

Open a FIT file and iterate over data messages.

from fitfile import FitFile

with open('activity.fit', 'rb') as f:
    fit = FitFile(f)
    for record in fit.get_messages():
        if record.name == 'record':
            print(record.get('heart_rate', None))