Skip to main content

fit

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.

Installation

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Or use the Makefile:

make install

Usage

Reading a FIT file

from fit import FitFile

with FitFile.open("path/to/activity.fit") as f:
    for message in f:
        print(message)

Copying a FIT file

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)

Creating a new FIT file

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()

Reading from a stream

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)

Development

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 virtualenv

License

BSD 3-Clause — see LICENSE.

Metadata

Release files for fit 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fit 0.5.1
File Size Uploaded
fit-0.5.1.tar.gz 46.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fit 0.5.1
File Interpreter ABI Platform
fit-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 99.3 kB

Release files / fit-0.5.1.tar.gz

Download URL fit-0.5.1.tar.gz
Size 46.2 kB
Tags Source
SHA-256 checksum
How to use checksums
52fe23e53ebd973418099114068893e57626c1d23d232eaf38a252cbef73e61a
BLAKE2b-256 checksum
How to use checksums
061bb2cb459c54c2937723392be175fff5dd89d9fec0c2202a933c151ecce37b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / fit-0.5.1-py3-none-any.whl

Download URL fit-0.5.1-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc45bd0455784ba6292b50386e71f46b840094b1d6286bb6df987eadeb06c556
BLAKE2b-256 checksum
How to use checksums
e77aeead630b0ec75a0fea676f18e597ee2ee0881f1e8e93c85be6e877bb569f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.4.1

1 release file

0.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page