### Navigation

- index
- Python-Fitbit 0.0.2 documentation »

# Overview

This is a complete python implementation of the Fitbit API.

It uses oAuath for authentication, it supports both us and si measurements

# Quickstart

Here is some example usage:

    import fitbit
    unauth_client = fitbit.Fitbit('<consumer_key>', '<consumer_secret>')
    # certain methods do not require user keys
    unauth_client.activities()

    # You'll have to gather the user keys on your own, or try ./fitbit/gather_keys_cli.py <con_key> <con_sec> for development
    authd_client = fitbit.Fitbit('<consumer_key>', '<consumer_secret>', user_key='<user_key>', user_secret='<user_secret>')
    authd_client.sleep()

# Fitbit API

Some assumptions you should note. Anywhere it says user_id=None, it assumes the current user_id from the credentials given, and passes a `-` through the API. Anywhere it says date=None, it should accept either `None` or a `date` or `datetime` object (anything with proper strftime will do), or a string formatted as `%Y-%m-%d`.

class `fitbit.``Fitbit`(consumer_key, consumer_secret, system='en_US', **kwargs)
  `_COLLECTION_RESOURCE`(resource, date=None, user_id=None, data=None)

    Retrieving and logging of each type of collection data.

    Arguments:
      resource, defined automatically via curry [date] defaults to today [user_id] defaults to current logged in user [data] optional, include for creating a record, exclude for access

    This implements the following methods:

        body(date=None, user_id=None, data=None)
        activities(date=None, user_id=None, data=None)
        foods(date=None, user_id=None, data=None)
        water(date=None, user_id=None, data=None)
        sleep(date=None, user_id=None, data=None)
        heart(date=None, user_id=None, data=None)
        bp(date=None, user_id=None, data=None)

    - https://wiki.fitbit.com/display/API/Fitbit+Resource+Access+API
  `_DELETE_COLLECTION_RESOURCE`(resource, log_id)

    deleting each type of collection data

    Arguments:
      resource, defined automatically via curry log_id, required, log entry to delete

    This builds the following methods:

        delete_body(log_id)
        delete_activities(log_id)
        delete_foods(log_id)
        delete_water(log_id)
        delete_sleep(log_id)
        delete_heart(log_id)
        delete_bp(log_id)

  `_food_stats`(user_id=None, qualifier='')

    This builds the convenience methods on initialization:

        recent_foods(user_id=None, qualifier='')
        favorite_foods(user_id=None, qualifier='')
        frequent_foods(user_id=None, qualifier='')

    - https://wiki.fitbit.com/display/API/API-Get-Recent-Foods
    - https://wiki.fitbit.com/display/API/API-Get-Frequent-Foods
    - https://wiki.fitbit.com/display/API/API-Get-Favorite-Foods
  `accept_invite`(other_user_id)

    Convenience method for respond_to_invite

  `activities_list`()

    https://wiki.fitbit.com/display/API/API-Browse-Activities

  `activity_detail`(activity_id)

    https://wiki.fitbit.com/display/API/API-Get-Activity

  `activity_stats`(user_id=None, qualifier='')
    - https://wiki.fitbit.com/display/API/API-Get-Activity-Stats
    - https://wiki.fitbit.com/display/API/API-Get-Favorite-Activities
    - https://wiki.fitbit.com/display/API/API-Get-Recent-Activities
    - https://wiki.fitbit.com/display/API/API-Get-Frequent-Activities

    This implements the following methods:

        recent_activities(user_id=None, qualifier='')
        favorite_activities(user_id=None, qualifier='')
        frequent_activities(user_id=None, qualifier='')

  `add_favorite_activity`(activity_id)

    https://wiki.fitbit.com/display/API/API-Add-Favorite-Activity

  `add_favorite_food`(food_id)

    https://wiki.fitbit.com/display/API/API-Add-Favorite-Food

  `create_food`(data)

    https://wiki.fitbit.com/display/API/API-Create-Food

  `delete_favorite_activity`(activity_id)

    https://wiki.fitbit.com/display/API/API-Delete-Favorite-Activity

  `delete_favorite_food`(food_id)

    https://wiki.fitbit.com/display/API/API-Delete-Favorite-Food

  `food_detail`(food_id)

    https://wiki.fitbit.com/display/API/API-Get-Food

  `food_units`()

    https://wiki.fitbit.com/display/API/API-Get-Food-Units

  `get_badges`(user_id=None)

    https://wiki.fitbit.com/display/API/API-Get-Badges

  `get_devices`()

    https://wiki.fitbit.com/display/API/API-Get-Devices

  `get_friends`(user_id=None)

    https://wiki.fitbit.com/display/API/API-Get-Friends

  `get_friends_leaderboard`(period)

    https://wiki.fitbit.com/display/API/API-Get-Friends-Leaderboard

  `get_meals`()

    https://wiki.fitbit.com/display/API/API-Get-Meals

  `invite_friend`(data)

    https://wiki.fitbit.com/display/API/API-Create-Invite

  `invite_friend_by_email`(email)

    Convenience Method for https://wiki.fitbit.com/display/API/API-Create-Invite

  `invite_friend_by_userid`(user_id)

    Convenience Method for https://wiki.fitbit.com/display/API/API-Create-Invite

  `list_subscriptions`(collection='')

    https://wiki.fitbit.com/display/API/Fitbit+Subscriptions+API

  `reject_invite`(other_user_id)

    Convenience method for respond_to_invite

  `respond_to_invite`(other_user_id, accept=True)

    https://wiki.fitbit.com/display/API/API-Accept-Invite

  `search_foods`(query)

    https://wiki.fitbit.com/display/API/API-Search-Foods

  `subscription`(subscription_id, subscriber_id, collection=None, method='POST')

    https://wiki.fitbit.com/display/API/Fitbit+Subscriptions+API

  `time_series`(resource, user_id=None, base_date='today', period=None, end_date=None)

    The time series is a LOT of methods, (documented at url below) so they don’t get their own method. They all follow the same patterns, and return similar formats.

    Taking liberty, this assumes a base_date of today, the current user, and a 1d period.

    https://wiki.fitbit.com/display/API/API-Get-Time-Series

  `user_profile_get`(user_id=None)

    Get a user profile. You can get other user’s profile information by passing user_id, or you can get the current user’s by not passing a user_id

    https://wiki.fitbit.com/display/API/API-Get-User-Info

  `user_profile_update`(data)

    Set a user profile. You can set your user profile information by passing a dictionary of attributes that will be updated.

    https://wiki.fitbit.com/display/API/API-Update-User-Info

# Indices and tables

- Index
- Module Index
- Search Page

### Navigation

- index
- Python-Fitbit 0.0.2 documentation »