This little script runs in the Google App Script environment.
Specifically it runs in Google Spreadsheets. It lets you suck down your Fitbit data and the do all kinds of analysis. It's also an easy way to get started with the Fitbit API. This code is based on the work loghound did in his project. I have added support for heart rate figures that are produced by a Fitbit Charge HR. This version can also be scheduled using triggers.
If you want to know how OAuth 2.0 works, have a look at a sample.
Sadly to get started is a bit of a pain:
- Create a new Google Spreadsheet.
- Go to Tools-->Script Editor
- Replace the template with fitbit.js.
- Save your changes and reload your sheet.
- From the Fitbit menu in your Spreadsheet, run the Configure option. If you don't see the option, run "onInstall" function in script editor and try again.
- Follow the instructions given in the form that pops up. You'll have to set up a Fitbit dev account.
- Run the "Authorize" menu option -- this will run through the OAuth dance.
- Run the 'Refresh fitbit Time Data" menu option to get your data
- Profit!
Optional: 10. Set up a trigger for your script to run periodically. - Script editor --> Resources --> All your triggers --> Add a new trigger for "refreshTimeSeries".