Skip to content

Instantly share code, notes, and snippets.

@SamStudio8

SamStudio8/hearty.py

Created Jun 24, 2018
Embed
What would you like to do?
python-fitbit intraday heart
import fitbit
import gather_keys_oauth2 as Oauth2
import datetime
CLIENT_ID = 'YOUR CLIENT'
CLIENT_SECRET = 'YOUR SECRET'
server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET)
server.browser_authorize()
ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token'])
REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token'])
auth2_client = fitbit.Fitbit(CLIENT_ID, CLIENT_SECRET, oauth2=True, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)
hr = auth2_client.intraday_time_series('activities/heart', base_date='2018-06-08', detail_level='1sec')
for record in hr["activities-heart-intraday"]["dataset"]:
print record["time"], record["value"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment