Giter Club home page Giter Club logo

fitbit-omni-api's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.