0

Using CURL to Collect Oura Ring Sleep, Activity and Readiness Data

You have probably experienced frustration when trying to gather insights from your sleep, exercise, weight and diet tracking devices. Should I got to bed earlier? Eat more protein? Exercise at a lower intensity? The trouble is that each device tends to have have a customized app or website which makes comparing the data complicated. In this post I’ll showing how the Oura Ring like many trackers offers a REST interface which makes pulling down data from many tracking sites and combining it into one place a possibility. It also allows one to free their data and keep a personal backup.

While this demonstration is based on the Oura Ring aside from the initial setup the process will be quite similar for most fitness trackers.

Step 1: Setup an Application

  • this does require an Oura Ring account
  • website: https://cloud.ouraring.com/docs/
  • click on ‘My Applications
  • Display name: Adafruit REST Demo
  • Website: localhost
  • Click: ‘Save

Step 2: Get a Token

  • click the top URL [server-size flow authorization]
  • accepts the privacy policy
  • click ‘Submit POST request
  • the next page will be one line of text save the value for “access token”
  • mine looked like this: “WGZGSPT6PEDN5RQALOSRY5RKJNCIJ3UB”
  • don’t worry I deleted this before this post went out.

Step 3: Last Nights Sleep Data Using CURL

  • $ curl –header “Authorization: Bearer WGZGSPT6PEDN5RQALOSRY5RKJNCIJ3UB” https://api.ouraring.com/v1/sleep?start=2017-10-01

    {“sleep”: [{“deep”: 6480, “bedtime_start”: “2017-10-01T22:17:01-06:00”, “rmssd”: 57, “light”: 10380, “hypnogram_5min”: “4442111111111121121111222222444244444222222222211111122222243333333222211232333444”, “restless”: 30, “awake”: 4110, “breath_average”: 14, “efficiency”: 83, “hr_5min”: “summary_date”: “2017-10-01”, “score_alignment”: 100, “duration”: 24600, “timezone”: -360, “total”: 20490, “score_efficiency”: 79, “temperature_delta”: -0.03, “score_rem”: 54, “onset_latency”: 900, “rem”: 3630, “bedtime_end”: “2017-10-02T05:07:01-06:00”, “is_longest”: 1, “score”: 75, “hr_lowest”: 51, “score_latency”: 99, “score_total”: 58, “score_disturbances”: 77, “hr_average”: 55.375, “midpoint_time”: 12390, “score_deep”: 97, “rmssd_5min”:

Step 4: Yesterdays Exercise Data Using CURL

  • $ curl –header “Authorization: Bearer WGZGSPT6PEDN5RQALOSRY5RKJNCIJ3UB” https://api.ouraring.com/v1/activity?start=2017-10-01

    {“activity”: [{“met_min_inactive”: 5, “met_min_high”: 115, “score_training_volume”: 100, “score_meet_daily_targets”: 100, “inactivity_alerts”: 0, “score_training_frequency”: 100, “met_min_medium”: 652, “class_5min”: “daily_movement”: 21612, “non_wear”: 132, “summary_date”: “2017-10-01”, “inactive”: 409, “cal_total”: 2938, “timezone”: -360, “rest”: 465, “score_stay_active”: 86, “low”: 248, “day_start”: “2017-10-01T04:00:00-06:00”, “met_min_low”: 179, “high”: 15, “medium”: 171, “met_1min”:

Step 5: Yesterdays Readiness Assessment Using CURL

  • $ curl –header “Authorization: Bearer WGZGSPT6PEDN5RQALOSRY5RKJNCIJ3UB” https://api.ouraring.com/v1/readiness?start=2017-10-01

    {“readiness”: [{“score_previous_night”: 63, “score_temperature”: 100, “summary_date”: “2017-10-01”, “period_id”: 0, “score_sleep_balance”: 64, “score_activity_balance”: 11, “score”: 55, “score_previous_day”: 42, “score_recovery_index”: 77, “

Two Thoughts:

  • I’m only showing one days worth of data and I cropped out the raw data as it is a little overwhelming. If we wanted to see months or years at a time simply adding ‘\&end=2017-10-02′ would provide a start and stop range that is easily adjusted on the command line. 
  • Oura and most other fitness trackers have great apps and websites for us to utilize. However, those of us who want to passively track our data and review it in one location we need to write some code. More posts to come on crossing tracking boundaries.

Make a robot friend with Adafruit’s CRICKIT – A Creative Robotics & Interactive Construction Kit. It’s an add-on to our popular Circuit Playground Express, FEATHER and other platforms to make and program robots with CircuitPython, MakeCode, and Arduino. Start controlling motors, servos, solenoids. You also get signal pins, capacitive touch sensors, a NeoPixel driver and amplified speaker output. It complements & extends your boards so you can still use all the goodies on the microcontroller, now you have a robotics playground as well.

Join 7,500+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython in 2018 – Python on Microcontrollers is here!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/


Maker Business — Despite multiple bankruptcies, RadioShack continues to find ways to keep the lights on

Wearables — Tape, meet 3D printing

Electronics — A few words on inductor resistance

Biohacking — Running Blades

Python for Microcontrollers — Help bring CircuitPython to other languages!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



No Comments

No comments yet.

Sorry, the comment form is closed at this time.