Some more hints on How to Move Your Data from Endomondo to Strava

Rainer Pausch
5 min readJan 6, 2021

I had 2003 activities on Endomondo dating back to 2011. Therefore migrating them manually was not an option. In this article, I want to tell my story and give some more (hopefully helpful) hints to those who also want to migrate their data from Endomondo to Strava. (Sorry for the awful formatting. It’s my first post here and I am not familiar with the editor, yet.)

First I want to thank Kamil Buzik for this great tutorial here: https://medium.com/@kamil.burczyk/exporting-your-activities-from-endomondo-to-strava-682c23391041 . But also thanks to the other guys who gave some helpful comments and hints. Please read this tutorial first. You won’t understand my notes unless you do so ;-)

Trying Tapiriik

Since I am lazy I first tried Tapiriik. But obviously it is/was overwhelmed by all those requests. Simply nothing happened for days although I even paid 5 bucks. Fortunately enough Colin refunded the money without any further ado upon my complaint.

Getting my data from Endomondo

So, I decided to get my data directly using node.js and the java script exporter.js provided by Kamil. I modified it a bit in order to retrieve tcx files instead of gpx since I think tcx has some more information. I must say that the Endomondo API seems to be very robust and the download of the data worked pretty fast. However sometimes the export threw an error. But by re-running the script with different start dates I managed to export about 1950 data sets. Quite good, but I wanted them all. My ambition was triggered. (Side note: As of today (Jan 6, 2021) API access to endomondo still works although it is in its final phase.)

Next, I logged in to Endomondo and requested the data. A few days later I got an e-mail with the download link to the zip archive. All my 2003 workouts where included both as tcx and json files. Nice!

Uploading to Strava

Since I am a Windows user I thought that I simply could use the manipulated script from Rteeraphong for Powershell in order to upload my files to Strava. But I always got errors on the for loops. So I did some research and finally ended up in enabling the Linux subsystem on Windows and installing the Ubuntu distribution from the Windows store. (Here’s a great article describing how to do this https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/ . Don’t be afraid, it is quite straightforward.) Now I was ready to use the bash commands and scripts.

Since I have 2003 workouts and I wanted to upload them all I wanted to have some control and further modified Rteeraphong’s script such that files are only moved after successful upload.

Here’s the script (I called it 3_uploader.sh . More on the naming convention later on.):

#!/bin/bash

for i in {1..100}

do

# get txc file from directory Files

file=`ls Files/*.tcx | head -n 1`

echo

echo “Processing file: “$file

curl -f -w “\nHTTP response Code: %{response_code}\n” -X POST https://www.strava.com/api/v3/uploads -H “Authorization: Bearer YOUR_ACCESS_TOKEN” -F data_type=”tcx” -F file=@”$file”

# check if upload was successful and only move file if “yes”. The -f option of curl makes it return 0 only upon successful execution. If anything fails it returns 22 and -w prints the http response code.

# 200 Successful request

# 201 Your activity/etc. was successfully created

# 401 Unauthorized

# 403 Forbidden; you cannot access

# 404 Not found; the requested asset does not exist, or you are not authorized to see it

# 429 Too Many Requests; you have exceeded rate limits

# 500 Strava is having issues, please check https://status.strava.com

res=$?

if test “$res” != “0”;

then

echo -e “\n the curl command failed with: $res”

#exit loop if error occurs

break

else

# success: move file to directory uploaded

echo -e “\n\nupload successful, res: “ $res

mv “$file” uploaded

echo “file “ $file “moved to uploaded”

fi

echo

done;

echo “Remaining files:” `ls -la Files/*.tcx | wc -l`;

echo “Finished at:” `date`;

next_execution_DATE=$(date -d “+15 minutes”)

echo “Next execution not before: “$next_execution_DATE

Since the Strava API allows only 1000 requests a day I had to run the script on several days and my precaution paid off by stopping the script when the quota was exceeded.

Did I now manage to upload all of my workouts?

Unfortunately not! The Strava API accepts only workouts with GPS data (at least for bike rides). Since in the early days of my use of Endomondo (remember, I started back in 2011. Side note: on a Blackberry Torch, if you remember what this was.) it often crashed or did not record the route, I had several workouts without GPS data that I could not upload (neither with the script nor with the manual upload function on the Strava website). BTW: that’s why I did not get all workouts using the java script downloader. So I had to key them in manually on the website. After that all my workouts where on Strava. Pfuhhhh.

The final check: Was the statistics correct?

I compared the yearly statistics on Endomondo and on Strava and found that for some years they coincided but for others there were some discrepancies. What’s now? I did not want to compare every activity one by one. So I came up with the idea to have a look at the file size of the uploaded files and found that some of them had only 1 or 2 kb, at least a factor of 10 smaller than all the others. A look into some them showed that they were the suspicious candidates. One type were files of swimming activities. For some reason Strava did not get the distance. So I had to correct them manually on the Strava website (or delete and key in again.) The second type were cycling activities but with only rudimentary GPS data. So they were uploaded but the distance in Strava was 0. So again: delete the activity and key it in again L

But finally: All activities are migrated and the statistics are correct!

Final hints

Remember the funny naming convention for my upload script? 3_uploader.sh

That’s simply a way to remember the order of the different steps you have to do in order to make the upload work. As I wrote before, the Strava API only accepts 1000 request per day and therefore you have to run the script on several different days if you have more an 1000 activities you want to upload or if you run some test in order to get you script right. This means that you have to retrieve a new access token for your upload script.

Step 1: Get the code

In order to do this I created a very simple html file 1_get_Strava_code.html

<html>

<body>

<a href=”https://www.strava.com/oauth/mobile/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost&response_type=code&approval_prompt=auto&scope=activity%3Awrite%2Cread&state=test"> Get Strava code </a>

</body>

</html>

Simply replace YOUR_CLIENT_ID with your Strava client ID, save it, click on it, click on the link in the browser and you have you code in order to

Step 2: get the token

To this end I “wrote” ;-) a bat file containing the CURL command 2_get_token.bat

curl -X POST https://www.strava.com/api/v3/oauth/token -d client_id= YOUR_CLIENT_ID -d client_secret=YOUR_CLIENT_SECRET -d code=YOUR_CODE_FROM_STEP_1 -d grant_type=authorization_code

Edit it with your data and run it, best redirection the output to a file, e.g.

C:\YOUR_DIRECTORY\2_get_token.bat >> token.txt

From this file you now can easily get the access token, insert it in your shell script 3_uploader.sh and run

Step 3: upload your data to Strava

C:\YOUR_DIRECTORY\bash 3_uploader.sh

If you want to follow me

Twitter: @jazzonbike

Strava: Rainer Pausch

--

--

Rainer Pausch
0 Followers

Product Marketing Guy, Race Biker, Free Diver, Cook, Gourmand, Wine Lover