Welcome

Hi, welcome to my Fitbit project page! I put this site together to share some of my code and other "hacks" for my Fitbit device. If you have any questions, or would like to contact me, you can visit my Contact page on my main site.

First of all, what exactly is a Fitbit? Chances are if you've stumbled here you have a pretty good idea. If not, Fitbit is a tiny magical device($99 USD) that automatically tracks your fitness and sleep statistics. Throughout the day it will track your calories burned, steps taken, distance traveled, your activity level, and even track your sleep patterns. All of this data is synced wirelessly through your base station to Fitbit's website where you can get very detailed daily and historical graphs. The main benefit is that you can be conscious of and keep track of your fitness level, food your eating, and how well you're sleeping so you can make better choices throughout the day. Hopefully Fitbit will get you from fat to fit, bit by bit (I have no future in marketing) :)

ActiveOS - The Wearables Insights Platform

What's to Hack?

Out of the box, the Fitbit device and website gives you pretty much all you need. However, I think there are 2 major things that could be accomplished through some APIs and automation:

  1. Data Download - As of right now, users don't have the ability to download data that is tracked by the Fitbit and subsequently uploaded to the website. Reading through the support forums shows that the development team is currently working on this and it seems to be in high demand. It appears that some official API (REST using JSON or XML) is in the works and possibly some sort of CSV download.
  2. 3rd Party Integration - There are a number of other fitness devices and applications that could benefit from integrating with the Fitbit site. One great example is the Wi-Fi enabled scale from Withings. Each time I step on the scale it will automatically upload my current weight and BMI info to the Withings website and iPhone app. It would be great to automatically upload my current weight directly to fitbit.com.

API

Code is hosted via GitHub at http://github.com/ericblue/Perl-FitBit-API

Until an official API is announced, I've decided to write my own in Perl. Although there isn't a fitbit-endorsed API for getting access to data, it is possible to retrieve using the XML feeds that are used to populate the flash-based charts on the site. I was inspired by another project I recently discovered that's written in Python (by Wade Simmons). My API is similar in syntax and function, but offers some additional methods for retrieving historical/aggregate numbers. Current API features:

Intraday (5min and 1min intervals) logs are provide for:

  • calories burned
  • activity score
  • steps taken
  • sleep activity (every 1 min)
Historical (aggregate) info is provided for:
  • calories burned / consumed
  • activity score
  • steps taken
  • distance travels (miles)
  • sleep (total time in hours, and times awoken)

Sample Perl Code

#!/usr/bin/perl

use FitbitClient;

my $fb = new FitbitClient( config => 'conf/fitbit.conf' );

print "Total calories burned = " .
  $fb->total_calories()->{burned} . "\n";
print "Total calories consumed = " . 
  $fb->total_calories()->{consumed} . "\n";

#my @log = $fb->get_calories_log("2010-05-01");
#foreach (@log) {
#    print "time = $_->{time} : calories = $_->{value}\n";
#}
#

print "score = " . $fb->total_active_score("2010-05-01");
print "steps = " . $fb->total_steps("2010-05-01");
print "distance (mi) = " . $fb->total_distance("2010-05-01");

my $ah = $fb->total_active_hours("2010-05-01");
print "active hrs = very[$ah->{very}], fair[$ah->{fairly}]\n";

my $st = $fb->total_sleep_time("2010-05-01");
print "sleep = hrs[$st->{hours_asleep}]\n";

CSV Export

The following CSV export currently supports daily/historical values. Support for intraday (5 min) intervals will be added shortly. In order to access the Fitbit site, the API needs a number of values to download data. This includes the user_id (available from your profile url on fitbit.com - i.e. http://www.fitbit.com/user/XXXNSD), sid, uid, and uis (set as a cookie - you'll need to grab these values from your browser. Check out WikiHow for a good tutorial on how to get these cookie values.).

CSV Columns:
DATE,BURNED,CONSUMED,SCORE,STEPS,DISTANCE,ACTIVE_VERY,ACTIVE_FAIR,ACTIVE_LIGHT,SLEEP_TIME,AWOKEN

[Replace the following values with your own]
user_id
uid
uis
sid
# days (max 120 days)
 

Future Plans

I have a number of things I'd like to do for the future:

  • Create a mobile-enabled site (mainly for iPhone and iPad)
  • Export to a database: sqlite or mysql
  • Add Javascript graph for mobiled-enable site. Currently Fitbit is Flash which will not work on iPhone/iPad
  • Integrate with Withings API