ruby-fitbit¶ ↑
This is a Ruby API for the fitbit and the data at fitbit.com
Currently the gem uses screen scraping to get the data, but it will switch over to use the official API once available. The current set of data it retrieves is pretty limited, but it should grow over time. Originally built just to display a dashboard of my current fitbit stats on my blog. I started adding additonal data scrapped from the graphs. Which allows me to export the data or do my own charting. This is heavily influenced by the Python fitbit API from @wadey (github.com/wadey/python-fitbit), and also has a bit of inspiration from the perl API (eric-blue.com/projects/fitbit/). Thanks for their code to help me work out the API.
Usage¶ ↑
install `gem install ruby-fitbit` run `ruby-fitbit your@email.com YourPassword` ruby usage require 'ruby-fitbit' fitbit = RubyFitbit.new(EMAIL,PASSWORD) puts "Calories Burned #{fitbit.calories}" ... look at bin.ruby-fitbit for example usage of coding to the client. output ~/projects/ruby-fitbit(master) > ruby bin/ruby-fitbit my@email.com MYPASS Calories Burned 803 Steps Taken 552 Milkes Walked .23 Activity Levels Durations: Sedentary 11hrs 1min Lightly 18min Fairly 16min Very 0min done advanced usage: Print activity, steps, or calorie data broken down in 5 minute chunks for a given date. ~/projects/ruby-fitbit(master) > ruby bin/ruby-fitbit my@email.com MYPASS activity 06/22/2010 Calories Burned 803 Steps Taken 552 Milkes Walked .23 Activity Levels Durations: Sedentary 11hrs 1min Lightly 18min Fairly 16min Very 0min +--------------------------------+------+ | 0 | 1 | +--------------------------------+------+ | Tue Jun 22 21:50:00 -0400 2010 | 10.0 | | Tue Jun 22 05:05:00 -0400 2010 | 0.0 | | Tue Jun 22 16:15:00 -0400 2010 | 0.0 | | Tue Jun 22 10:40:00 -0400 2010 | 0.0 | ... done Aggregated Data ruby bin/ruby-fitbit dan@email.com pass summary 07/07/2010 07/04/2010 getting aggregated data | 2010-07-04 | {"miles_walked"=>"2.97", "steps"=>"6976", "lightly_active"=>"3hrs 3min", "sedentary_active"=>"18hrs ... | | 2010-07-05 | {"miles_walked"=>"4.98", "steps"=>"11711", "lightly_active"=>"2hrs 21min", "sedentary_active"=>"2hrs... | | 2010-07-06 | {"miles_walked"=>"4.68", "steps"=>"10014", "lightly_active"=>"1hr 17min", "sedentary_active"=>"20hrs... | ... Average Data over that time +--------------+------------------+ | miles_walked | 4.03857142857143 | | steps | 8953.85714285714 | | calories | 2247.71428571429 | +--------------+------------------+
TODOs¶ ↑
-
get food data intake tracked etc
-
add ability for gem to write data to fitbit
-
better cmd line output
-
add data caching, currently it refetches every time. especially dumb when it does it twice for aggragate and avg data
-
Support Avgs over all data_point
-
create ruby-fitbit exceptions
Note on Patches/Pull Requests¶ ↑
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
-
user dailyTotals id to scrape the current food log from www.fitbit.com/foods/log/2010/10/07 for display
Copyright¶ ↑
Copyright © 2010 Dan Mayer. See LICENSE for details.