Skip to content

Instantly share code, notes, and snippets.

@cbrannen9a
Created July 3, 2018 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbrannen9a/45c3ad5527f12e1f3f18a6b98c219704 to your computer and use it in GitHub Desktop.
Save cbrannen9a/45c3ad5527f12e1f3f18a6b98c219704 to your computer and use it in GitHub Desktop.
Test script for obtaining athlete data
import requests
import json
from pprint import pprint
apikey = 'YOUR_API_KEY'
url = 'https://api.triathlon.org/v1/athletes/'
query = '{0}?output=basic'
local_filename = 'test.txt'
params = {}
headers = {'content-type': 'application/json',
'Accept-Charset': 'UTF-8', 'apikey': apikey}
r = requests.get(url + query.format('75945'),
headers=headers, params=params, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
data = json.load(open(local_filename))
pprint(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment