Reflections on 7 Years of Peloton To Garmin

Cartoon astronaut rides a tricycle... but pretend its a Peloton bike
Image by catalyststuff on Freepik

Over the years I've built many tools and weekend scripts, but Peloton-to-Garmin is the first tool I wrote that was used by a community of people and it's been so much fun growing and learning how to maintain a free open-source project.

Seven years ago, after nearly a year of my parents owning and raving about their Peloton, I decided to get one. Like many, I purchased around the holidays and was excited to not only catch the bike on sale but also kick off my πŸͺ© New Year with a new type of fitness resolution: Peloton-ing.

The idea of participating in live classes was a novelty to me and really stoked my competitive spirit. But the one area where Peloton fell flat (especially seven years ago) was in 1️⃣0️⃣ data and πŸ“ˆ metrics. Sure, the metrics on the bike were amazing and beautiful, but this was before the introduction of the Power Zone gauge and before they even had an Android app.

As an avid data nerd, this was immensely disappointing to me, so much so that I started poking around one weekend to see what I could do about it.

✳️ init

Cartoon astronaut sits at a desk typing on a laptop, the screen of the laptop lights their helmet showing stars and planets in the reflection.
Image by catalyststuff on Freepik

Ultimately, my goal was to see if there was any way I could automatically get my workouts from Peloton to sync over to Garmin Connect where I had over a decade of training history, and in doing so, I hoped to find the metric data I craved.

While researching I learned what would be the biggest barriers to this project:

  1. Peloton did have an API, but it was not official nor documented
  2. Garmin Connect did have an official API but they practice some major gatekeeping, only allowing other major companies to use it, not individuals like myself.
🧠
API stands for "Application Programming Interface". For the layperson its a sort of common way applications communicate with each other, sharing data back and forth, and is the underpinning of what makes all of your websites and apps work.

So I did what all good engineers do when encountering a problem... I set out to hack my way around it. It's my data after all.

I spent the weekend reverse engineering the Peloton and Garmin API's, mostly by inspecting network traffic from my browser and from referencing some existing Garmin projects on GitHub. At this time there weren't really any Peloton projects to reference.

Since I was just hacking together a quick script for myself, I used my trusty scripting language, 🐍 Python, and dumped all of the code into a single file. Surprisingly enough (to me at the time), it worked (mostly), and a whole new world of possibilities was unlocked.

Initially, the script only downloaded the Peloton data into files on your computer and you had to manually upload those workout files to Garmin Connect, but it was good enough for me. I decided to polish the code up a bit and publish it on πŸ™ GitHub publicly.

Wednesday Dec 27th, 2017 P2G was born.

I happily used my little script for just over a year before my first πŸ› bug was opened by a stranger on Jan 29th, 2019.

πŸ”­ discovery

Cartoon astronaut pirate looks through a telescope and spots saturn.
Image by catalyststuff on Freepik

I don't exactly remember how my project got discovered, I may have mentioned it in a comment on the r/peloton subreddit or it might have been one of the admins at the time u/clipin who was a tech savvy Garmin user.

Regardless of how it happened, P2G slowly started gathering its own following of people who were choosing to use it.

On July 22nd, 2020 the project had its first major contribution from the community. A member @padioca added initial support for P2G to automatically uploaded Peloton workouts to Garmin Connect, a feature I'd planned for from day one, but one that had escaped my technical skill level at the time.

This fabulous contribution was just in time for the projects first great disaster ☒️.

🌱 growth

Cartoon astronaut grows out of of a pot.
Image by catalyststuff on Freepik

There were now more than a handful of people using P2G, exact numbers are hard to determine as the project does not use any analytics tracking. I can loosely get an idea from looking at the number of Stars and Forks on GitHub.

The other great indicator of adoption is how many people show up when a problem occurs, just like it did January 5th, 2021 when Garmin made significant changes to how authentication worked and suddenly P2G could no longer auto-upload workouts to Garmin.

The first Great Garmin Auth Disaster ☒️.

(shhhhh just let me be dramatic ok?)

This was a stressful event for me. It was the first time (outside of the workplace) that I felt on the hook to fix a problem that intimidated me for a bunch of strangers on the internet who were counting on this tool.

However I learned through this "Garmin Auth Disaster" (and the second, third, and fourth ones) three important lessons:

❀️ The Peloton community is supportive

Folks regularly showed me patience, appreciation, and encouragement. And at the end of an issue, it's so much fun to see their excitement about the tool working for them again.

🀝 The GitHub community is supportive

I'd previously had some interactions with other developers on GitHub, but nothing like the interactions I've had while trying to solve these various "Garmin Auth Disasters". It was incredible to see how various projects around GitHub who all relied on the Garmin API in some way came together to research and find a solution. It's as if we have our own coalition now that comes together to share information and provide code when the need arises.

πŸ‘· The value of being an Escalator

Even in software engineering, while challenging, it's important to try and be an Escalator. Garmin changing their authentication method is something that happens on a somewhat regular basis, but thankfully, it does not fully break P2G.

The auto-upload feature is there for convenience, even when its not working, P2G can provide people a way to manually upload their workout files to Garmin. So even when the escalator is broken, they can still take the stairs.

🌲 longevity

Cartoon astronaut walks across a Crescent moon as if on a balance beam.
Image by catalyststuff on Freepik

It wasn't till the second Great Garmin Auth Disaster that I realized something needed to change. There were too many people using this project, too many new feature requests coming in, and too many changes I personally wanted to make. And on top of all that... P2G was just a hobby, something I really only wanted to spend a few hours working on every other week or so.

I decided it was time to leave 🐍 Python.

Don't get me wrong, I have no meaningful critique of the Python programming language, instead, my motivation is purely selfish. I am not a Python developer by trade and my knowledge of the language and its frameworks was still shallow at best.

I had reached a point where I was more interested in the project than in always trying to learn "how do I do this thing in python?".

So around June 12th, 2021 I rewrote P2G into my preferred language of C#. This immediately allowed me to not only decrease the amount of time I needed to invest in making changes (because of my familiarity with this language) but also got me excited and motivated to push the boundaries a bit. P2G became a place I could experiment and learn more about my trade language.

But most importantly, this rewrite made the project something I could more easily commit to maintaining long term.

πŸš€ to infinity and beyond

Cartoon Astronaut stands on the moon, pointing dramatically towards the future as they plant a flag.
Image by catalyststuff on Freepik

Since then, P2G now has a Windows application and Web application (for the technically inclined). It has grown to support newer Peloton exercise types like the Tread, Rower, and Strength classes. And it has a small community of folks discussing the project.

Working on a hobby project, for free, that's used by so many people has been a plethora of learning opportunities.

  • I learned how to write better error and logging messages since troubleshooting with folks via a discussion forum is hard.
  • I learned how to build in resiliency to my code so that one thing breaking doesn't also break everything else.
  • I got to practice providing support for people, with experience levels ranging from the extremely technical to the non-technical.
  • I got to practice documentation, testing, CI/CD pipelines, new UI frameworks, the list goes on and on

I hope for P2G to continue to follow the KISS principle, and to always focus on doing one thing and doing it well.

I'm excited to see what I have the opportunity to build for P2G in 2024 😏 !

bonus material

timeline

Subscribe to Next Topic

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe