Title: | Interface with the 'Fitbit' API |
---|---|
Description: | Many 'Fitbit' users, and R-friendly 'Fitbit' users especially, have found themselves curious about their 'Fitbit' data. 'Fitbit' aggregates a large amount of personal data, much of which is interesting for personal research and to satisfy curiosity, and is even potentially useful in medical settings. The goal of 'fitbitr' is to make interfacing with the 'Fitbit' API as streamlined as possible, to make it simple for R users of all backgrounds and comfort levels to analyze their 'Fitbit' data and do whatever they want with it! Currently, 'fitbitr' includes methods for pulling data on activity, sleep, and heart rate, but this list is likely to grow in the future as the package gains more traction and more requests for new methods to be implemented come in. You can find details on the 'Fitbit' API at <https://dev.fitbit.com/build/reference/web-api/>. |
Authors: | Matt Kaye [aut, cre] |
Maintainer: | Matt Kaye <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.0 |
Built: | 2024-10-16 12:43:51 UTC |
Source: | https://github.com/mrkaye97/fitbitr |
Performs the OAuth 2.0 dance to create a token to use with the Fitbit API.
generate_fitbitr_token( app_name = "fitbitr", client_id = Sys.getenv("FITBIT_CLIENT_ID"), client_secret = Sys.getenv("FITBIT_CLIENT_SECRET"), callback = Sys.getenv("FITBIT_CALLBACK", "https://localhost:1410/"), scope = c("activity", "cardio_fitness", "electrocardiogram", "heartrate", "location", "nutrition", "oxygen_saturation", "profile", "respiratory_rate", "settings", "sleep", "social", "temperature", "weight"), cache = TRUE, use_basic_auth = TRUE, ... )
generate_fitbitr_token( app_name = "fitbitr", client_id = Sys.getenv("FITBIT_CLIENT_ID"), client_secret = Sys.getenv("FITBIT_CLIENT_SECRET"), callback = Sys.getenv("FITBIT_CALLBACK", "https://localhost:1410/"), scope = c("activity", "cardio_fitness", "electrocardiogram", "heartrate", "location", "nutrition", "oxygen_saturation", "profile", "respiratory_rate", "settings", "sleep", "social", "temperature", "weight"), cache = TRUE, use_basic_auth = TRUE, ... )
app_name |
The name of your OAuth app. Default: |
client_id |
Your Fitbit client ID |
client_secret |
Your Fitbit client secret |
callback |
Your Fitbit redirect URL |
scope |
The scopes to enable |
cache |
Do you want to cache your token? See oauth2.0_token for details |
use_basic_auth |
A boolean for whether or not to use basic auth in oauth2.0_token. Defaults to |
... |
additional arguments to be passed to oauth2.0_token |
Saves a token as .fitbitr_token
which can then be used in the
background to authorize requests
Returns an OAuth 2.0 token (invisibly) that can be used to authorize requests to the Fitbit API. Also saves the token to .fitbitr_token
.
## Not run: generate_fitbitr_token( client_id = <YOUR-CLIENT-ID> client_secret = <YOUR-CLIENT-SECRET>, cache = TRUE ) ## End(Not run)
## Not run: generate_fitbitr_token( client_id = <YOUR-CLIENT-ID> client_secret = <YOUR-CLIENT-SECRET>, cache = TRUE ) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_active_zone_minutes_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_active_zone_minutes_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
Other intraday:
get_calories_intraday()
,
get_distance_intraday()
,
get_elevation_intraday()
,
get_floors_intraday()
,
get_heart_rate_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_active_zone_minutes_intraday(detail_level = "15min") ## get more granular data get_active_zone_minutes_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_active_zone_minutes_intraday(detail_level = "15min") ## get more granular data get_active_zone_minutes_intraday(detail_level = "1min") ## End(Not run)
Resource path /activities/activityCalories
get_activity_calories(start_date, end_date)
get_activity_calories(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and activity_calories
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_activity_calories(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_activity_calories(date) ## End(Not run)
See https://dev.fitbit.com/build/reference/web-api/activity/ for more details.
get_activity_summary(date)
get_activity_summary(date)
date |
The date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with the date
and a number of activity summary metrics for the day.
## Not run: date <- lubridate::today() get_activity_summary(date) ## End(Not run)
## Not run: date <- lubridate::today() get_activity_summary(date) ## End(Not run)
Resource path /activities/calories
get_calories(start_date, end_date)
get_calories(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and calories
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() calories(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() calories(date) ## End(Not run)
Resource path /activities/caloriesBMR
get_calories_bmr(start_date, end_date)
get_calories_bmr(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and calories_bmr
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_calories_bmr(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_calories_bmr(date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_calories_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_calories_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and calories
Other intraday:
get_active_zone_minutes_intraday()
,
get_distance_intraday()
,
get_elevation_intraday()
,
get_floors_intraday()
,
get_heart_rate_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_calories_intraday(detail_level = "15min") ## get more granular data get_calories_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_calories_intraday(detail_level = "15min") ## get more granular data get_calories_intraday(detail_level = "1min") ## End(Not run)
Resource path /activities/distance
get_distance(start_date, end_date)
get_distance(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and distance
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_distance(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_distance(date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_distance_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_distance_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and distance
Other intraday:
get_active_zone_minutes_intraday()
,
get_calories_intraday()
,
get_elevation_intraday()
,
get_floors_intraday()
,
get_heart_rate_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_distance_intraday(detail_level = "15min") ## get more granular data get_distance_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_distance_intraday(detail_level = "15min") ## get more granular data get_distance_intraday(detail_level = "1min") ## End(Not run)
Resource path /activities/elevation
get_elevation(start_date, end_date)
get_elevation(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and elevation
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_elevation(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_elevation(date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_elevation_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_elevation_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and elevation
Other intraday:
get_active_zone_minutes_intraday()
,
get_calories_intraday()
,
get_distance_intraday()
,
get_floors_intraday()
,
get_heart_rate_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_elevation_intraday(detail_level = "15min") ## get more granular data get_elevation_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_elevation_intraday(detail_level = "15min") ## get more granular data get_elevation_intraday(detail_level = "1min") ## End(Not run)
Resource path /activities/floors
get_floors(start_date, end_date)
get_floors(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and floors
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_floors(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_floors(date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_floors_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_floors_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and floors
Other intraday:
get_active_zone_minutes_intraday()
,
get_calories_intraday()
,
get_distance_intraday()
,
get_elevation_intraday()
,
get_heart_rate_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_floors_intraday(detail_level = "15min") ## get more granular data get_floors_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_floors_intraday(detail_level = "15min") ## get more granular data get_floors_intraday(detail_level = "1min") ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_heart_rate_intraday( date = lubridate::today(), detail_level = c("1sec", "1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_heart_rate_intraday( date = lubridate::today(), detail_level = c("1sec", "1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
Other intraday:
get_active_zone_minutes_intraday()
,
get_calories_intraday()
,
get_distance_intraday()
,
get_elevation_intraday()
,
get_floors_intraday()
,
get_steps_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_heart_rate_intraday(detail_level = "15min") ## get more granular data get_heart_rate_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_heart_rate_intraday(detail_level = "15min") ## get more granular data get_heart_rate_intraday(detail_level = "1min") ## End(Not run)
See https://dev.fitbit.com/build/reference/web-api/activity/ for more details.
get_heart_rate_zones(start_date, end_date = start_date)
get_heart_rate_zones(start_date, end_date = start_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble of the date, the heart rate zone (zone
), the minimum heart rate in that zone (min_hr
), the maximum heart rate in that zone (max_hr
), the minutes in that zone (minutes_in_zone
), and the calories burned in that zone (calories_out
)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_heart_rate_zones(start_date, end_date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_heart_rate_zones(start_date, end_date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_intraday_time_series( resource = c("active-zone-minutes", "calories", "distance", "elevation", "floors", "heart", "steps"), date, detail_level, start_time, end_time )
get_intraday_time_series( resource = c("active-zone-minutes", "calories", "distance", "elevation", "floors", "heart", "steps"), date, detail_level, start_time, end_time )
resource |
The resource to get |
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and {{resource}}
Retrieve lifetime best distance, floors, and steps
get_lifetime_bests()
get_lifetime_bests()
A tibble the best distance
, floors
, and steps
(by date) tracked on any of your trackers
## Not run: get_lifetime_bests() ## End(Not run)
## Not run: get_lifetime_bests() ## End(Not run)
Retrieve lifetime total distance, floors, and steps
get_lifetime_totals()
get_lifetime_totals()
A tibble of all-time totals across trackers (i.e. the total distance
, floors
, and steps
tracked across all of your trackers)
## Not run: get_lifetime_totals() ## End(Not run)
## Not run: get_lifetime_totals() ## End(Not run)
Resource path /activities/minutesFairlyActive
get_minutes_fairly_active(start_date, end_date)
get_minutes_fairly_active(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and minutes_fairly_active
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_fairly_active(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_fairly_active(date) ## End(Not run)
Resource path /activities/minutesLightlyActive
get_minutes_lightly_active(start_date, end_date)
get_minutes_lightly_active(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and minutes_lightly_active
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_lightly_active(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_lightly_active(date) ## End(Not run)
Resource path /activities/minutesSedentary
get_minutes_sedentary(start_date, end_date)
get_minutes_sedentary(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and minutes_sedentary
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_sedentary(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_sedentary(date) ## End(Not run)
Resource path /activities/minutesVeryActive
get_minutes_very_active(start_date, end_date)
get_minutes_very_active(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and minutes_very_active
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_very_active(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_minutes_very_active(date) ## End(Not run)
Returns a tibble of nightly sleep stage data. Very granular. Returns blocks of time spent in each phase.
get_sleep_stage_granular(start_date, end_date = start_date)
get_sleep_stage_granular(start_date, end_date = start_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble of granular sleep stage data. This method is more granular than get_sleep_stage_summary, and returns blocks of time that you spent in each zone throughout the night.
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_stage_granular(start_date, end_date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_stage_granular(start_date, end_date) ## End(Not run)
Returns a tibble of nightly sleep stage data. Minutes in each stage, count of times in each stage, and a thirty day average for the number of minutes in each stage.
get_sleep_stage_summary(start_date, end_date = start_date)
get_sleep_stage_summary(start_date, end_date = start_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble of a variety of sleep stage summary data, by day
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_stage_summary(start_date, end_date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_stage_summary(start_date, end_date) ## End(Not run)
Returns a tibble of summary by night
get_sleep_summary(start_date, end_date = start_date)
get_sleep_summary(start_date, end_date = start_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble of a variety of sleep summary data by day
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_summary(start_date, end_date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_sleep_summary(start_date, end_date) ## End(Not run)
Resource path /activities/steps
get_steps(start_date, end_date)
get_steps(start_date, end_date)
start_date |
The start date of records to be returned in "yyyy-mm-dd" or date(time) format |
end_date |
The end date of records to be returned in "yyyy-mm-dd" or date(time) format |
A tibble with two columns: date
and steps
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_steps(date) ## End(Not run)
## Not run: start_date <- lubridate::today() - lubridate::weeks(1) end_date <- lubridate::today() get_steps(date) ## End(Not run)
See the API documentation for more detailed explanations of parameters and more usage information and examples.
get_steps_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
get_steps_intraday( date = lubridate::today(), detail_level = c("1min", "5min", "15min"), start_time = NULL, end_time = NULL )
date |
A date to get data for |
detail_level |
The detail level. One of |
start_time |
The start time of the time window. Default: |
end_time |
The end time of the time window. Default: |
A tibble with two columns: time
and steps
Other intraday:
get_active_zone_minutes_intraday()
,
get_calories_intraday()
,
get_distance_intraday()
,
get_elevation_intraday()
,
get_floors_intraday()
,
get_heart_rate_intraday()
## Not run: date <- lubridate::today() ## get minute by minute data get_steps_intraday(detail_level = "15min") ## get more granular data get_steps_intraday(detail_level = "1min") ## End(Not run)
## Not run: date <- lubridate::today() ## get minute by minute data get_steps_intraday(detail_level = "15min") ## get more granular data get_steps_intraday(detail_level = "1min") ## End(Not run)
Retrieve tracker best distance, floors, and steps
get_tracker_bests()
get_tracker_bests()
A tibble the best distance
, floors
, and steps
(by date) tracked on your tracker
## Not run: get_tracker_bests() ## End(Not run)
## Not run: get_tracker_bests() ## End(Not run)
Retrieve tracker total distance, floors, and steps
get_tracker_totals()
get_tracker_totals()
A tibble of all-time tracker totals (i.e. the total distance
, floors
, and steps
tracked by your tracker)
## Not run: get_tracker_totals() ## End(Not run)
## Not run: get_tracker_totals() ## End(Not run)
Perform a GET request
perform_get(url, ...)
perform_get(url, ...)
url |
The URL to make the request to |
... |
Additional arguments (not currently used) |
The response