# Get Heart Rate 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 Heart Rate Intraday 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.

Heart Rate Intraday data (opens new window) contain details about a user's Heart Rate Intraday data. In Fitbitter, a datapoint is expressed by the FitbitHeartRateIntradayData model. Fitbitter fetches a simplified version of Heart Rate Intraday data (opens new window) as described by Fitbit. In particular, an instance of FitbitHeartRateIntradayData has the following fields:

  /// The user encoded id.
  String? userID;

  /// The date of monitoring of the data.
  DateTime? dateOfMonitoring;

  /// The value of the data.
  double? value;

An example is:

FitbitHeartRateIntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 00:02:00.000, value: 50,)
FitbitHeartRateIntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 00:02:15.000, value: 52,)
FitbitHeartRateIntradayData(userID: 7ML2XV, dateOfMonitoring: 2022-05-08 00:02:30.000, value: 51,)

Information about the user's Heart Rate Intraday data can be obtained in three steps:

# Step 1: Instanciate a manager

First, you need to instanciate a FitbitHeartRateIntradayDataManager

    FitbitHeartRateIntradayDataManager fitbitHeartRateIntradayDataManager = FitbitHeartRateIntradayDataManager(
        clientID: '<OAuth 2.0 Client ID>',
        clientSecret: '<Client Secret>',
    );

# Step 2: Create the request url

Then, you have to create a url object, FitbitHeartRateIntradayAPIURL to fetch the Heart Rate Intraday data as:

    FitbitHeartRateIntradayAPIURL fitbitHeartRateIntradayAPIURL = FitbitHeartRateIntradayAPIURL.dayAndDetailLevel(
                                    date: DateTime.now(),
                                    fitbitCredentials: fitbitCredentials,
                                    intradayDetailLevel: intradayDetailLevel,
                                  );

where date is the day you want to fetch FitbitHeartRateIntradayData 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 FitbitHeartRateIntradayAPIURL, defined for different time ranges, please refer to the API Doc (opens new window).

# Step 3: Get the data

Finally you can obtain the Heart Rate Intraday data using

    List<FitbitHeartRateIntradayData> fitbitHeartRateIntradayData = await fitbitHeartRateIntradayDataManager.fetch(fitbitHeartRateIntradayAPIURL);