### Install Runtime Requirements Source: https://github.com/orcasgit/python-fitbit/blob/master/README.rst Installs the necessary packages to run the python-fitbit library. ```bash sudo pip install -r requirements/base.txt ``` -------------------------------- ### Fitbit Unauthorized Client Example Source: https://github.com/orcasgit/python-fitbit/blob/master/docs/index.rst Demonstrates how to initialize and use the Fitbit client for operations that do not require user authorization. This includes making calls to endpoints like `food_units()`. ```python import fitbit unauth_client = fitbit.Fitbit('', '') # certain methods do not require user keys unauth_client.food_units() ``` -------------------------------- ### Install Test Requirements Source: https://github.com/orcasgit/python-fitbit/blob/master/README.rst Installs packages needed for running tests on a continuous integration server. ```bash sudo pip install -r requirements/test.txt ``` -------------------------------- ### Install Developer Requirements Source: https://github.com/orcasgit/python-fitbit/blob/master/README.rst Installs packages required for modifying and testing the library, including documentation and testing tools. ```bash sudo pip install -r requirements/dev.txt ``` -------------------------------- ### Fitbit OAuth 2.0 Authorized Client Example Source: https://github.com/orcasgit/python-fitbit/blob/master/docs/index.rst Shows how to set up an authorized Fitbit client using OAuth 2.0 credentials, including access and refresh tokens. This allows access to user-specific data and actions, such as retrieving sleep data. ```python # You'll have to gather the tokens on your own, or use # ./gather_keys_oauth2.py authd_client = fitbit.Fitbit('', '', access_token='', refresh_token='') authd_client.sleep() ``` -------------------------------- ### Fitbit API Documentation Source: https://github.com/orcasgit/python-fitbit/blob/master/docs/index.rst This section provides comprehensive documentation for the Fitbit API, detailing various methods for data retrieval and management. It includes information on parameters, return values, and links to the official Fitbit developer documentation for each endpoint. The methods cover body data, activities, food logging, sleep tracking, and heart rate monitoring, as well as functionalities to delete logged entries and retrieve recent, frequent, and favorite activities/foods. ```APIDOC Fitbit Class Methods: body(date=None, user_id=None, data=None) Get body data: https://dev.fitbit.com/docs/body/ Parameters: date: The date for which to retrieve body data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Body data for the specified date. activities(date=None, user_id=None, data=None) Get body data: https://dev.fitbit.com/docs/activity/ Parameters: date: The date for which to retrieve activity data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Activity data for the specified date. foods_log(date=None, user_id=None, data=None) Get food logs data: https://dev.fitbit.com/docs/food-logging/#get-food-logs Parameters: date: The date for which to retrieve food log data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Food log data for the specified date. foods_log_water(date=None, user_id=None, data=None) Get water logs data: https://dev.fitbit.com/docs/food-logging/#get-water-logs Parameters: date: The date for which to retrieve water log data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Water log data for the specified date. sleep(date=None, user_id=None, data=None) Get sleep data: https://dev.fitbit.com/docs/sleep/ Parameters: date: The date for which to retrieve sleep data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Sleep data for the specified date. heart(date=None, user_id=None, data=None) Get heart rate data: https://dev.fitbit.com/docs/heart-rate/ Parameters: date: The date for which to retrieve heart rate data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Heart rate data for the specified date. bp(date=None, user_id=None, data=None) Get blood pressure data: https://dev.fitbit.com/docs/heart-rate/ Parameters: date: The date for which to retrieve blood pressure data. Accepts None, date/datetime object, or a string formatted as '%Y-%m-%d'. Defaults to the current user's data. user_id: The ID of the user. Defaults to the current user from credentials. data: Additional data payload (if any). Returns: Blood pressure data for the specified date. delete_body(log_id) Delete a body log, given a log id. Parameters: log_id: The ID of the body log to delete. Returns: Confirmation of deletion. delete_activities(log_id) Delete an activity log, given a log id. Parameters: log_id: The ID of the activity log to delete. Returns: Confirmation of deletion. delete_foods_log(log_id) Delete a food log, given a log id. Parameters: log_id: The ID of the food log to delete. Returns: Confirmation of deletion. delete_foods_log_water(log_id) Delete a water log, given a log id. Parameters: log_id: The ID of the water log to delete. Returns: Confirmation of deletion. delete_sleep(log_id) Delete a sleep log, given a log id. Parameters: log_id: The ID of the sleep log to delete. Returns: Confirmation of deletion. delete_heart(log_id) Delete a heart log, given a log id. Parameters: log_id: The ID of the heart log to delete. Returns: Confirmation of deletion. delete_bp(log_id) Delete a blood pressure log, given a log id. Parameters: log_id: The ID of the blood pressure log to delete. Returns: Confirmation of deletion. recent_foods(user_id=None, qualifier='') Get recently logged foods: https://dev.fitbit.com/docs/food-logging/#get-recent-foods Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering recent foods. Returns: A list of recently logged foods. frequent_foods(user_id=None, qualifier='') Get frequently logged foods: https://dev.fitbit.com/docs/food-logging/#get-frequent-foods Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering frequent foods. Returns: A list of frequently logged foods. favorite_foods(user_id=None, qualifier='') Get favorited foods: https://dev.fitbit.com/docs/food-logging/#get-favorite-foods Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering favorite foods. Returns: A list of favorited foods. recent_activities(user_id=None, qualifier='') Get recently logged activities: https://dev.fitbit.com/docs/activity/#get-recent-activity-types Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering recent activities. Returns: A list of recently logged activities. frequent_activities(user_id=None, qualifier='') Get frequently logged activities: https://dev.fitbit.com/docs/activity/#get-frequent-activities Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering frequent activities. Returns: A list of frequently logged activities. favorite_activities(user_id=None, qualifier='') Get favorited foods: https://dev.fitbit.com/docs/activity/#get-favorite-activities Parameters: user_id: The ID of the user. Defaults to the current user from credentials. qualifier: Optional qualifier for filtering favorite activities. Returns: A list of favorited activities. ``` -------------------------------- ### Base Project Requirements Source: https://github.com/orcasgit/python-fitbit/blob/master/requirements/dev.txt Specifies the core dependencies required for the python-fitbit project to function. Includes version constraints for cherrypy. ```python cherrypy>=3.7,<3.9 ``` -------------------------------- ### Test Project Requirements Source: https://github.com/orcasgit/python-fitbit/blob/master/requirements/dev.txt Specifies the additional dependencies required for testing the python-fitbit project. Includes version constraints for tox. ```python tox>=1.8,<2.2 ``` -------------------------------- ### Fitbit API - OAuth Refresh and Error Handling Source: https://github.com/orcasgit/python-fitbit/blob/master/CHANGELOG.rst This section details improvements in handling OAuth token refreshes and surfacing errors in the Fitbit API client. It includes automatic token refreshing using requests-oauthlib and better error reporting mechanisms. ```APIDOC Fitbit API Client Enhancements: OAuth Token Refresh: - Automatically refresh tokens using requests-oauthlib's auto-refresh feature. - Call a hook if it exists when tokens are refreshed. - Refresh token when it expires. - Fixes for token refresh bugs. - Update requirements to use requests-oauthlib>=0.6.1. Error Handling: - Surface errors better. - Add HTTPTooManyRequests exception with retry_after_secs information. - Include error messages in the exception. - Quick fix for response objects without a status code. API Changes: - Drop OAuth1 support. See `OAuth1 deprecated `_. - Clean up OAuth workflow, change the API slightly to match oauthlib terminology. New APIs and Features: - Support Intraday Time Series API. - Use connection pooling to avoid a TCP and SSL handshake for every API call. - Add get_bodyweight and get_bodyfat methods. - Add get_badges method. - Add API for alarms. - Add API for log activity. - Enable adding parameters to authorize token URL. General Improvements: - Fix the broken foods log date endpoint. - Integrate with travis-ci.org, coveralls.io, and requires.io. - Officially test/support Python 3.2+ and PyPy in addition to Python 2.x. - Switch from python-oauth2 to the better supported oauthlib. - Correctly pass headers on requests. - Way more test coverage. - Add docs, including Readthedocs support. - Add tests. - Use official oauth2 version from pypi. - Initial release. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.