About the Package

The pelotonR package was created to provide users with simple access to the Peloton API through R.

The Peloton APIs are unsupported. However, there are some really great unofficial swagger docs which I used to familiarize myself with the API.


The package offers a set of easy to use functions which allow the user to:

Load the Libraries

Before we start exploring the pelotonR package, we will load a few libraries used to help explore and display the data.

#Uncomment the line below if you also need to install pelotonR
# devtools::install_github("lgellis/pelotonR")
library("pelotonR")
#Packages for nice output display
library(DT) # For table display
library(Hmisc) # For list display
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(tidyverse) # For data munging
## ── Attaching packages ──────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.0.1     ✓ dplyr   1.0.0
## ✓ tidyr   1.1.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ✓ purrr   0.3.4
## ── Conflicts ─────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter()    masks stats::filter()
## x dplyr::lag()       masks stats::lag()
## x dplyr::src()       masks Hmisc::src()
## x dplyr::summarize() masks Hmisc::summarize()
library(lubridate) # For dates
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(gameofthrones) # For colors

Unauthenticated API Calls

The following functions are available without authentication.

Get Peloton Metadata Mappings Data Frame

The function get_metadata_mapping_df(type) allows us to see all metadata mapping for a particular category of Peloton metadata. Available options for type include: ‘instructors’, ‘class_types’, ‘equipment’, ‘fitness_disciplines’, device_type_display_names’, ‘content_focus_labels’, ‘difficulty_levels’, ‘locales’

To learn about the function, execute the command ?get_metadata_mapping_df

class_types <- get_metadata_mapping_df('class_types')

#Nicely display data
datatable(class_types, extensions = "Scroller", width = 1000, options = list(scrollY = 400, scroller = TRUE, scrollX = 600, pageLength = 5))

Get Peloton Live Rides Data Frame

The function get_live_rides_df returns a data frame with all of the currently available live rides.

To learn about the function, execute the command ?get_live_rides_df

live_rides <- get_live_rides_df()

#Nicely display data
datatable(live_rides, extensions = "Scroller", width = 1000, options = list(scrollY = 400, scroller = TRUE, scrollX = 600, pageLength = 5))

Get Full Set of Ride Information In a List

The function get_ride_info_list allows us to gather the full list of information for a particular ride.

To learn about the function, execute code ?get_ride_info_list

ride_info <- get_ride_info_list('55214456a1984c5885a087021e3f67b7')

#Nicely display data
list.tree(ride_info)
##  ride_info = list 60 (20624 bytes)
## .  class_type_ids = character 1= 7579b9edbdf9464fa19eb5 
## .  content_provider = character 1= peloton 
## .  content_format = character 1= video 
## .  description = character 1= Efficient and effectiv 
## .  difficulty_estimate = double 1= 8.0285
## .  overall_estimate = double 1= 0.9955
## .  difficulty_rating_avg = double 1= 8.0285
## .  difficulty_rating_count = integer 1= 26062
## .  difficulty_level = NULL 0
## .  duration = integer 1= 900
## .  equipment_ids = list 0
## .  equipment_tags = list 0
## .  ...   and 48 more

Get Peloton Ride Data Frame

The function get_ride_info_df allows us to gather the basic ride information for a particular ride into a data frame.

To learn about the function, execute the command `?get_ride_info_df

ride_info <- get_basic_ride_info_df('55214456a1984c5885a087021e3f67b7')

#Nicely display data
datatable(ride_info, extensions = "Scroller", width = 1000, options = list(scrollY = 75, scroller = TRUE, scrollX = 600, pageLength = 5))

Get Peloton Instructors Data Frame

The function get_instructors_df returns a data frame with all instructors and their information.

To learn about the function, execute the command ?get_instructors_df`

instructors <- get_instructors_df()

#Nicely display data
datatable(instructors, extensions = "Scroller", width = 1000, options = list(scrollY = 400, scroller = TRUE, scrollX = 600, pageLength = 5))

Get Live Rides and Details

The function get_live_ride_and_details_df returns a data frame with all current live rides as well as the joined ride and instructor data for each ride.

To learn about the function, execute the command ?get_live_ride_and_details_df

live_with_details <- get_live_ride_and_details_df() 

#Nicely display data
datatable(live_with_details, extensions = "Scroller", width = 1000, options = list(scrollY = 400, scroller = TRUE, scrollX = 600, pageLength = 5))