PHPackages                             huitiemesens/fitbit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. huitiemesens/fitbit

ActiveLibrary[API Development](/categories/api)

huitiemesens/fitbit
===================

Fork of popthestack/fitbit with new APIs

0206PHP

Since Oct 14Pushed 10y ago2 watchersCompare

[ Source](https://github.com/huitiemesens/fitbitphp)[ Packagist](https://packagist.org/packages/huitiemesens/fitbit)[ RSS](/packages/huitiemesens-fitbit/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

FitbitPHP
---------

[](#fitbitphp)

Basic wrapper for the OAuth-based [FitBit](http://fitbit.com) [REST API](http://dev.fitbit.com). See [dev.fitbit.com](http://dev.fitbit.com) for details on their OAuth implementation.

Both this library and the Fitbit API are in **beta**.

This library does not require the PHP OAuth extension. It should work on any server with PHP &gt;= 5.3.

Installation
------------

[](#installation)

This package is installable with composer: "huitiemesens/fitbit": "dev-master"

Usage
-----

[](#usage)

You need a consumer key and secret. You can obtain them by registering an application at .

Simple, but full OAuth workflow example:

```
$factory = new \Fitbit\ApiGatewayFactory;
$factory->setCallbackURL($callback_url);
$factory->setCredentials($consumer_key, $consumer_secret);

$adapter = new \OAuth\Common\Storage\Session();
$factory->setStorageAdapter($adapter);

$auth_gateway = $factory->getAuthenticationGateway();

if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
    $auth_gateway->authenticateUser($_GET['oauth_token'], $_GET['oauth_verifier']);
} elseif (isset($_GET['connect'])) {
    $auth_gateway->initiateLogin();
}

if ($auth_gateway->isAuthorized()) {
    $user_gateway = $factory->getUserGateway();
    $user_profile = $user_gateway->getProfile();
    echo '';
    print_r($user_profile);
    echo '';
} else {
    echo 'Not connected.';
}
```

If you want to retrieve the OAuth token and secret from the session to store elsewhere (e.g. a database):

```
$storage = $factory->getStorageAdapter();
$token   = $storage->retrieveAccessToken('FitBit');

// Save these somewhere:
$oauth_token  = $token->getRequestToken();
$oauth_secret = $token->getRequestTokenSecret();
```

Here's how to use your OAuth token and secret without the `Session` storage adapter. It's a little cumbersome, but it works. If I ever have time for it, I'd like to replace the current OAuth library with something that doesn't enforce so much... stuff.

```
$token = new \OAuth\OAuth1\Token\StdOAuth1Token();
$token->setRequestToken($oauth_token);
$token->setRequestTokenSecret($oauth_secret);
$token->setAccessToken($oauth_token);
$token->setAccessTokenSecret($oauth_secret);

$adapter = new \OAuth\Common\Storage\Memory();
$adapter->storeAccessToken('FitBit', $token);

$factory->setStorageAdapter($adapter);

$user_gateway = $factory->getUserGateway();
$food_gateway = $factory->getFoodGateway();

$user_profile = $user_gateway->getProfile();
$user_devices = $user_gateway->getDevices();
$foods        = $food_gateway->searchFoods('banana split');

echo '';
print_r($user_profile);
print_r($user_devices);
print_r($foods);
echo '';
```

Notes
-----

[](#notes)

- By default, all requests assume you want data for the authorized user (viewer). There are, however, several endpoints you can use to access the data of other Fitbit users, given that you have permission to access their data. This is accomplished by setting the Fitbit User ID with the `setUserID` method available on `ApiGatewayFactory` and the Endpoint Gateways (e.g. `UserGateway`, `FoodGateway`).
- *Subscriptions*: this library has some basic methods to add/delete subscriptions, but it's your responsibility to track the list and maintain server endpoints to receive notifications from Fitbit, as well as register them at . See [Subscriptions API](https://wiki.fitbit.com/display/API/Fitbit+Subscriptions+API) for more information.

New API
-------

[](#new-api)

- getWeight in BodyGateway : Allow to get all weight log over a period, a range date or on a specific date. check on  for more information

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/eba6ae6fa4e203e423b4e4161ede7075ab3c2c5b431c547888f0205fee820bf1?d=identicon)[huitiemesens](/maintainers/huitiemesens)

---

Top Contributors

[![pavelrisenberg](https://avatars.githubusercontent.com/u/576661?v=4)](https://github.com/pavelrisenberg "pavelrisenberg (13 commits)")[![elicwhite](https://avatars.githubusercontent.com/u/249164?v=4)](https://github.com/elicwhite "elicwhite (12 commits)")[![popthestack](https://avatars.githubusercontent.com/u/136891?v=4)](https://github.com/popthestack "popthestack (3 commits)")[![jgkim](https://avatars.githubusercontent.com/u/86622?v=4)](https://github.com/jgkim "jgkim (2 commits)")[![nassuf](https://avatars.githubusercontent.com/u/7489336?v=4)](https://github.com/nassuf "nassuf (2 commits)")[![saschahagedorn](https://avatars.githubusercontent.com/u/16554930?v=4)](https://github.com/saschahagedorn "saschahagedorn (1 commits)")

### Embed Badge

![Health badge](/badges/huitiemesens-fitbit/health.svg)

```
[![Health](https://phpackages.com/badges/huitiemesens-fitbit/health.svg)](https://phpackages.com/packages/huitiemesens-fitbit)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
