How I automated booking my Cure.fit Cult classes — A Lazy fitness enthusiast’s story

Anooj Narvekar
3 min readMay 19, 2019

--

I’ve been a regular member at Cult. For folks who don’t know what Cult is, it is a mix of group workouts for one’s fitness needs. For me it was mostly Boxing, HRX and Strength & Conditioning. The group size is around 30 people and booking is strictly FCFS. Regular members (like me) can book 4 days in advance, while members who have been in the system for a while (level 3 and above) can book 7 days in advance.

There was a time, around new year’s, where getting a slot was close to impossible. My preferred slot is usually the morning 7–8 am slot. Most of this slot was booked by the Level3+ members 7 days in-advance, while very few slots were left for beginners to enroll. The slot booking would open at 10 pm every night and by the time I would check for availability, they would be all gone.

After a series of emails to the Cult support and with no much help, it was time to sit down, spend some time and automate the booking so that i would not miss the 10pm timeline.

Step 1 — Figuring out the APIs

Alright. You have the cure.fit app installed on your phone. It’s making API calls to the cure.fit services. How do you figure out the set of APIs in order to automate the entire booking of slot process?

To your help comes Charles. Quoting what Charles is meant for

Charles is an HTTP proxy / HTTP monitor / Reverse Proxy that enables a developer to view all of the HTTP and SSL / HTTPS traffic between their machine and the Internet. This includes requests, responses and the HTTP headers (which contain the cookies and caching information).

I use an iPhone. I have documented step-by-step guide on using Charles to monitor phone traffic here. Following that documentation, you would be able to figure out the API calls being made by the app.

APIs that we would need for booking are:

/api/cult/classes/v2?productType=FITNESS
/api/cult/class/<activityID>/book

In order to make authorised calls, you will need to figure out few details which needs to be passed whilst making the API calls.st, at and osname are the HTTP header fields that cure.fit needs to authenticate and authorise the user making the API call.

Screenshot of Charles showing typical header fields part of request to cure.fit APIs

Step 2 — Writing code for the automation

Sample gist is as below. You can find the entire code here on github.

The script is in Node, but you could use any programming language of your choice.

The script first makes an API call to figure out the upcoming classes, and then based on the your preference, books the slot. I’ve tried adding comments inside the script for better understanding.

Step 3 — Deploying code

We now have our script ready to automate the flow. But where do we deploy it to? Well, you won’t be buying dedicated hosting for this. How about AWS’s EC2 instance? Well, you can! But you don’t want your instance to be running all the time. You just want to execute the script everyday at a fixed time, for me it was 10 pm. Lamba — Serverless Compute!

You may follow this blog for steps for setting up Lambda functions and triggering them at defined intervals.

Done!

Happy automation to you! :)

--

--