npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fitbit-node

v2.2.0

Published

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

Downloads

354

Readme

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.