Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retrieve the last 10 days of UP data from the jawbone nudge API
import requests
import json
import pandas
import pylab as plt
import auth
# Get auth token
r = requests.post("https://jawbone.com/user/signin/login", {
'pwd': auth.pwd,
'email': auth.email,
'service': 'nudge'
})
token = json.loads(r.text)['token']
# Get list of recent moves
data = requests.get("https://jawbone.com/nudge/api/users/@me/moves", headers={'x-nudge-token': token})
j = data.json()
# Store as json blob
file("data/moves.json", 'w').write(json.dumps(j, indent=2))
# Get all the moves object snapshots
M = []
for i,item in enumerate(j["data"]["items"]):
move_xid = item["xid"]
req = requests.get("https://jawbone.com/nudge/api/moves/" + move_xid + "/snapshot", headers={'x-nudge-token': token})
move_data = json.loads(req.text)
M.append(move_data)
# Store to jsonline file
file("data/snapshots.jl", 'w').write("\n".join([json.dumps(m) for m in M]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment