Skip to main content

Peloton Client Library

Hello Peloton! I wanted to thank you for being sane people and utilizing an API to move data around, at the very least, from within your web app (I have no idea how you do it on the bike etc).

I wrote (see: am writing) this library for a couple reasons, not the least of which is to be able to mess around with my workout data, and eventually attempt to build (my first practical idea) an algorithm that predicts target resistance to match an instructors cadence/output requirement. For funsies.

I've tried to be as reasonable as I can in developing this client lib - I lazy load as much data as possible to limit API calls, and if you look in your logs, you'll see a header that clearly indicates that this library is making API calls (look for peloton-client-library/ in your logs). I have also tried to mimic the paging/granularity that's made by your web UI (going under the assumption that your backend is optimsed for those calls) - the last thing I want to do is piss you off! <3

If you have any questions or concerns, please, ping me (I'm not hard to find).

API Documentation

This all started out of a curiosity when I looked at a ride details page. I threw open dev tools and .. boom, you've got an actual web app that's making API calls to drive the UI. A+, friends.

As I've been poking around in your WebUI, I've essentially been looking at the API calls that are made. I've been keeping notes on all of this here.

Using the Client Library

Utilizing the library is pretty simple. A super quick example is below, with more thorough documentation to follow as I find time (this is a side/pet project after all).

Configuration

The library requires a configuration file, whos path is either pulled from the environment variale PELOTON_CONFIG, or looked for in the hard-coded ~/.config/peloton (which can be a symlink to a unified config if you have many). The only config block that the library looks for is shown below.

[peloton]
username = Your_Peloton_Username_Or_Email
password = Your_Peloton_Password

# Optional: Whether or not to ignore warnings that are thrown (default: True)
ignore_warnings = True

# Optional: Verify SSL Authenticity (default: True)
ssl_verify = True

# Optional: Filepath to a local cert bundle. Useful when SSL MITM is in play (default: None)
ssl_cert = ''

You may also specify the environment variables PELOTON_USERNAME and PELOTON_PASSWORD which will take precedence over the config file.

Example Usage

>>> from peloton import PelotonWorkout
>>> workouts = PelotonWorkout.list()
>>> workout = workouts[0]

>>> dir(workout)
['_get_metrics', 'achievements', 'created', 'created_at', 'end_time', 'fitness_discipline', 'get', 'id', 'leaderboard_rank', 'list', 'metrics', 'ride', 'serialize', 'start_time', 'status', 'total_leaderboard_users']

>>> workout.status
'COMPLETE'

>>> workout.ride
<peloton.peloton.PelotonRide object at 0x104516e48>

>>> dir(workout.ride)
['description', 'duration', 'get', 'id', 'instructor_id', 'serialize', 'title']

>>> workout.ride.title
'45 min Max Capacity Ride'

Release files for peloton 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for peloton 0.0.2
File Size Uploaded
peloton-0.0.2.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for peloton 0.0.2
File Interpreter ABI Platform
peloton-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / peloton-0.0.2.tar.gz

Download URL peloton-0.0.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2894eb9aaffc0f30f8b8a96a1af5bb5690ff02071aaf76d2545f3e18a5333523
BLAKE2b-256 checksum
How to use checksums
152d4eb3842530f22567e183ddeb05b501b42f120121f7d1d387386a36703377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release files / peloton-0.0.2-py3-none-any.whl

Download URL peloton-0.0.2-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98fdd29ddd6910f9bb858f8b3a6b0fef6299e93992fd2cfe060adbc923ea533c
BLAKE2b-256 checksum
How to use checksums
a9c4051238398d9f149a74940c6204375f25bbaaf9628b2a90086a1ec6d21677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page