# Get SpO2 Intraday Data
WARNING
To fetch Intraday data, your app must be registered as Personal or must obtain a specifc grant by Fitbit, otherwise you will get an error. For additional information see https://dev.fitbit.com/build/reference/web-api/intraday/ (opens new window).
WARNING
As specified by Fitbit's Web API SpO2 data cannot be retrieved for more than a 24 hour period. Any requests that expand over a 24 hour period will result in an error.
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
.
SpO2 data (opens new window) contain details about a user's SpO2 data. In Fitbitter, a datapoint is expressed by the FitbitSpO2IntradayData
model.
In particular, an instance of FitbitSpO2IntradayData
has the following fields:
/// The user encoded id.
String? userID;
/// The date of monitoring of the data.
DateTime? dateOfMonitoring;
/// The average value of the data.
double? value;
An example is:
FitbitSpO2IntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 04:02:17.000, value: 95.7,)
FitbitSpO2IntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 004:03:17.000, value: 99.5,)
FitbitSpO2IntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 04:04:17.000, value: 99.0,)
Information about the user's SpO2 data can be obtained in three steps:
# Step 1: Instanciate a manager
First, you need to instanciate a FitbitSpO2IntradayDataManager
FitbitSpO2IntradayDataManager fitbitSpO2IntradayDataManager = FitbitSpO2IntradayDataManager(
clientID: '<OAuth 2.0 Client ID>',
clientSecret: '<Client Secret>',
);
# Step 2: Create the request url
Then, you have to create a url object, FitbitSpO2IntradayAPIURL
to fetch the SpO2 data as:
FitbitSpO2IntradayAPIURL fitbitSpO2IntradayAPIURL = FitbitSpO2IntradayAPIURL.dayAndDetailLevel(
date: DateTime.now(),
fitbitCredentials: fitbitCredentials,
intradayDetailLevel: intradayDetailLevel,
);
where date
is the day you want to fetch FitbitSpO2IntradayData
from, fitbitCredentials
is the FitbitCredentials
instance obtained during the authentication step, and intradayDetailLevel
is an instance of IntradayDetailLevel
enumerator that defines the desired data granularity (Supported: IntradayDetailLevel.ONE_SECOND
, IntradayDetailLevel.ONE_MINUTE
, IntradayDetailLevel.FIVE_MINUTES
, and IntradayDetailLevel.FIFTEEN_MINUTES
) .
TIP
For the complete list of possible FitbitSpO2IntradayAPIURL
, defined for different time ranges, please refer to the API Doc (opens new window).
# Step 3: Get the data
Finally you can obtain the SpO2 data using
List<FitbitSpO2IntradayData> fitbitSpO2IntradayData = await FitbitSpO2IntradayDataManager.fetch(fitbitSpO2IntradayAPIURL);