An open API service indexing awesome lists of open source software.

https://github.com/veerendra2/fitbit-cli

Access your Fitbit โŒš๏ธ data at your terminal ๐Ÿ’ป
https://github.com/veerendra2/fitbit-cli

cli fitbit fitbit-api pip python

Last synced: 9 days ago
JSON representation

Access your Fitbit โŒš๏ธ data at your terminal ๐Ÿ’ป

Awesome Lists containing this project

README

        

# Fitbit CLI

[![Release](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml/badge.svg)](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml) [![PyPI - Status](https://img.shields.io/pypi/status/fitbit-cli)
](https://pypi.org/project/fitbit-cli/) [![PyPI - Version](https://img.shields.io/pypi/v/fitbit-cli)
](https://pypi.org/project/fitbit-cli/)

> This is not an official Fitbit CLI

Access your Fitbit data directly from your terminal ๐Ÿ’ป. View ๐Ÿ’ค sleep logs, โค๏ธ heart rate, ๐Ÿ‹๏ธโ€โ™‚๏ธ activity levels, ๐Ÿฉธ SpO2, and more, all presented in a simple, easy-to-read table format!


Fitbit logo

[![asciicast](https://asciinema.org/a/696114.svg)](https://asciinema.org/a/696114)

## Supported Web APIs

> Only `GET` APIs are supported!

| API | Status |
| ----------------------------------------------------------------------------------------------------------------------- | ------ |
| [User](https://dev.fitbit.com/build/reference/web-api/user/) | โœ… |
| [Sleep](https://dev.fitbit.com/build/reference/web-api/sleep/) | โœ… |
| [SpO2](https://dev.fitbit.com/build/reference/web-api/spo2/) | โœ… |
| [Heart Rate Time Series](https://dev.fitbit.com/build/reference/web-api/heartrate-timeseries/) | โœ… |
| [Active Zone Minutes (AZM) Time Series](https://dev.fitbit.com/build/reference/web-api/active-zone-minutes-timeseries/) | โœ… |
| [Activity](https://dev.fitbit.com/build/reference/web-api/activity/) | โœ… |

## Usage Guide

1. Install the Fitbit CLI

```bash
python -m pip install fitbit-cli
```

2. Help

```bash
fitbit-cli -h
usage: fitbit-cli [-h] [-i] [-s [DATE[,DATE]]] [-o [DATE[,DATE]]] [-e [DATE[,DATE]]] [-a [DATE[,DATE]]] [-u] [-v]

Fitbit CLI -- Access your Fitbit data at your terminal.

options:
-h, --help show this help message and exit
-i, --init-auth Initialize Fitbit iterative authentication setup
-v, --version Show fitbit-cli version

APIs:
Specify date ranges (ISO 8601 format: YYYY-MM-DD) for the following arguments.
You can provide a single date or a range (start,end). If not provided, defaults to today's date.

-s, --sleep [DATE[,DATE]]
Show sleep data
-o, --spo2 [DATE[,DATE]]
Show SpO2 data
-e, --heart [DATE[,DATE]]
Show Heart Rate Time Series data
-a, --active-zone [DATE[,DATE]]
Show Active Zone Minutes (AZM) Time Series data
-u, --show-user-profile
Show user profile data
```

3. Register Fitbit App

1. Go to [https://dev.fitbit.com/apps](https://dev.fitbit.com/apps)
2. Click on "REGISTER AN APP" tab
3. Follow below example and register an app


Fitbit logo

4. Run the following command to set up interactive authentication and store the Fitbit token locally

```bash
fitbit-cli --init-auth
```

For a visual guide, see the Asciinema recording below
[![asciicast](https://asciinema.org/a/696115.svg)](https://asciinema.org/a/696115)

5. Start using it ๐Ÿ˜Ž

```bash
$ fitbit-cli -s
Sleep Data Summary ๐Ÿ˜ด
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Date ๐Ÿ“† โ”ƒ Deep Sleep ๐Ÿ› โ”ƒ Light Sleep ๐Ÿ’ค โ”ƒ REM Sleep ๐ŸŒ™ โ”ƒ Wake Time โฐ โ”ƒ Efficiency ๐Ÿ’ฏ โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 2024-12-25 โ”‚ 139 min โ”‚ 190 min โ”‚ 155 min โ”‚ 54 min โ”‚ 55% โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

_**NOTE: The token is valid for only 8 hours, `fitbit-cli` automatically refreshes the token when it expires.**_

## Local Development

- [Fitbit Docs](https://dev.fitbit.com/build/reference/web-api/)
- [OAuth Tutorial](https://dev.fitbit.com/build/reference/web-api/troubleshooting-guide/oauth2-tutorial/)

```bash
git clone [email protected]:veerendra2/fitbit-cli.git
cd fitbit-cli

python -m venv venv
source venv/bin/activate
python -m pip install -e .
```