Skip to content

Instantly share code, notes, and snippets.

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 ="", {
'pwd': auth.pwd,
'service': 'nudge'
token = json.loads(r.text)['token']
# Get list of recent moves
data = requests.get("", 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("" + move_xid + "/snapshot", headers={'x-nudge-token': token})
move_data = json.loads(req.text)
# 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