blog.cjcjameson.com · the COROS activity tool
I text my bot a workout and it shows up in COROS. COROS has no public upload API, so we read the web app's JavaScript to figure out how it uploads.
soccer yesterday 6pm, 90 min
Soccer, Fri Nov 20, 6:00 PM PST, 90 min. About 900 kcal, HR steady around 143, peaks near 189. Upload?
yes
Done, it's in COROS. Training Load will fill in after COROS recomputes.
coros.cjcjameson.com generates .fit files for workouts my watch didn't record, like a soccer game or a hike I forgot to start. It simulates per-second heart rate, and if you give it a GPX route it shapes the pace by grade. Then you import the file into COROS Training Hub by hand.
I already have a personal assistant bot on Telegram (it runs in AWS Lambda), so I wanted to skip the laptop and just text it.
COROS only offers its API to approved partners. But Training Hub is a single-page app, so its JavaScript is public and readable from the login screen.
The main bundle has the API paths as plain strings: /activity/query, /activity/update, /activity/fit/import. The upload code is in one of 253 lazy-loaded chunks. Grepping them turned up the one that bundles the AWS S3 SDK, so the browser uploads to S3 directly with temporary credentials and then tells COROS where the file is.
jsonParameter, with the bucket, object key, md5, size, filename and timezone.The timezone is in 15-minute units, so Pacific Standard Time is -32. Places like Nepal (UTC+5:45) need the finer grain. The upload code also has a branch for Alibaba Cloud OSS, for accounts in China.
The command-line version prints each request as it goes:
$ coros_api.py upload test-walk.fit
→ POST teamapi.coros.com/account/login
→ GET t.coros.com/api/proxy/oss/sts
→ PUT s3://coros-s3/fit_zip/…/ab94…59c6.zip
→ POST teamapi.coros.com/activity/fit/import
✅ COROS accepted the import
Imports always show up as runs, and Training Load fills in a while later once COROS recomputes. That's just how COROS treats imported files.
One surprise: COROS allows one live login per account. When I tested from my laptop while the bot was mid-upload, my login knocked out the bot's token, and it reported a failure for an upload that had actually gone through. Now it logs in again once if that happens, and it can't call an upload failed after COROS has accepted it.
Renaming is one call, POST /activity/update with the activity's ID and a new name. It's the same request the rename box on the activity page sends. It's reversible, so the bot renames anything without asking first and tells me the old name.
Fixing a recording is harder, because Training Hub can't edit distance, time or heart rate. My case was a treadmill run the watch recorded as an outdoor run: the heart rate was right, but GPS said I'd covered 0.27 miles in 26 minutes. The fix:
/activity/detail/download, the same thing the Export button uses) and keep it as a backup.The preview for that run came out at 2.59 miles and 137 feet of climb, with my real heart rate throughout. The bot never deletes the original recording. I do that myself in the app once the new one looks right.
Claude Code did most of the digging. It wouldn't type my password into the COROS site even when I said it could, so it read the public JavaScript instead, which turned out to be enough. It's an unofficial API and could break whenever COROS ships a new web app, but it's my account and my data, and for now it works.
Telling the bot how my heart rate actually behaves. My swims run easier than the generator assumes, so I'd like it to remember that per activity.