Previous topic

access_jawbone module

This Page

get_sleep_data module

synopsis:Example code to demonstrate how to “GET” JSON data from Jawbone UP API
get_sleep_data.main()[source]
To compile this example code, run the command: python get_sleep_data.py user_email user_password https://jawbone.com/nudge/api/users/@me/sleeps? &
  • EXAMPLE_1 : “GET” the bulk of sleep event data
    • Use access_jawbone.args_store() to receive the command-line arguments
      • arg1 - user_email associated with Jawbone account
      • arg2 - user_password associated with Jawbone account
      • arg3 - data request url for this example https://jawbone.com/nudge/api/users/@me/sleeps?
    • Run access_jawbone.authenticate() for secure access to jawbone data
      returns:security token
    • Employ access_jawbone.get_data() to “GET” sleep data from Jawbone API
      returns:user xid, event xid, date, sleep time, awake time, number of awakenings, duration of sleep event, quality score, etc.
    • Operate on JSON data dictionary and use JSON.dumps to print in readable format

    • Convert timestamps into a readable format with access_jawbone.format() function

    • Create list of sleep events ‘xid’ which serve as the input for EXAMPLE_2
      returns:'xid' for each sleep event
  • EXAMPLE_2 : “GET” detailed data about sleep phases
    • Operate on the list of sleep events ‘xid’ obtained in EXAMPLE_1

    • Insert sleep event xid[item] into detailed data request url 'https://jawbone.com/nudge/api/sleeps/' + xid[item] + '/ticks'

    • Employ access_jawbone.get_data() to “GET” detailed sleep phase data
      returns:timing of sleep phases (1=awake, 2=light sleep, 3=sound sleep)