Skip to content

Instantly share code, notes, and snippets.

@rafmos
Last active July 28, 2019 19:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafmos/1fdbc538a0df65374b6a0383f47b2c2d to your computer and use it in GitHub Desktop.
Save rafmos/1fdbc538a0df65374b6a0383f47b2c2d to your computer and use it in GitHub Desktop.
Download all activities from Runtastic.com (as .gpx)

Download all activities from Runtastic 🏃

With this script you can download all your activities from www.runtastic.com in .gpx format. Runtastic restricted these exports to 5 per hour. That's why I adapted a little bit christianewald's script.

❗ Only tested in Google Chrome 41.0+

How does it work

Login to your runtastic account and go to the page where all your activities are listed. Then open the developer tools of Chrome with CMD + OPTION + I and go to the console tab. Now copy and paste the following script in the console line and press enter. The usually content should disapear and the downloads should start.

When a download fails, the script waits for a few seconds before trying again. This is because Runtastic restricted the downloads.

// If you want to start from another activity 
// (useful if you want to turn off your computer before it's finished exporting, for example), 
// then change the value of i.
// Typing index_data in your console can help you
var i = 0; 
var delay = 300; // In seconds
var file_format = 'gpx'; // Change here to tcx if you want tcx files instead of gpx

$('body').html('');
function f() {
	// Date formatting
	var d = new Date();
	var day = d.getDate();
	var month = d.getMonth()+1;
	var year = d.getFullYear();
	var hour = d.getHours();
	var minute = d.getMinutes();
	var second = d.getSeconds();
	console.log(day+'.'+month+'.'+year+' '+hour+':'+minute+':'+second+' - Downloading activity '+i+'...');
	
	var value = index_data[i];
	var nbActivities = index_data.length;
	
    var id = value[0];
    var filename = 'RUNTASTIC-' + value[1] + '-' + value[0] + '.'+file_format;

    $.ajax({
        url: 'https://' + app_config.domain + user.run_sessions_path + id + '.'+file_format,
        success: function(data, textStatus, jqXHR)
        {
            if(textStatus == 'success')
            {
                $('<a/>', {
                    'href' : 'data:text/plain;charset=utf-8,' + encodeURIComponent(jqXHR.responseText),
                    'download' : filename,
                    'id' : id
                }).html(filename)
                .before(i + '. Downloaded: ')
                .after('<br/>')
                .prependTo('body');

                $('#' + id)[0].click();
				
				console.log('Activity '+i+' successfully downloaded.');
				i++;
				if(i < nbActivities){
					f();
				}
            }
            else
            {
                console.log(textStatus);
            }
        },
		error: function () {
			console.log('Error downloading the activity '+i+'. Trying again in '+delay+' seconds...');
			setTimeout( f, delay * 1000 );
		},
        dataType: 'xml',
        beforeSend: function(xhr){
            xhr.setRequestHeader('X-Requested-With', ' ');
        },
    });
};
f();
@JbKarlsson
Copy link

Is it possible to set a date interval? It seems that the download only starts from the first activity.

@cavemaster
Copy link

Hello,
seems to be the perfect solution to switch to another sports app.
Unfortunatly everytime I got this message:

Error downloading the activity 0. Trying again in 300 seconds...

Any idea what I'm doing wrong?

@eeemptyy
Copy link

eeemptyy commented May 5, 2019

@cavemaster
Please check below

  1. check if you are in all activities page on runtastic
  2. typing index_data to check if there something to download
  3. Try not copy the script line start with //

Hope this help

@TimoTautenhahn
Copy link

I immediately got my 5 downloads per hour (current limitation from Runtastic), but sadly not more than that. So your script seem to work perfectly fine, Runtastic just seem to make it harder and harder to get the data out of their portal... :(

I'll try if this "GDPR approach" works for me: https://github.com/mato1092/runtastic-activity-lib

Is this 5 downloads per hour limiting you, too in the current version of the Runtastic portal?

@a-nemilov
Copy link

@cavemaster
Copy link

@eeemptyy thanks I got it. Unfortunatly the same issue like @TimoTautenhahn as well.
The recommandation from @a-nemilov also doesn't work for me. :(
@TimoTautenhahn did you have success in the meantime?

@a-nemilov
Copy link

@cavemaster I did it today. It took ten second. Run script from correct dir, run script with log/pass , that’s all. https://youtu.be/sCrBWePqoJ0

@cavemaster
Copy link

@a-nemilov I'm doing exactly the same on my mac and I got the following response:

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12271e0]

goroutine 1 [running]:
github.com/metalnem/runtastic/api.(*Session).GetActivities(0xc4201b0200, 0x13f1000, 0xc4200722c0, 0x1b, 0x7ffeefbffc95, 0x8, 0xc4201b0200, 0x0)
/Users/Metalnem/Go/src/github.com/metalnem/runtastic/api/api.go:660 +0x160
main.main()
/Users/Metalnem/Go/src/github.com/metalnem/runtastic/main.go:142 +0x1bc`

@a-nemilov
Copy link

@cavemaster send me login/pass , i will get all data today))))

@cavemaster
Copy link

I tried the windows version and this worked for me.
Thanks for your support.

@JbKarlsson
Copy link

@cavemaster did you use the latest windows version?

@cavemaster
Copy link

@JbKarlsson yes I did.

@JbKarlsson
Copy link

@cavemaster Ok, I just keep getting the error message you got when you didn't try with the windows version.

@Vyrwn
Copy link

Vyrwn commented Jul 17, 2019

@a-nemilov window version worked for me like a charm. Thank you for pointing out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment