Read and write Garmin FIT (Flexible and Interoperable Data Transfer) files from Python.
FIT is a binary format designed for sport, fitness, and health devices. It is compact, interoperable, and extensible — any FIT-compliant device can interpret a FIT file from any other FIT-compliant device.
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"Or use the Makefile:
make installfrom fit import FitFile
with FitFile.open("path/to/activity.fit") as f:
for message in f:
print(message)from fit import FitFile
with FitFile.open("path/to/source.fit") as src:
with FitFile.open("path/to/copy.fit", mode="w") as dst:
dst.copy(src)from fit.files.activity import ActivityFile
from fit.messages.common import FileCreator
fnew = ActivityFile.create("path/to/new.fit")
fnew.append(FileCreator(software_version=100))
fnew.write()
fnew.close()from io import BytesIO
from fit import FitFile
data = open("path/to/activity.fit", "rb").read()
with FitFile.open(BytesIO(data)) as f:
for message in f:
print(message)make install # create .venv and install all dev dependencies
make format # run black
make lint # run ruff
make typecheck # run mypy
make test # run pytest with coverage
make tox # run tests across Python 3.9, 3.10, 3.12
make clean # remove build artefacts and the virtualenvBSD 3-Clause — see LICENSE.