# Get Cardio Fitness Score (VO2Max) 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.

Cardio Score data (opens new window) contain details about a user's cardio fitness score (VO2Max). In Fitbitter, a datapoint is expressed by the FitbitCardioScoreData model. In particular, an instance of FitbitCardioScoreData 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:

FitbitCardioScoreData(userID: 7ML2XV, value: 53.0, dateOfMonitoring: 2022-05-08 00:00:00.000, )

Information about the user's Cardio Score data can be obtained in three steps:

# Step 1: Instanciate a manager

First, you need to instanciate a FitbitCardioScoreDataManager

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

# Step 2: Create the request url

Then, you have to create a url object, FitbitCardioScoreAPIURL to fetch the Cardio Score data as:

    FitbitCardioScoreAPIURL fitbitCardioScoreAPIURL = FitbitCardioScoreAPIURL.day(
                                    date: DateTime.now(),
                                    fitbitCredentials: fitbitCredentials,
                                  );

where date is the day you want to fetch FitbitCardioScoreData from and fitbitCredentials is the FitbitCredentials instance obtained during the authentication step.

TIP

For the complete list of possible FitbitCardioScoreAPIURL, defined for different time ranges, please refer to the API Doc (opens new window).

# Step 3: Get the data

Finally you can obtain the Cardio Score data using

    List<FitbitCardioScoreData> fitbitCardioScoreData = await fitbitCardioScoreDataManager.fetch(fitbitCardioScoreAPIURL);