# Get Activity Timeseries Data
TIP
This guide assumes that your app has already been authorized and the snippet of code that I will show you can access to the Fitbit user id, here called userID
, the Fitbit OAuth 2.0 client ID, here called clientID
, and the Fitbit client secret, here called clientSecret
.
Information about the user's Activity Timeseries data can be obtained in three steps
# Step 1: Instanciate a manager
First, you need to instanciate a FitbitActivityTimeseriesDataManager
FitbitActivityTimeseriesDataManager fitbitActivityTimeseriesDataManager = FitbitActivityTimeseriesDataManager(
clientID: '<OAuth 2.0 Client ID>',
clientSecret: '<Client Secret>',
type: '<type>'
);
TIP
The <type>
field must be a valid string representing the type of Activity Timeseries data you need.
The possible values for <type>
are:
calories
caloriesBMR
steps
distance
floors
elevation
minutesSedentary
minutesLightlyActive
minutesFairlyActive
minutesVeryActive
activityCalories
# Step 2: Create the request url
Then, you have to create a url object, FitbitActivityTimeseriesAPIURL
, that fetches the specific Activty Timeseries data, specifying the same <type>
as above, during the desidered time range. For example:
FitbitActivityTimeseriesAPIURL fitbitActivityTimeseriesApiUrl = FitbitActivityTimeseriesAPIURL.dayWithResource(
date: DateTime.now(),
userID: userID,
resource: '<type>',
);
For the complete list of possible FitbitActivityTimeseriesAPIURL
, defined for different time ranges, please refer to the API Doc (opens new window).
# Step 3: Get the data
Finally you can obtain the Activty Timeseries data using
List<FitbitActivityTimeseriesData> fitbitActivityTimeseriesData = await fitbitActivityTimeseriesDataManager.fetch(fitbitActivityTimeseriesApiUrl);