-
-
Save wassupluke/8b092f66202967a10fabdf3f00c933eb to your computer and use it in GitHub Desktop.
Python Script to get data from COROS Training Hub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Python PoC to interact with COROS Training Hub. | |
| URL : https://training.coros.com/ | |
| This script retrieves COROS's activity list for 2022/12. | |
| $ python3 coros_activity_list.py | |
| date,name,sportType,totalTime,distance,calorie,trainingLoad | |
| 20221230,Foo Run,100,9538,14651.11,1266085,117 | |
| 20221218,Bar,100,14696,24009.9,2135983,264 | |
| ''' | |
| import csv | |
| import json | |
| import sys | |
| import requests | |
| # get access token | |
| headers = { | |
| "content-type": "application/json", | |
| } | |
| payload = '{"account":"foo@example.com","accountType":2,"pwd":"YOUR_HASHED_PASSWORD"}' # FIXME | |
| URL_AUTH = "https://teamapi.coros.com/account/login" | |
| res_auth = json.loads(requests.post(URL_AUTH, headers=headers, data=payload).text) | |
| token = res_auth["data"]["accessToken"] | |
| # get data | |
| headers = { | |
| "accesstoken": token, | |
| "content-type": "application/json", | |
| } | |
| ## data range : 20221201 to 20221231 | |
| URL_DATA = "https://teamapi.coros.com/activity/query?size=50&pageNumber=1&startDay=20221201&endDay=20221231&modeList=" | |
| res_data = json.loads(requests.get(URL_DATA, headers=headers).text) | |
| # process data | |
| header = [ | |
| "date", | |
| "name", | |
| "sportType", | |
| "totalTime", | |
| "distance", | |
| "calorie", | |
| "trainingLoad", | |
| ] | |
| cw = csv.DictWriter(sys.stdout, header, extrasaction="ignore") | |
| cw.writeheader() | |
| cw.writerows(res_data["data"]["dataList"]) |
does this actually work? Where should I get my password hash?
Author
@KjellVerb great question. I had forked this and thought I was close to figuring it out and updating the gist with instructions but I still haven't gotten it to work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks