Skip to main content

fittie

Parse Garmin .FIT files

PyPI version

Installation

Fittie is available on pypi and can be installed with the following command.

$ pip install fittie

Example

from fittie import decode

if __name__ == "__main__":
    fitfile = decode("path/to/fit/file.fit")
        
    # Example: get average heart rate
    print(fitfile.average_heart_rate)

    # Loop through all data messages:
    for data_message in fitfile:
        print(data_message)

For more information and examples, check the documentation

Fitfile

Usage

Decoding / parsing a FIT file is done through the decode function in the fittie.fitfile package. It accepts the following types of arguments:

  • A file path string
  • A file opened in "rb" mode
  • A buffered reader, BinaryIO or BytesIO
# Examples
from io import BytesIO
from fittie.fitfile import decode

fitfile_1 = decode("/path/to/fit/file.fit")         # Path to file

fitfile_2 = decode(BytesIO(...))                    # BytesIO

with open("/path/to/fit/file.fit", "rb") as f:      # File opened in rb mode
    fitfile_3 = decode(f)

To view the available message types in the fitfile, use the available_message_types property. It will return a list of message type keys. These keys can be used to retrieve all messages of a certain kind. After retrieving the available message types, the messages can be retrieved using get_messages_by_type.

fitfile = decode("/path/to/fit/file.fit")

types = fitfile.available_message_types
# e.g. [ 'file_id', 'device_info', 'record', 'event', 'lap', 'session', 'activity']
messages = fitfile.get_messages_by_type('record')  # Returns a list of `DataMessage`

Alternatively, you can interact with the messages property of fitfile directly, this is a simple dict.

File types

All FIT files should contain a file id message that describes the type of file. Common file types are activity, workout and course. More file types can be found in fit_types.py.

To retrieve the type of the decoded fitfile, use the .file_type property.

assert fitfile.file_type == "activity"

CRC

A crc check is done by default, but can be disabled by providing calculate_crc=False to the decode function to improve speed.

For example, on the same FIT file with 58297 data messages, decoding with crc takes 0.029 seconds and without crc it only takes 0.014 seconds.

DataMessages

To access data in a DataMessage, use the fields property. This will return a dict with all the values inside the message.

fitfile = decode("/path/to/fit/file.fit")

for record in fitfile.get_messages_by_type("record")[:5]:
    print(record.fields)

# {'timestamp': 1044776016}
# {'timestamp': 1044776016, 'heart_rate': 117}
# {'timestamp': 1044776017, 'heart_rate': 116}
# {'timestamp': 1044776017, 'heart_rate': 115}
# {'timestamp': 1044776018, 'heart_rate': 115}

TODO:

  • Handle component fields
  • Handle accumulators
  • Handle chained FIT files
  • Handle compressed timestamps
  • move record_header into record, instead of reading it separately
  • encoding

Metadata

Release files for fittie 0.10.0

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

Source distribution (sdist)

Source distribution for fittie 0.10.0
File Size Uploaded
fittie-0.10.0.tar.gz 93.7 kB Details

Built distribution (wheel)

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

Total release size: 196.9 kB

Release files / fittie-0.10.0.tar.gz

Download URL fittie-0.10.0.tar.gz
Size 93.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0ab111ef91d29e65f29b07e1385bdb5d9fa1f4adc3d20b317cceb676a2f26ba8
BLAKE2b-256 checksum
How to use checksums
aa91a599ad204b05eaf3621a3b1e315c22cf035be855783036d17608d59118b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.9

Release files / fittie-0.10.0-py3-none-any.whl

Download URL fittie-0.10.0-py3-none-any.whl
Size 103.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afad30c74080932e2f08fe6e583e53051f0b424e4dcb48c69657194bb12b8304
BLAKE2b-256 checksum
How to use checksums
beb0aee99373af57e1c8fde51a8fae944fa001777afb16cc4f2f5f89fa85da81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.9

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.1

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.0.1

2 release files

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