Skip to content

mcdan/peloton-client-node

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Description

Authenticates the session. Must be called before any other methods are called.

Arguments

  • options - options object
    • username - 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 object
    • userId - 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 object
    • userId - 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 object
    • userId - 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 object
    • userId - 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 object
    • workoutId - 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 object
    • workoutId - 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 object
    • rideId - 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 object
    • rideId - 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.

About

Node client library for the Peloton API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.5%