Fitbit – Unofficial Perl API and CSV Download

Fitbit – Unofficial Perl API and CSV Download

The other week I received my Fitbit and have been in geek heaven ever since. 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.
The Fitbit team is working hard on manufacturing and distribution and have future plans for releasing an official API. Although the website does offer most of the features you’ll need, you can not download your data. The goals is to have an API that will allow you to do this and also integrate some other applications. I spent some time coding last weekend and have create an OO Perl API to access all Fitbit information and even download historical data in CSV format. I’ve setup a ‘Fitbit Hack’ project. Check out:

http://eric-blue.com/projects/fitbit/

(Visited 3,741 times, 1 visits today)

8 Responses

  1. […] blog post: Fitbit – Unofficial Perl API and CSV Download http://eric-blue.com/?p=1206 […]

  2. jrnold says:

    Thanks for the api. While not a Perl user myself, it inspired me to fork and improve on the wadey’s python-fitbit api. My fork can be found at http://github.com/jrnold/python-fitbit. Here are a few things that I learned and thought you might find useful.
    All the historical graph calls can take periods of greater than 1 day. I found that they will accept 1d, 7d, 1m, 3m, 6m, 1y, and max for the period argument.
    The way I solved the cross-date problem with sleep-data as well as finding multiple sleep records for a single day is to parse http://www.fitbit.com/sleep/yyyy/mm/dd for the given date. From this, I got the ids for all the sleep records on that day. The “To Bed At” element includes both the date and time, so for the graph observations it is just a matter of incrementing one minute from the start time for each data point.
    I was also able to get data on logged activities, and activity records (both summary data and the per minute data in the flash graphs) by parsing http://www.fitbit.com/activities/yyyy/mm/dd.

  3. Thanks for doing this. When I read the Fitbit didn’t let you easily get at your data, I figured there might be a Perl solution. 😉

  4. Hi, is your code available on Github or any other sort of public RCS site? I’d like to hack on this a bit, but it’s not clear whether the code available from your site is all there is at this point, or whether there’s a test suite that’s not exposed…
    If I could help out, I’d be happy to help you get what you’ve got up on Github with an eye towards eventually getting it onto CPAN so that it’s easier for other people to find and extend — drop me a line if that’s something I could help with.

  5. Eric Blue says:

    Hi John,
    It’s not currently hosted on any public site, however I was planning on eventually doing it (now is probably a good time!). I’d appreciate any help you can offer. My time is limited, and any way I can get the code out to the public so they can contribute in turn would be fantastic.
    I’ll send you a follow-up email shortly to work out the details.

  6. […] Box WordPress PluginLast month I announced a new “hacking” project – creating a Perl API for my FitBit device.  Traditionally, whenever I host one of my projects I usually include both the project page and […]

  7. […] help ease my own effort to download data and help other developers, I decided to create my own OO Perl library similar to the one I initially created for Fitbit back in May.  Unlike the FitBit libary which is somewhat unofficial (Fitbit does not offer […]

Leave a Reply

Your email address will not be published. Required fields are marked *