Skip to content

A Python-based exercise challenge using Strava's API to track a virtual race (to San Marino!)

Notifications You must be signed in to change notification settings

gabriel-ing/ProjectSanMarino

Repository files navigation

Project San Marino

My partner and I were looking for a new exercise challenge recently and the idea was raised to do something like a Conqueror challenge, where one virtually runs/walks/cycles a route. However these challenges are expensive for relatively little, so I took this as a challenge to build my own.

Based on distance, we ended up choosing to go from our house in Edinburgh, to San Marino, giving this project it's name, Project San Marino.

This program functions by downloading data from Strava, the common exercise tracking app. It is customisable so your own route can be used (instructions to follow). Setting up the Strava details is a bit of a pain, but otherwise it is fairly straightforward to use, and get a basic dashboard like this:

example dashboard

There are a few things you need to do before using these scripts.

Step 1: Create a route using my-maps from Google.

  • Create directions

example dashboard

  • Export route as kmz:

example dashboard

  • Rename kmz file 'Directions_file.kmz' and move it to the main directory

Step 2: Create Strava payloads file (strava_payloads.py).

This requires setting up the strava API to your strava account, this took me ages to get my head around but I recommend the information in these articles by: Ksawery Lejczak, Matt Ambrogi and the video and github repo from Franchyze923.

Once you have the Strava information for each participant (the client ID, Client Secret and Refresh Token (with scope read_all)). Add these into dictionaries in the formats shown in Strava_payloads_example.py in this repository. Note, all credit for how to set this up goes to franchyze923, who's tutorials were super helpful.

Step 3: Fill in parameters file: - A start date and target finish date needs to be added in 'parameters.py' - A foot_target should also be added this was created in our version to make sure we didn't just cycle the whole route because cycling is wayyyy easier to get the distance in. If you want to ignore this, just set it to None or ''.

Step 4: Install requirements.txt Install the requirements with pip:

pip install -r requirements.txt

After these bits of set-ups are done, the project_setup.py file should be run:

python project_setup.py

This creates a distance-position look up file ('Distance_lookup.csv') which speeds up finding your current location, it also creates a doc.kml file to give the route in a more useable format.

After running project_setup.py, the main python file can be run:

python project_san_marino.py

Now try opening index.html and hopefully the dashboard should be built.

About

A Python-based exercise challenge using Strava's API to track a virtual race (to San Marino!)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published