# Get Heart 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 Heart data can be obtained in three steps

# Step 1: Instanciate a manager

First, you need to instanciate a FitbitHeartDataManager

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

# Step 2: Create the request url

Then, you have to create a url object, FitbitHeartAPIURL, that fetches the Heart data, during the desidered time range. For example:

    FitbitHeartAPIURL fitbitHeartApiUrl = FitbitHeartAPIURL.dayWithUserID(
                                    date: DateTime.now(),
                                    userID: userID,
                                  );

For the complete list of possible FitbitHeartAPIURL, 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 data using

    List<FitbitHeartData> fitbitHeartData = await fitbitHeartDataManager.fetch(fitbitHeartApiUrl);