Script to export data from to influxDB, in order to use with Grafana, for example
Go to file
Toni Miquel bf3c3c28ad Merge pull request 'Update README' (#13) from develop into main
Reviewed-on: #13
2023-09-06 12:00:25 +00:00
docs Update README 2023-09-06 13:59:44 +02:00
src WIP: Update documentation 2023-09-06 12:16:42 +02:00
.dockerignore Update Dockerfile and documentacion 2023-09-05 11:20:54 +02:00
.gitignore First commit 2023-08-26 12:19:31 +02:00
.readthedocs.yaml WIP: add material to mkdocs 2023-09-02 21:16:28 +02:00
Dockerfile Update Dockerfile and documentacion 2023-09-05 11:20:54 +02:00
LICENSE Add LICENSE 2023-08-28 13:53:34 +02:00 Update README 2023-09-06 13:59:44 +02:00 Reorder folders to start with pip package 2023-09-04 12:03:04 +02:00 WIP: Update documentation 2023-09-06 12:16:42 +02:00
mkdocs.yml WIP: Update documentation 2023-09-06 12:16:42 +02:00
pyproject.toml Update to 0.2.4 2023-09-06 12:38:05 +02:00
requirements.txt Update Dockerfile and documentacion 2023-09-05 11:20:54 +02:00 Update to 0.2.4 2023-09-06 12:38:05 +02:00 to InfluxDB

Intervalsicu-to-influxdb is a personal project to extract data from to InfluxDB (oh, really?). But if already shows a lot of graphics, statistics and more, why I need to extract it?

Full documentation can be found in here


Well, as a sportsman and techie, it's just a personal project, but the main reason is because I want to create my own dashboards (using Grafana in this case).

So, for example, I can combine activity data with sleep time or quality, compare the evolution between pace/bpm for the similar activities or whatever.

Grafana Dashboard example Grafana Dashboard example2

How it works

This project exports some data from to influxDB. To retrieve the information the official API is used.

Exported data

Not all information is exported. This project has been created to extract data from activities and wellness. Besides, information about data account (like email, location, preferences, etc.), calendar or workouts are not retrieved neither (for now).

Currently the following data is exported:

  • Wellness*: this data contains information like sleep time and quality, atl/ctl or VO2Max
  • Activities*: general information about every activity, like elapsed time, time in zones (hr or pace), distance, average pace/hr, etc.
  • Streams**: streams contains detailed information about activities, like hr/pace for every second.

* There are som extra fields generated, just to facilitate the use for the dashboards (see Entities)

** Currently working on it.

How to use

There are 2 ways (3 if you count 'from source code') to use the project: with Docker or directly with Python (or from source code), but in both cases you need to create a .env file to save your credentials for and InfluxDB as follow:



To use with Docker, just run the following command:

docker run --env-file PATH/TO/FILE -it --rm tmllull/intervals-to-influxdb [-h] [--start-date START_DATE] [--end-date END_DATE] [--streams] [--reset]


All the arguments are optional, but take in consideration the following variations when run it:

  • No arguments: retrieve the wellness and activities data for today (this is the basic use to run with a cronjob)
  • Start date: retrieve data from the starting date (in format YYYY-MM-DD) until today
  • End date: retrieve data until specified date (in format YYYY-MM-DD). Use it with start-date
  • Streams: retrieve the streams for the activities
  • Reset: delete the current bucket and recreate again

NOTE: on the first run, the bucket is created automatically if not exists on InfluxDB

With Python

If you want to run it directly with Python, first install the dependency:

pip install intervalsicu-to-influxdb

Then, the minimum code to run it is (remember to put the .env file on the same folder):

from intervalsicu_to_influxdb.extractor import IntervalsToInflux

extractor = IntervalsToInflux()

To run it, just save as and run it:



As the Docker way, we can pass arguments when create the extractor. For example:

extractor = IntervalsToInflux(start_date="2023-01-01")
extractor = IntervalsToInflux(streams=True)
extractor = IntervalsToInflux(start_date="2023-01-01", end_date="2023-05-01")

Dynamic script

If you want to create a more dynamic script, here is a more complete example:

import argparse

from intervalsicu_to_influxdb.extractor import IntervalsToInflux

parser = argparse.ArgumentParser()

parser.add_argument("--start-date", type=str, help="Start date in format YYYY-MM-DD")
parser.add_argument("--end-date", type=str, help="End date in format YYYY-MM-DD")
    help="Export streams for the activities",
    "--reset", action="store_true", help="Reset influx bucket (delete and create)"

args = parser.parse_args()

if args.start_date:
    start_date = args.start_date
    start_date = None
if args.end_date:
    end_date = args.end_date
    end_date = None
if args.streams:
    streams = True
    streams = False
if args.reset:
    reset = True
    reset = False

extractor = IntervalsToInflux(start_date, end_date, reset, streams)

Then, just run the script as before, but you will can use arguments (same as the Docker section):

python [-h] [--start-date START_DATE] [--end-date END_DATE] [--streams] [--reset]

From source code

If you want to run it from source code, just clone the project, and the follow the next steps (remember to create the .env file):

Run with Docker

First, compile the image

docker build --tag intervals-to-influxdb .

And then, just run it like the Docker section above (but with the image name)

docker run --env-file PATH/TO/FILE -it --rm intervals-to-influxdb [-h] [--start-date START_DATE] [--end-date END_DATE] [--streams] [--reset]

Run with Python

First, install dependencies from source

pip install .

And then, run the script

python [-h] [--start-date START_DATE] [--end-date END_DATE] [--streams] [--reset]