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

@researchable/fitbit-web-api

v0.0.1

Published

Fitbit provides a Web API for accessing data from Fitbit activity trackers Aria scale and manually entered logs Anyone can develop an application to access and modify a Fitbit users data on their behalf so long as it complies with Fitbit Platform Terms o

Downloads

2

Readme

fitbit_web_api

FitbitWebApi - JavaScript client for fitbit_web_api Fitbit provides a Web API for accessing data from Fitbit activity trackers, Aria scale, and manually entered logs. Anyone can develop an application to access and modify a Fitbit user's data on their behalf, so long as it complies with Fitbit Platform Terms of Service. These Swagger UI docs do not currently support making Fitbit API requests directly. In order to make a request, construct a request for the appropriate endpoint using this documentation, and then add an Authorization header to each request with an access token obtained using the steps outlined here: https://dev.fitbit.com/build/reference/web-api/oauth2/#obtaining-consent. This SDK is automatically generated by the Swagger Codegen project:

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install fitbit_web_api --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your fitbit_web_api from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('fitbit_web_api') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var FitbitWebApi = require('fitbit_web_api');

var defaultClient = FitbitWebApi.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = "YOUR ACCESS TOKEN"

var api = new FitbitWebApi.ActivityApi()

var activityId = 56; // {Number} The ID of the activity, directory activity or intensity level activity.

var manualCalories = 56; // {Number} Calories burned that are manaully specified. Required with activityName must be provided.

var startTime = "startTime_example"; // {String} Activity start time. Hours and minutes in the format HH:mm:ss.

var durationMillis = 56; // {Number} Duration in milliseconds.

var _date = new Date("2013-10-20"); // {Date} Log entry date in the format yyyy-MM-dd.

var distance = 56; // {Number} Distance is required for logging directory activity in the format X.XX and in the selected distanceUnit.

var opts = { 
  'activityName': "activityName_example", // {String} Custom activity name. Either activityId or activityName must be provided.
  'distanceUnit': 56 // {Number} Distance measurement unit. Steps units are available only for Walking (activityId=90013) and Running (activityId=90009) directory activities and their intensity levels.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
api.addActivitiesLog(activityId, manualCalories, startTime, durationMillis, _date, distance, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://api.fitbit.com

Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- FitbitWebApi.ActivityApi | addActivitiesLog | POST /1/user/-/activities.json | Log Activity FitbitWebApi.ActivityApi | addFavoriteActivities | POST /1/user/-/activities/favorite/{activity-id}.json | Add Favorite Activity FitbitWebApi.ActivityApi | addUpdateActivitiesGoals | POST /1/user/-/activities/goals/{period}.json | Update Activity Goals FitbitWebApi.ActivityApi | deleteActivitiesLog | DELETE /1/user/-/activities/{activity-log-id}.json | Delete Activity Log FitbitWebApi.ActivityApi | deleteFavoriteActivities | DELETE /1/user/-/activities/favorite/{activity-id}.json | Delete Favorite Activity FitbitWebApi.ActivityApi | getActivitiesByDate | GET /1/user/-/activities/date/{date}.json | Get Activity Summary by Date FitbitWebApi.ActivityApi | getActivitiesGoals | GET /1/user/-/activities/goals/{period}.json | Get Activity Goals FitbitWebApi.ActivityApi | getActivitiesLog | GET /1/user/-/activities.json | Get Lifetime Stats FitbitWebApi.ActivityApi | getActivitiesLogList | GET /1/user/-/activities/list.json | Get Activity Log List FitbitWebApi.ActivityApi | getActivitiesTCX | GET /1/user/-/activities/{log-id}.tcx | Get Activity TCX FitbitWebApi.ActivityApi | getActivitiesTypeDetail | GET /1/activities/{activity-id}.json | Get Activity Type FitbitWebApi.ActivityApi | getActivitiesTypes | GET /1/activities.json | Browse Activity Types FitbitWebApi.ActivityApi | getFavoriteActivities | GET /1/user/-/activities/favorite.json | Get Favorite Activities FitbitWebApi.ActivityApi | getFrequentActivities | GET /1/user/-/activities/frequent.json | Get Frequent Activities FitbitWebApi.ActivityApi | getRecentActivities | GET /1/user/-/activities/recent.json | Get Recent Activity Types FitbitWebApi.ActivityIntradayTimeSeriesApi | getActivitiesResourceByDateIntraday | GET /1/user/-/activities/{resource-path}/date/{date}/1d/{detail-level}.json | Get Intraday Time Series FitbitWebApi.ActivityIntradayTimeSeriesApi | getActivitiesResourceByDateRangeIntraday | GET /1/user/-/activities/{resource-path}/date/{base-date}/{end-date}/{detail-level}.json | Get Activity Intraday Time Series FitbitWebApi.ActivityIntradayTimeSeriesApi | getActivitiesResourceByDateRangeTimeSeriesIntraday | GET /1/user/-/activities/{resource-path}/date/{date}/{end-date}/{detail-level}/time/{start-time}/{end-time}.json | Get Activity Intraday Time Series FitbitWebApi.ActivityIntradayTimeSeriesApi | getActivitiesResourceByDateTimeSeriesIntraday | GET /1/user/-/activities/{resource-path}/date/{date}/1d/{detail-level}/time/{start-time}/{end-time}.json | Get Intraday Time Series FitbitWebApi.ActivityTimeSeriesApi | getActivitiesResourceByDatePeriod | GET /1/user/-/activities/{resource-path}/date/{date}/{period}.json | Get Activity Time Series FitbitWebApi.ActivityTimeSeriesApi | getActivitiesResourceByDateRange | GET /1/user/-/activities/{resource-path}/date/{base-date}/{end-date}.json | Get Activity Resource by Date Range FitbitWebApi.ActivityTimeSeriesApi | getActivitiesTrackerResourceByDatePeriod | GET /1/user/-/activities/tracker/{resource-path}/date/{date}/{period}.json | Get Activity Time Series FitbitWebApi.ActivityTimeSeriesApi | getActivitiesTrackerResourceByDateRange | GET /1/user/-/activities/tracker/{resource-path}/date/{base-date}/{end-date}.json | Get Activity Tracker Resource by Date Range Time Series FitbitWebApi.AuthApi | introspect | POST /1.1/oauth2/introspect | Retrieve the active state of an OAuth 2.0 token FitbitWebApi.AuthApi | oauthToken | POST /oauth2/token | Get OAuth 2 access token FitbitWebApi.BodyAndWeightApi | addBodyFatLog | POST /1/user/-/body/log/fat.json | Log Body Fat FitbitWebApi.BodyAndWeightApi | addWeightLog | POST /1/user/-/body/log/weight.json | Log Weight FitbitWebApi.BodyAndWeightApi | deleteBodyFatLog | DELETE /1/user/-/body/log/fat/{body-fat-log-id}.json | Delete Body Fat Log FitbitWebApi.BodyAndWeightApi | deleteWeightLog | DELETE /1/user/-/body/log/weight/{body-weight-log-id}.json | Delete Weight Log FitbitWebApi.BodyAndWeightApi | getBodyFatByDate | GET /1/user/-/body/log/fat/date/{date}.json | Get Body Fat Logs FitbitWebApi.BodyAndWeightApi | getBodyFatByDatePeriod | GET /1/user/-/body/log/fat/date/{date}/{period}.json | Get Body Fat Logs FitbitWebApi.BodyAndWeightApi | getBodyFatByDateRange | GET /1/user/-/body/log/fat/date/{base-date}/{end-date}.json | Get Body Fat Logs FitbitWebApi.BodyAndWeightApi | getBodyGoals | GET /1/user/-/body/log/{goal-type}/goal.json | Get Body Goals FitbitWebApi.BodyAndWeightApi | getWeightByDate | GET /1/user/-/body/log/weight/date/{date}.json | Get Weight Logs FitbitWebApi.BodyAndWeightApi | getWeightByDatePeriod | GET /1/user/-/body/log/weight/date/{date}/{period}.json | Get Body Fat Logs FitbitWebApi.BodyAndWeightApi | getWeightByDateRange | GET /1/user/-/body/log/weight/date/{base-date}/{end-date}.json | Get Body Fat Logs FitbitWebApi.BodyAndWeightApi | updateBodyFatGoal | POST /1/user/-/body/log/fat/goal.json | Update Body Fat Goal FitbitWebApi.BodyAndWeightApi | updateWeightGoal | POST /1/user/-/body/log/weight/goal.json | Update Weight Goal FitbitWebApi.BodyAndWeightTimeSeriesApi | getBodyResourceByDatePeriod | GET /1/user/-/body/{resource-path}/date/{date}/{period}.json | Get Body Time Series FitbitWebApi.BodyAndWeightTimeSeriesApi | getBodyResourceByDateRange | GET /1/user/-/body/{resource-path}/date/{base-date}/{end-date}.json | Get Body Time Series FitbitWebApi.DevicesApi | addAlarms | POST /1/user/-/devices/tracker/{tracker-id}/alarms.json | Add Alarm FitbitWebApi.DevicesApi | deleteAlarms | DELETE /1/user/-/devices/tracker/{tracker-id}/alarms/{alarm-id}.json | Delete Alarm FitbitWebApi.DevicesApi | getAlarms | GET /1/user/-/devices/tracker/{tracker-id}/alarms.json | Get Alarms FitbitWebApi.DevicesApi | getDevices | GET /1/user/-/devices.json | Get Devices FitbitWebApi.DevicesApi | updateAlarms | POST /1/user/-/devices/tracker/{tracker-id}/alarms/{alarm-id}.json | Update Alarm FitbitWebApi.FoodAndWaterApi | addFavoriteFood | POST /1/user/-/foods/log/favorite/{food-id}.json | Add Favorite Food FitbitWebApi.FoodAndWaterApi | addFoods | POST /1/user/-/foods.json | Create Food FitbitWebApi.FoodAndWaterApi | addFoodsLog | POST /1/user/-/foods/log.json | Log Food FitbitWebApi.FoodAndWaterApi | addMeal | POST /1/user/-/meals.json | Create Meal FitbitWebApi.FoodAndWaterApi | addUpdateFoodsGoal | POST /1/user/-/foods/log/goal.json | Update Food Goal FitbitWebApi.FoodAndWaterApi | addUpdateWaterGoal | POST /1/user/-/foods/log/water/goal.json | Update Water Goal FitbitWebApi.FoodAndWaterApi | addWaterLog | POST /1/user/-/foods/log/water.json | Log Water FitbitWebApi.FoodAndWaterApi | deleteFavoriteFood | DELETE /1/user/-/foods/log/favorite/{food-id}.json | Delete Favorite Food FitbitWebApi.FoodAndWaterApi | deleteFoods | DELETE /1/user/-/foods/{food-id}.json | Delete Custom Food FitbitWebApi.FoodAndWaterApi | deleteFoodsLog | DELETE /1/user/-/foods/log/{food-log-id}.json | Delete Food Log FitbitWebApi.FoodAndWaterApi | deleteMeal | DELETE /1/user/-/meals/{meal-id}.json | Delete Meal FitbitWebApi.FoodAndWaterApi | deleteWaterLog | DELETE /1/user/-/foods/log/water/{water-log-id}.json | Delete Water Log FitbitWebApi.FoodAndWaterApi | getFavoriteFoods | GET /1/user/-/foods/log/favorite.json | Get Favorite Foods FitbitWebApi.FoodAndWaterApi | getFoodsByDate | GET /1/user/-/foods/log/date/{date}.json | Get Food Logs FitbitWebApi.FoodAndWaterApi | getFoodsGoal | GET /1/user/-/foods/log/goal.json | Get Food Goals FitbitWebApi.FoodAndWaterApi | getFoodsInfo | GET /1/foods/{food-id}.json | Get Food FitbitWebApi.FoodAndWaterApi | getFoodsList | GET /1/foods/search.json | Search Foods FitbitWebApi.FoodAndWaterApi | getFoodsLocales | GET /1/foods/locales.json | Get Food Locales FitbitWebApi.FoodAndWaterApi | getFoodsUnits | GET /1/foods/units.json | Get Food Units FitbitWebApi.FoodAndWaterApi | getFrequentFoods | GET /1/user/-/foods/log/frequent.json | Get Frequent Foods FitbitWebApi.FoodAndWaterApi | getMeals | GET /1/user/-/meals.json | Get Meals FitbitWebApi.FoodAndWaterApi | getRecentFoods | GET /1/user/-/foods/log/recent.json | Get Recent Foods FitbitWebApi.FoodAndWaterApi | getWaterByDate | GET /1/user/-/foods/log/water/date/{date}.json | Get Water Logs FitbitWebApi.FoodAndWaterApi | getWaterGoal | GET /1/user/-/foods/log/water/goal.json | Get Water Goal FitbitWebApi.FoodAndWaterApi | updateMeal | POST /1/user/-/meals/{meal-id}.json | Edit Meal FitbitWebApi.FoodAndWaterApi | updateWaterLog | POST /1/user/-/foods/log/water/{water-log-id}.json | Update Water Log FitbitWebApi.FoodAndWaterTimeSeriesApi | getFoodsByDateRange | GET /1/user/-/foods/log/{resource-path}/date/{base-date}/{end-date}.json | Get Food or Water Time Series FitbitWebApi.FoodAndWaterTimeSeriesApi | getFoodsResourceByDatePeriod | GET /1/user/-/foods/log/{resource-path}/date/{date}/{period}.json | Get Food or Water Time Series FitbitWebApi.FriendsApi | createFriendsInvitations | POST /1.1/user/-/friends/invitations | Invite Friends FitbitWebApi.FriendsApi | getFriends | GET /1.1/user/-/friends.json | Get Friends FitbitWebApi.FriendsApi | getFriendsInvitations | GET /1.1/user/-/friends/invitations.json | Get Friend Invitations FitbitWebApi.FriendsApi | getFriendsLeaderboard | GET /1.1/user/-/leaderboard/friends.json | Get Friends Leaderboard FitbitWebApi.FriendsApi | respondFriendsInvitation | POST /1.1/user/-/friends/invitations/{from-user-id} | Respond to Friend Invitation FitbitWebApi.HeartRateIntradayTimeSeriesApi | getHeartByDateIntraday | GET /1/user/-/activities/heart/date/{date}/1d/{detail-level}.json | Get Heart Rate Intraday Time Series FitbitWebApi.HeartRateIntradayTimeSeriesApi | getHeartByDateRangeIntraday | GET /1/user/-/activities/heart/date/{date}/{end-date}/{detail-level}.json | Get Heart Rate Intraday Time Series FitbitWebApi.HeartRateIntradayTimeSeriesApi | getHeartByDateRangeTimestampIntraday | GET /1/user/-/activities/heart/date/{date}/{end-date}/{detail-level}/time/{start-time}/{end-time}.json | Get Heart Rate Intraday Time Series FitbitWebApi.HeartRateIntradayTimeSeriesApi | getHeartByDateTimestampIntraday | GET /1/user/-/activities/heart/date/{date}/1d/{detail-level}/time/{start-time}/{end-time}.json | Get Heart Rate Intraday Time Series FitbitWebApi.HeartRateTimeSeriesApi | getHeartByDatePeriod | GET /1/user/-/activities/heart/date/{date}/{period}.json | Get Heart Rate Time Series FitbitWebApi.HeartRateTimeSeriesApi | getHeartByDateRange | GET /1/user/-/activities/heart/date/{base-date}/{end-date}.json | Get Heart Rate Time Series FitbitWebApi.SleepApi | addSleep | POST /1.2/user/-/sleep.json | Log Sleep FitbitWebApi.SleepApi | deleteSleep | DELETE /1.2/user/-/sleep/{log-id}.json | Delete Sleep Log FitbitWebApi.SleepApi | getSleepByDate | GET /1.2/user/-/sleep/date/{date}.json | Get Sleep Log FitbitWebApi.SleepApi | getSleepByDateRange | GET /1.2/user/-/sleep/date/{base-date}/{end-date}.json | Get Sleep Logs by Date Range FitbitWebApi.SleepApi | getSleepGoal | GET /1.2/user/-/sleep/goal.json | Get Sleep Goal FitbitWebApi.SleepApi | getSleepList | GET /1.2/user/-/sleep/list.json | Get Sleep Logs List FitbitWebApi.SleepApi | updateSleepGoal | POST /1.2/user/-/sleep/goal.json | Update Sleep Goal FitbitWebApi.SubscriptionsApi | addSubscriptions | POST /1/user/-/{collection-path}/apiSubscriptions/{subscription-id}.json | Add a Subscription FitbitWebApi.SubscriptionsApi | deleteSubscriptions | DELETE /1/user/-/{collection-path}/apiSubscriptions/{subscription-id}.json | Delete a Subscription FitbitWebApi.SubscriptionsApi | getSubscriptionsList | GET /1/user/-/{collection-path}/apiSubscriptions.json | Get a List of Subscriptions FitbitWebApi.UserApi | getBadges | GET /1/user/-/badges.json | Get Badges FitbitWebApi.UserApi | getProfile | GET /1/user/-/profile.json | Get Profile FitbitWebApi.UserApi | updateProfile | POST /1/user/-/profile.json | Update Profile

Documentation for Models

Documentation for Authorization

oauth2

  • Type: OAuth
  • Flow: implicit
  • Authorization URL: https://www.fitbit.com/oauth2/authorize
  • Scopes:
    • activity: Activity data and exercise log related features, such as steps, distance, calories burned, and active minutes
    • heartrate: Continuous heart rate data and related analysis
    • location: GPS and other location data
    • nutrition: Calorie consumption and nutrition related features, such as food/water logging, goals, and plans
    • profile: Basic user information
    • settings: User account and device settings, such as alarms
    • sleep: Sleep logs and related sleep analysis
    • social: Friend-related features, such as friend list, invitations, and leaderboard
    • weight: Weight and related information, such as body mass index, body fat percentage, and goals