This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there a way to export bulk data to TCX or GPX files? Seems like I can only bulk export to .csv and individual activities to GPX.

I'm looking for a way to import all of my activities from Garmin into Strava.  I see a bulk export option, but it only seems to allow for .csv exports.  I want the GPX data.  My accounts are linked but it only imported from the date of Strava account creation and onward.

Thanks,

Mike

Top Replies

All Replies

  • I tried the above code from Superbole but received an error from Chrome. I tried using ChatGPT to correct it but couldn't get it to work. I then asked ChatGPT to adjust the code from BunBun to save the files with the GPX extension and it worked! I'm not a programmer so don't ask me how as I just used Chat GPT but here's the code (this for GPX with a limit of 700):

    h = {
        'DI-Backend': 'connectapi.garmin.com',
        'Authorization': 'Bearer ' + JSON.parse(localStorage.token).access_token
    };
    
    fetch('https://connect.garmin.com/activitylist-service/activities/search/activities?limit=700', {'headers': h})
        .then(r => r.json())
        .then(all => {
            let t = 0;
            all.forEach(async (a, index) => {
                await new Promise(s => setTimeout(s, t += 5000)); // Increasing delay
                fetch(`https://connect.garmin.com/download-service/export/gpx/activity/${a.activityId}`, {'headers': h})
                    .then(r => {
                        if (!r.ok) throw new Error('Failed to fetch with status: ' + r.status);
                        return r.blob();
                    })
                    .then(b => {
                        const f = document.createElement('a');
                        f.href = window.URL.createObjectURL(b);
                        f.download = a.activityId + ".gpx";
                        f.click();
                        console.log(`Downloading file ${index + 1}: ${a.activityId}`);
                    })
                    .catch(error => console.error('Error at activity ${a.activityId}:', error));
            });
        });