Skip to main content

Python 3 API wrapper for Garmin Connect

Project description

Python: Garmin Connect

$ ./example.py 

*** Garmin Connect API Demo by cyberjunky ***

Trying to login to Garmin Connect using token data from '~/.garminconnect'...

1 -- Get full name
2 -- Get unit system
3 -- Get activity data for '2023-10-01'
4 -- Get activity data for '2023-10-01' (compatible with garminconnect-ha)
5 -- Get body composition data for '2023-10-01' (compatible with garminconnect-ha)
6 -- Get body composition data for from '2023-09-24' to '2023-10-01' (to be compatible with garminconnect-ha)
7 -- Get stats and body composition data for '2023-10-01'
8 -- Get steps data for '2023-10-01'
9 -- Get heart rate data for '2023-10-01'
0 -- Get training readiness data for '2023-10-01'
- -- Get daily step data for '2023-09-24' to '2023-10-01'
/ -- Get body battery data for '2023-09-24' to '2023-10-01'
! -- Get floors data for '2023-09-24'
? -- Get blood pressure data for '2023-09-24' to '2023-10-01'
. -- Get training status data for '2023-10-01'
a -- Get resting heart rate data for 2023-10-01'
b -- Get hydration data for '2023-10-01'
c -- Get sleep data for '2023-10-01'
d -- Get stress data for '2023-10-01'
e -- Get respiration data for '2023-10-01'
f -- Get SpO2 data for '2023-10-01'
g -- Get max metric data (like vo2MaxValue and fitnessAge) for '2023-10-01'
h -- Get personal record for user
i -- Get earned badges for user
j -- Get adhoc challenges data from start '0' and limit '100'
k -- Get available badge challenges data from '1' and limit '100'
l -- Get badge challenges data from '1' and limit '100'
m -- Get non completed badge challenges data from '1' and limit '100'
n -- Get activities data from start '0' and limit '100'
o -- Get last activity
p -- Download activities data by date from '2023-09-24' to '2023-10-01'
r -- Get all kinds of activities data from '0'
s -- Upload activity data from file 'MY_ACTIVITY.fit'
t -- Get all kinds of Garmin device info
u -- Get active goals
v -- Get future goals
w -- Get past goals
y -- Get all Garmin device alarms
x -- Get Heart Rate Variability data (HRV) for '2023-10-01'
z -- Get progress summary from '2023-09-24' to '2023-10-01' for all metrics
A -- Get gear, the defaults, activity types and statistics
B -- Get weight-ins from '2023-09-24' to '2023-10-01'
C -- Get daily weigh-ins for '2023-10-01'
D -- Delete all weigh-ins for '2023-10-01'
E -- Add a weigh-in of 89.6kg on '2023-10-01'
F -- Get virtual challenges/expeditions from '2023-09-24' to '2023-10-01'
G -- Get hill score data from '2023-09-24' to '2023-10-01'
H -- Get endurance score data from '2023-09-24' to '2023-10-01'
I -- Get activities for date '2023-10-01'
J -- Get race predictions
K -- Get all day stress data for '2023-10-01'
Z -- Remove stored login tokens (logout)
q -- Exit
Make your selection: 

Donate

Python 3 API wrapper for Garmin Connect to get your statistics.

NOTE: For developers using this package

From version 0.2.1 onwards, this package uses garth to authenticate and perform API calls.
This requires minor changes to your login code, look at the code in example.py or the reference.ipynb file how to do that.
It fixes a lot of stability issues, so it's well worth the effort!

About

This package allows you to request garmin device, activity and health data from your Garmin Connect account. See https://connect.garmin.com/

Installation

pip3 install garminconnect

Authentication

The library uses the same authentication method as the app using Garth. The login credentials generated with Garth are valid for a year to avoid needing to login each time.
NOTE: We obtain the OAuth tokens using the consumer key and secret as the Connect app does. garth.sso.OAUTH_CONSUMER can be set manually prior to calling api.login() if someone wants to use a custom consumer key and secret.

Testing

The test files use the credential tokens created by example.py script, so use that first.

export GARMINTOKENS=~/.garminconnect
sudo apt install python3-pytest (needed some distros)

make install-test
make test

Development

The tests provide examples of how to use the library.
There is a Jupyter notebook called reference.ipynb provided here.
And you can check out the example.py code you can find here, you can run it like so:

pip3 install -r requirements-dev.txt
./example.py

Credits

:heart: Special thanks to all people contributed, either by asking questions, reporting bugs, coming up with great ideas, or even by creating whole Pull Requests to add new features! This project deserves more attention, but I'm struggling to free up time sometimes, so thank you for your patience too!

Donations

Donate

Project details


Release history Release notifications | RSS feed

This version

0.2.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garminconnect-0.2.8.tar.gz (75.0 kB view details)

Uploaded Source

Built Distribution

garminconnect-0.2.8-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file garminconnect-0.2.8.tar.gz.

File metadata

  • Download URL: garminconnect-0.2.8.tar.gz
  • Upload date:
  • Size: 75.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for garminconnect-0.2.8.tar.gz
Algorithm Hash digest
SHA256 3187b10a035a26804dc8d06fe3017755209bb9ec3faae6a3f0a5f416ac9d17d2
MD5 65162b4b1d95dfc5f3af7cf0f850bb3f
BLAKE2b-256 3a61012c7620687d2b620d03dceeb2d305e7c15d240e14f1af0da903a8e3c4da

See more details on using hashes here.

File details

Details for the file garminconnect-0.2.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for garminconnect-0.2.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49a2a997d270de28433f6a6a6b98d240688f8c905c62dd8b8193c5cdb5e16ab8
MD5 9093de11d946ac9167c2b5d2ada3a593
BLAKE2b-256 35b76da86c469e344943fe1a28f52395ecbf9f7cdee9fb29ab30823b1f79ff38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page