I wrote this code because there is no way to do bulk download of your logbook data that includes stroke data for every session that has it. In other words, bulk downloads only get you summary data. If you want detail data then you have to select every session and download it one by one. That sucks.
Code: Select all
import requests
import json
api_root = 'https://log.concept2.com'
api_token = 'YOUR_API_TOKEN'
endpoint = f"{api_root}/api/users/me/results"
headers = {"Authorization": f"Bearer {api_token}"}
page = 1
next_page = endpoint
def getPage(nextPage):
global next_page
print(nextPage)
res = requests.get(nextPage, headers = headers)
outfile = 'page'+str(page)+'.json'
with open(outfile,'w') as f:
json.dump(res.json(),f,indent=4)
try:
next_page = res.json()["meta"]["pagination"]["links"]["next"]
except:
next_page = ''
while next_page != '':
getPage(next_page)
page += 1