Skip to main content
Question

API answer changed: average_heartrate and max_heartrate are missing (amongst others)

  • April 4, 2025
  • 1 reply
  • 13 views

Forum|alt.badge.img+1

I use an R script to retrieve my personal activity data from Strava using the API. I use the following code, that, in the past, always gave me data on average and max heart rates, but now these have disappeared for some reason:
 

while (TRUE) {
  req <- httr::GET(
    url = "https://www.strava.com/api/v3/athlete/activities",
    config = token,
    query = list(per_page = 200, page = page)
  )

  # Convert JSON to dataframe
  activity_data <- fromJSON(content(req, as = "text"), flatten = TRUE)

  # Stop if no data found
  if (length(activity_data) == 0) {break}

  # Append data to dataframe
  if (nrow(df) == 0) {df <- activity_data} else {
    common_cols <- intersect(names(df), names(activity_data))
    df <- rbind(df[, common_cols, drop = FALSE], activity_data[, common_cols, drop = FALSE])}

  # Turn to next page
  page <- page + 1
}

Anyone has an idea why the heart rate data is missing?

Forum|alt.badge.img+1

I’ve solved it myself. For some reason the “common_cols” approach I was using, removed these attributes from the activity_data. I replaced those lines of code with:

df <- bind_rows(df, activity_data)

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept, you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings