Can I delete just the activities from a single Garmin device from my Garmin Connect account?

Before going on a cycling holiday, I uploaded the routes to mine and a friend's Garmin 820s.  He also asked for me to update his device, as he rarely attaches it to his PC.

Whilst I connected his 820 to my PC, it has sync'ed all his rides to my G-Connect account.  As we ride together a lot, there are some very similar rides and telling the 100s of activities apart is going to takes ages...

Is there a way of sorting the data by a unique identifier, such as device serial number, so I can remove all his activities from my account, without reading each one to compare start and finish locations?

Any assistance would be appreciated.

  • THanks    i ahve the following error - Is needed to write "Device_5UH21487X"  or just "5UH21487X"

    Traceback (most recent call last):
    File "C:\Users\XxX\Documents\gc-deletebydevice.py", line 142, in <module>
    DEVICEID=int(DEVICEID)
    ^^^^^^^^^^^^^
    ValueError: invalid literal for int() with base 10: '5UH21487X'
    Press ENTER to exit.

  • THanks    i ahve the following error - Is needed to write "Device_5UH21487X"  or just "5UH21487X"

    Hey, last time I checked the device ID is just a number (no letters or special characters.) Which method did you use to obtain the device ID?

    EDIT: I noticed that my bookmarklet script for obtaining the device ID from a Connect activity no longer works. I'll have to fix it.

    EDIT: I've updated my original comment to fix the device ID script:
    forums.garmin.com/.../901884

  • Thanks for the code. HTTP 403 error forbidden when loading activity list.

  • Like others here, I'm so grateful to @WillNorthYork for working on a solution to delete all workouts from a given device. I tried to help somebody download a track, without thinking of the consequences... However, I'm getting the Error 402 Payment Required when I run the Python script. I can see that the previous fix is in the script "ACTIVITY_LIST = http_req(ACLISTURL, None,  { 'nk': 'NT' }) but it doesn't seem to work anymore... Any chance of another update, please?!

  • you are doing wonderful work! I receive the following error:

    Traceback (most recent call last):
    File "C:\Users\Frans\Downloads\gc-deletebydevice (3).py", line 293, in <module>
    ACTIVITY_LIST = http_req(ACLISTURL, None, { 'nk': 'NT' })
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Frans\Downloads\gc-deletebydevice (3).py", line 107, in http_req
    response = OPENER.open((request), data=post)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Frans\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 521, in open
    response = meth(req, response)
    ^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Frans\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 630, in http_response
    response = self.parent.error(
    ^^^^^^^^^^^^^^^^^^
    File "C:\Users\Frans\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 559, in error
    return self._call_chain(*args)
    ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Frans\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
    result = func(*args)
    ^^^^^^^^^^^
    File "C:\Users\Frans\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 402: Payment Required

    Sorry if its because of my incompetency with anything programing related!

  • Updated F12 → Console script

    • set limit=2 as needed (latest activities)
    • replace !!!DEVICE_ID!!! (number from device's settings link)
    • setTimeout 5000 is wait time

    Run search script and check if prints correct results:

    h={
     'DI-Backend':'connectapi.garmin.com',
     'Authorization':'Bearer '+JSON.parse(localStorage.token).access_token
    }

    jQuery.ajax({
     headers: h,
     url: 'https://connect.garmin.com/activitylist-service/activities/search/activities?limit=2',
     success: all => {
      t=0
      all.filter(a=>a.deviceId===!!!DEVICE_ID!!!).forEach(async a=>{
       await new Promise(s=>setTimeout(s,t+=5000))
       console.dir(a.activityId, a.activityName, a.startTimeLocal)
      })
     }
    })

    Add delete request inside the loop, new line after console.dir:

    fetch('https://connect.garmin.com/activity-service/activity/' + a.activityId,
    {
     'headers': {...h, 'X-HTTP-Method-Override': 'DELETE'},
     'method': 'POST'
    })

    To be safe, export all activities: garmin.com → Profile → Manage Data.

  • Locating Your Device Unit ID in the Garmin Connect App
    1. Open the Garmin Connect app.
    2. Access the menu by selecting More (bottom right).
    3. Select Garmin Devices.
    4. Press and hold the screen where the name of your device is listed. iOS: will display Device ID. Android: will display Unit ID.
  • Thanks WillNorthYork for the ongoing work. I'm getting similar errors to Frans


    First line reads
    File "C:\####\Downloads\gc-deletebydevice.py", line 260, in <module>
    LOGIN_RESPONSE = http_req(URL_GC_LOGIN + '#', urllib.parse.urlencode(POST_DATA), headers).decode()

    Then the same errors on lines 107, 521, 630, 559, 492, & 639

    Then the last line reads
    urllib.error.HTTPError: HTTP Error 401: Unauthorized

    If there's an update I'd love to be able to remove the data I now have from another user.

    Much appreciated
    Patrick

  • this helped me a lot. Now I would need something equivalent for Strava! :P