# Get Breathing Rate 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 a valid FitbitCredentials
instance, here called fitbitCredentials
, the Fitbit OAuth 2.0 client ID, here called clientID
, and the Fitbit client secret, here called clientSecret
.
Breathing Rate data (opens new window) contain details about a user's breathing rate. In Fitbitter, a datapoint is expressed by the FitbitBreathingRateData
model.
In particular, an instance of FitbitBreathingRateData
has the following fields:
/// The user encoded id.
String? userID;
/// The start date of the activity.
DateTime? dateOfMonitoring;
/// The value of the data
double? value;
An example is:
FitbitBreathingRateData(userID: 7ML2XV, value: 13.2, dateOfMonitoring: 2022-05-08 00:00:00.000, )
Information about the user's Breathing Rate data can be obtained in three steps:
# Step 1: Instanciate a manager
First, you need to instanciate a FitbitBreathingRateDataManager
FitbitBreathingRateDataManager fitbitBreathingRateDataManager = FitbitBreathingRateDataManager(
clientID: '<OAuth 2.0 Client ID>',
clientSecret: '<Client Secret>',
);
# Step 2: Create the request url
Then, you have to create a url object, FitbitBreathingRateAPIURL
to fetch the Breathing Rate data as:
FitbitBreathingRateAPIURL fitbitBreathingRateAPIURL = FitbitBreathingRateAPIURL.day(
date: DateTime.now(),
fitbitCredentials: fitbitCredentials,
);
where date
is the day you want to fetch FitbitBreathingRateData
from and fitbitCredentials
is the FitbitCredentials
instance obtained during the authentication step.
TIP
For the complete list of possible FitbitBreathingRateAPIURL
, defined for different time ranges, please refer to the API Doc (opens new window).
# Step 3: Get the data
Finally you can obtain the Breathing Rate data using
List<FitbitBreathingRateData> fitbitBreathingRateData = await fitbitBreathingRateDataManager.fetch(fitbitBreathingRateAPIURL);