Upload rides from Zwift

16 October, 2018 by David Johnstone

Here’s a bookmarklet that makes it possible to upload rides directly from Zwift to Cycling Analytics. When run, a button is added to the Zwift interface to upload rides.

The first step is to create an authentication token so that the bookmarklet will have permission to upload rides. Go to the API console and enter the following and hit “enter”:

POST /tokens {permissions: 'create_rides'}

(This token will then be displayed on the apps page and can be deleted there.)

Copy and paste the token here (just the part that looks something like EFS4Ef5wfDC8pmYbmpM3vITbjZY8wDWD) and click “create”:

Zwift to CA

Create a bookmark out of the link just created by right clicking and selecting the appropriate option or by dragging it to the bookmarks toolbar or library. Alternatively, create a new bookmark with the following value:

Enter the token and click “create” first.

Once the bookmark is created, it can be run on the Zwift activity page and a “send to CA” button is added for each ride.

Here’s the code. This can be modified if needed and converted into a bookmarlet with https://mrcoles.com/bookmarklet/.

$('.btn-link').each(function(i, el) {
    el = $(el);
    $('<a class="btn-link send-to-ca" style="margin-left: 10px"><i class="fa fa-cloud-upload"></i> Send to CA</a>').click(function() {
        var loading = $('<a class="btn-link send-to-ca" style="margin-left: 10px"><i class="fa fa-circle-o-notch fa-spin"></i></a>').insertAfter($(this));
        var title = el.parent().parent().find('h3').text();
        title = title.replace(/^Zwift - /, '');
        if (/^\d\d\/\d\d\/\d\d\d\d$/.test(title)) {
            title = '';
        var json = {url: el.attr('href')};
        if (title) {
            json.title = title;
        fetch('https://www.cyclinganalytics.com/api/me/upload', {method: 'POST', headers: {'Authorization': 'Bearer REPLACE_THIS_WITH_TOKEN', 'Content-Type': 'application/json'}, body: JSON.stringify(json)}).then(function() {
            loading.html($('<i class="fa fa-check"></i>'));
        }).catch(function() {
            loading.html($('<i class="fa fa-times"></i>'));


  • 18 October: Send ride titles
  • 19 October: Add code and fix bug

This is the blog of Cycling Analytics, which aims be the most insightful, most powerful and most user friendly tool for analysing ride data and managing training. You might be interested in creating an account, or following via Facebook or Twitter.

blog comments powered by Disqus