Upload rides from Zwift

26 October, 2021 by David Johnstone

Here’s a bookmarklet that uploads rides directly from Zwift to Cycling Analytics. When used on an activity page while the activity settings are shown, this immediately sends the ride to Cycling Analytics.

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. If you’ve previously created one, you can use that instead.)

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 any Zwift activity page once the activity settings are shown (click the cog icon near the top of the page to show the settings, which includes a link to download the Fit file that this uses). The ride is sent to Cycling Analytics immediately.


Here’s the code. This can be modified if needed and converted into a bookmarlet with a bookmarklet maker.

let a = document.getElementById('activityFitFile');  
if (a) {  
    let json = {url: a.href, title: document.getElementById('activityTitle').value};  
    let el = document.createElement('span');  
    el.textContent = 'Uploading to CA…';  
    el.style.marginLeft = '10px';  
    a.after(el);  
    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(() => el.textContent = 'Uploaded to CA')  
    .catch(() => el.textContent = 'Uploading error');  
} else {  
    alert('No FIT file URL');  
}

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