0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Fitbit OmniAuth strategy + API wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

UNMAINTAINED -- Fitbit-Omni-Api

This gem uses the OmniAuth-Fitbit Strategy for authentication. See that repo for more info.

Accessing the Fitbit API

There are breaking changes in this version.

Installation

Add the gem to your Gemfile

gem 'fitbit-omni-api'

The gem class is simply 'Fitbit::Api' and Fitbit Api requests are made with the 'Fitbit::Api.request' method.

Each API request needs:

  • Your Fitbit consumer_key and consumer_secret (acquired from dev.fitbit.com)
  • A params Hash with api-method and required parameters
  • Optionally, Fitbit auth tokens or user-id if required

This is the structure of an authenticated API call:

Fitbit::Api.request(
  'consumer_key',
  'consumer_secret',
  params = { 'api-method' => 'api-method-here', 'start-time' => '00:00' }
  'auth_token',
  'auth_secret'
)

This gem supports the Fitbit Resource Access API, Fitbit Subscriptions API and Fitbit Partner API.

To access the Resource Access API, consult the API docs and provide the required parameters. For example, the API-Search-Foods method requires 'api-version', 'query' and 'response-format', plus there's an optional 'Accept-Locale' Request Header parameter.

A call to API-Search-Foods might look like this:

def fitbit_foods_search
  request = Fitbit::Api.request(
    'consumer_key',
    'consumer_secret',
    params={'api-method'=>'api-search-foods','query'=>'buffalo chicken','Accept-Locale'=>'en_US'}
    'auth_token',
    'auth_secret'
  )
  @response = request.body
end

Fitbit Subscriptions API

Use API-Create-Subscription and API-Delete-Subscription API methods to to access the Subscription API. Consult the Subscription API docs to discover the required parameters. To subscribe to ALL of a user's changes, make 'collection-path' = 'all'.

Fitbit Partner API

These features are only accessible with approved Fitbit developer accounts.

Defaults:

  • 'api-version' defaults to '1'
  • 'response-format' defaults to 'xml'

Copyright

Copyright (c) 2012 TK Gospodinov, (c) Scott McGrath 2013. See LICENSE for details.