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();
@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