Getting Data from FitBit

Getting data out of a FitBit, as Rob pointed out, is not as easy as simply clicking an export button on the FitBit website. Fortunately, FitBit released their API to developers in February and since then a few solutions of obtaining the raw data have been realized. John McLaughlin has written an open source script (available on GitHub) that enables FitBit users to download their data into a Google spreadsheet.

Ernesto Ramirez (a Community Organizer for Quantified Self) has put together a tutorial on Vimeo for Importing FitBit data into Google Spreadsheets. His directions are also printed below.

How to set up FitBit & Google Spreadsheets integration:

  1. Download the FitBit For Google Apps Script from Github
    • Open the Github repository for the script
    • Click the downloads button and save the .zip file to your computer.
    • Unzip the folder and open the fitbit.js file in a text editor.
  2. Set up your FitBit Developer account and register an app.
    • Go to dev.fitbit.com and sign in using your FitBit login information.
    • Click on the “Register an App” at the top right corner of the page.
    • Fill in you application information. You can call it what you want. Make sure to click “Browser” for the Application Type and “Read Only” for the Default Access type fields. (Note: The URL fields are required. These can be your personal website, etc. They aren’t that important to using this script, but are needed to register an application.)
    • Read the terms of service and if you agree check the box and click “Register”
  3. Record the API keys
    • Copy the Consumer Key
    • Copy the Consumer Secret
    • You can save these to a text file, but they are also available anytime you return to dev.fitbit.com by clicking on the “Manage my Apps” tab.
  4. Set up Google Spreadsheet Script
    • Create a new google spreadsheet.
    • Go to Tools->Script Editor
    • Replace the template with fitbit.js (copy the entire thing from your text editor and paste it into the template)
    • Save the script and name it.
    • Click the “Select Function” button menu and choose “renderFitbitConfigurationDialog”. Run the script by clicking the play button.
    • Run the “renderFitbitConfigurationDialog” function again. In your spreadsheet window, enter your consumer key and consumer secret in the dialog box.
    • Select “Authorize” from the “Select Function” button menu and run the script.
    • Enter your FitBit user name and password in the dialog box.
    • Select the ‘refreshTimeSeries” function and run it to get your data. (Note: If you get the following error: TypeError: Cannot call method “getContentText” of undefined. (line 77),  select and run the “renderFitbitConfigurationDialog” function, making sure to select one or multiple items in the Loggables list box.)

You can also set up an automatic trigger to update your spreadsheet automatically with new data. To do this:

  • Go to Tools-> Script Editor
  • Go to the “Trigger” menu and select ‘current scripts triggers’
  • Add a new trigger that runs ‘refreshTimeSeries’ that is ‘time driven’ and choose an interval for the spreadsheet to update (e.g., ‘hour timer’ updates the spreadsheet ‘hourly’).
  • Click save.

Fit Bit

I just bought a “personal fitness tracking device.”  It records my every movement.  Even keeps track of when I sleep, in theory at least.  So far, its pretty cool.  Certainly its made me aware of how many steps I take during a day, and how rarely I meet the sacred 10,000 step goal. Today, for example, I’ve taken 8748 steps. Although, since its 9:30pm, the day is still young.

What’s frustrating is that even though its my data, it’s not “mine”.  I can’t see the entries, and I can’t do my own analysis.  I’d like to produce a nice 5-number summary of my daily step totals, for instance. But I can’t.  Best I can do is find this graph

And I’d love to plot this against other variables, but I have to live with their choices.

One interesting thing is how missing data becomes much more meaningful when the data missing is yours.  For example, for the last few nights, I’ve worn the damn thing around my wrist at night to keep track of my sleep—but forgotten to turn it ‘on’.  And so its missing. And I’m pretty sure it’s missing at random.  Tonight, of course, I will remember. I think.

Tomorrow, though, I will fly on an airplane, and so I expect that the activity levels will be quite low.  It would be great if there was a way of recording this, and then taking it into account in future analyses.  All this would be possible, of course, if they would “free” your data.

Introduction

We live in the Data Deluge, but we confess we still teach stats as if data were rare and easily-managed.  But in this blog, we embrace the Deluge, an age where data and software are accessible and ubiquitous.  The day of telling students to pay attention because Some Day This Will Be Good For You are over.  This stuff is good for them NOW, and we need to show them why.

In the future, we hope to share our thoughts about teaching future data scientists, fun data sets, cool apps, exciting software. That sort of thing.  It’s all about data.