RADAR-base/RADAR-REST-fitbit

Name: RADAR-REST-fitbit

Owner: RADAR-CNS

Description: null

Created: 2018-02-21 08:42:51.0

Updated: 2018-02-27 17:18:30.0

Pushed: 2018-02-21 12:17:46.0

Homepage: null

Size: 12

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

RADAR-REST-fitbit

This application is designed to poll the Fitbit web API and post data to a Kafka topic.

This repository is intended to be configurable using a web API and by updating a local configuration on app start.

Dependencies
Installation
  1. Install latest version of node from https://nodejs.org
  2. Clone this repository
  3. Run npm install
Configuration

All configuration can be updated by modifying configuration in the config folder / config.json file


"host": "http://localhost", //updates the hosting location of this app
"port": "3000", //updates the port of this app optional
"fitbit": {
    "clientId": "YOUR FITBIT CLIENT ID",
    "clientSecret": "YOUR FITBIT CLIENT SECRET",
    "apiVersion": "1.2",
    "callbackRoute" :"/auth/fitbit/callback", //callback route for Fitbit
    "authRoute": "/auth/fitbit", //initial authorization 
    "dataAuthorized": "activity heartrate location nutrition profile settings sleep social weight", //data you wish to authorize for a specific Fitbit source
    "authorizationHTML": "Fitbit authorized!" //HTML shown on authorization screen
},
"poller":{
    "enabled":true, //starts polling on app launch
    "frequency": "3000", //frequency of polling
    "routesPolled": [ //determines which time series data to poll for
        {
            "resourcePath":"activities/steps", 
            "date":"today", 
            "period":"1d"
        }
    ],
    "enableWebRoutes": true, //disables or enables access to web based polling control via web
    "stopPollingRoute":"/polling/stop", //route for stopping the poller
    "startPollingRoute":"/polling/start" //route for starting the poller
},
"kafka":{
    "host": "http://localhost:9092" //route for default Kafka instance
},
"sources":{
    "enableWebRoutes":true, //enable or disable visibility into source IDs and OAuth Tokens via web
    "deleteSourceRoute":"/sources/delete",
    "deactivateSourceRoute":"/sources/deactivate",
    "listAllSourcesRoute":"/sources/list"
}

Usage
Adding a device
  1. Ensure to update the Fitbit client secret, client id, and callback URLs
  2. Start the app after installation by running npm run start
  3. Add authorized devices by visiting the server auth URL, by default this is https://localhost:3000/auth/fitbit but this is configurable in the config.json file
Stopping the poller
Starting the poller
Getting a list of all devices
Deactivating a device
Deleting a device

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.