peloton-client-node v0.4.0
peloton-client-node
Currently a work in progress and not associated with Peloton.
A node client for making requests to the Peloton API.
Usage
const { peloton } = require('peloton-client-node');
async function example() {
await peloton.authenticate({
username: 'your-peloton-username-or-email',
password: 'your-peloton-password',
});
// Get your own personal information
const myInfo = await peloton.me();
// Get your workout info
const myLast10Workouts = await peloton.workouts({
limit: 10,
page: 0,
});
}Documenation
peloton.authenticate(options)- authenticate the sessionpeloton.me()- get authenticated user infopeloton.user(options)- get user info for specific userpeloton.followers(options)- the get followers of a specified userpeloton.following(options)- the get users following of a specified userpeloton.workouts(options)- get workouts of authetnicated userpeloton.workout(options)- get details of a specific workoutpeloton.workoutPerformanceGraph(options)- get the data used to build a performance graph of a specific workoutpeloton.ride(options)- get information about a specific ridepeloton.rideDetails(options)- get details about a specific ride
peloton.authenticate(options)
Description
Authenticates the session. Must be called before any other methods are called.
Arguments
options- options objectusername- the username or email of the authenticating Peloton account (required)password- the password of the authenticating Peloton account (required)
Usage
await peloton.authenticate({
username: 'your-peloton-username-or-email',
password: 'your-peloton-password',
});peloton.me()
Description
Gets the authenticated users information.
Must have called peloton.authenticate before this method can be used.
Usage
await peloton.me();peloton.user(options)
Description
Gets the details of the specified user or yourself if none is specified.
Arguments
options- options objectuserId- the ID of the user to fetch information of (default: authenticated userId)
Usage
const userInfo = await peloton.user({ userId: 'some-user-id' });peloton.followers(options)
Description
Get the followers of the authenticated user or a specified user.
Arguments
options- options objectuserId- specify the user to retrieve the followers of (default: authenticated userId)limit- limit the number of workouts returned (default:10)page- the page of the results to fetch (default:0)
Usage
const followers = await peloton.followers({
userId: 'some-peloton-user-id',
limit: 100,
page: 0,
});peloton.following(options)
Description
Get the users following the authenticated user or a specified user.
Arguments
options- options objectuserId- specify the user to retrieve those who are following (default: authenticated userId)limit- limit the number of workouts returned (default:10)page- the page of the results to fetch (default:0)
Usage
const following = await peloton.following({
userId: 'some-peloton-user-id',
limit: 100,
page: 0,
});peloton.workouts(options)
Description
Gets the workouts of the authenticated user or a specified user.
Arguments
options- options objectuserId- specify the user to retrieve the workouts of (default: authenticated userId)limit- limit the number of workouts returned (default:10)page- the page of the results to fetch (default:0)joins- UNSURE: some sort of join key. I believe it may expand the keys provided (default:'ride')
Usage
const workoutsRes = await peloton.workouts({
limit: 100,
page: 0,
joins: 'ride',
});peloton.workout(options)
Description
Get the details of a specified workout
Arguments
options- options objectworkoutId- the ID of the workout to retrieve (required)
Usage
const workoutRes = await peloton.workout({ workoutId: 'some-workout-id' });peloton.workoutPerformanceGraph(options)
Description
Get the data used to build a performance graph for a specific workout.
Arguments
options- options objectworkoutId- the ID of the workout to retrieve the graph data for (required)everyN- an integer value defining the granularity of data received, in seconds (default:5)
Usage
const workoutPerformanceGraphRes = await peloton.workoutPerformanceGraph({
workoutId: 'some-workout-id',
everyN: 30,
});peloton.ride(options)
Description
Get inforamtion about a specific ride.
Arguments
options- options objectrideId- the ID of the ride to retrieve the information for (required)
Usage
const rideRes = await peloton.ride({ rideId: 'some-ride-id' });peloton.rideDetails(options)
Description
Get details about a specific ride.
Arguments
options- options objectrideId- the ID of the ride to retrieve the information for (required)
Usage
const rideDetailsRes = await peloton.rideDetails({ rideId: 'some-ride-id' });References
This was inspred from this python library as well as the API Docs written there.