GithubHelp home page GithubHelp logo

nauw / fitbit-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukasolson/fitbit-node

0.0 0.0 0.0 28 KB

An API client library for Fitbit, written in NodeJS.

License: MIT License

JavaScript 100.00%

fitbit-node's Introduction

Fitbit-Node

An API client library for Fitbit written in Node.js.

Usage

  1. npm install fitbit-node
  2. (In your JS file) var FitbitApiClient = require("fitbit-node");

API

new FitbitApiClient({clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET", apiVersion: "1.2"})

Constructor. Use the clientId and clientSecret provided to you when you registered your application on dev.fitbit.com. The apiVersion is by default 1.2

getAuthorizeUrl(scope, redirectUrl, [prompt], [state])

Construct the authorization URL. This is the first step of the OAuth 2.0 flow. Returns a string. When this string containing the authorization URL on the Fitbit site is returned, redirect the user to that URL for authorization. The scope (a string of space-delimitted scope values you wish to obtain authorization for) and the redirectUrl (a string for the URL where you want Fitbit to redirect the user after authorization) are required. See the Scope section in Fitbit's API documentation for more details about possible scope values. See the Authorization Page section in Fitbit's API documentation for more details about possible prompt and state values.

getAccessToken(code, redirectUrl)

After the user authorizes your application with Fitbit, they will be forwarded to the redirectUrl you specified when calling getAuthorizationUrl(), and the code will be present in the URL. Use this to exchange the authorization code for an access token in order to make API calls. Returns a promise.

refreshAccessToken(accessToken, refreshToken, [expiresIn])

Refresh the user's access token, in the event that it has expired. The accessToken and refreshToken (returned as refresh_token alongside the access_token by the getAccessToken() method) are required. The expiresIn parameter specifies the new desired access token lifetime in seconds. Returns a promise.

revokeAccessToken(accessToken)

Revoke the user's access token. The accessToken to be revoked is required. Returns a promise.

get(path, accessToken, [userId], [extraHeaders])

Make a GET API call to the Fitbit servers. (See example.js for an example.) Returns a promise.

post(path, accessToken, data, [userId], [extraHeaders])

Make a POST API call to the Fitbit servers. Returns a promise.

put(path, accessToken, data, [userId], [extraHeaders])

Make a PUT API call to the Fitbit servers. Returns a promise.

delete(path, accessToken, [userId], [extraHeaders])

Make a DELETE API call to the Fitbit servers. Returns a promise.

Custom HTTP Headers

Some Fitbit API calls (such as adding subscriptions) accept an optional HTTP header. The get, post, put, and delete functions accept an optional parameter with an object with HTTP headers to handle these kind of calls (extraHeaders above). The default Authorization header is merged with the provided parameter, if it exists.

fitbit-node's People

Contributors

mbmccormick avatar lukasolson avatar jmdiego avatar foundling avatar jharris avatar twelve17 avatar xxzefgh avatar stephenyeargin avatar

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.