Skip to content

Instantly share code, notes, and snippets.

@vanne02135
Created January 15, 2017 09:38
Show Gist options
  • Save vanne02135/6901cc2b92315881080d0ce0f07c1a17 to your computer and use it in GitHub Desktop.
Save vanne02135/6901cc2b92315881080d0ce0f07c1a17 to your computer and use it in GitHub Desktop.
# Demonstrate data download from Emfit API
# Config
remember_token="XXXXXXXX" # token returned from API login
device_id=666 # Your own device id number
from_date = "2017-01-01"
to_date = "2017-01-14"
# End of config
import json
import pandas as pd
import matplotlib.pyplot as plt
import requests
url = "https://api-qs.emfit.com/v3/trends/%d/%s/%s?remember_token=%s"
resp = requests.get(url % (device_id, from_date, to_date, remember_token))
if not resp.ok:
raise Exception("Failed to fetch")
emfit = json.loads(resp.text)
df = pd.DataFrame(emfit["data"]).set_index("date")
df.meas_hr_min.plot()
df.meas_hr_min_sma.plot()
plt.show()
@vanne02135
Copy link
Author

Should plot something like this

screen shot 2017-01-15 at 11 39 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment