Currently a work in progress and not associated with Peloton.
A node client for making requests to the Peloton API.
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,
});
}
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
Authenticates the session. Must be called before any other methods are called.
options
- options objectusername
- the username or email of the authenticating Peloton account (required)password
- the password of the authenticating Peloton account (required)
await peloton.authenticate({
username: 'your-peloton-username-or-email',
password: 'your-peloton-password',
});
Gets the authenticated users information.
Must have called peloton.authenticate
before this method can be used.
await peloton.me();
Gets the details of the specified user or yourself if none is specified.
options
- options objectuserId
- the ID of the user to fetch information of (default: authenticated userId)
const userInfo = await peloton.user({ userId: 'some-user-id' });
Get the followers of the authenticated user or a specified user.
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
)
const followers = await peloton.followers({
userId: 'some-peloton-user-id',
limit: 100,
page: 0,
});
Get the users following the authenticated user or a specified user.
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
)
const following = await peloton.following({
userId: 'some-peloton-user-id',
limit: 100,
page: 0,
});
Gets the workouts of the authenticated user or a specified user.
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'
)
const workoutsRes = await peloton.workouts({
limit: 100,
page: 0,
joins: 'ride',
});
Get the details of a specified workout
options
- options objectworkoutId
- the ID of the workout to retrieve (required)
const workoutRes = await peloton.workout({ workoutId: 'some-workout-id' });
Get the data used to build a performance graph for a specific workout.
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
)
const workoutPerformanceGraphRes = await peloton.workoutPerformanceGraph({
workoutId: 'some-workout-id',
everyN: 30,
});
Get inforamtion about a specific ride.
options
- options objectrideId
- the ID of the ride to retrieve the information for (required)
const rideRes = await peloton.ride({ rideId: 'some-ride-id' });
Get details about a specific ride.
options
- options objectrideId
- the ID of the ride to retrieve the information for (required)
const rideDetailsRes = await peloton.rideDetails({ rideId: 'some-ride-id' });
This was inspred from this python library as well as the API Docs written there.