Skip to content

Instantly share code, notes, and snippets.

@masselmello
Last active September 24, 2025 09:49
Show Gist options
  • Select an option

  • Save masselmello/6d4f4c533b98b2550ee23a7a5e6c6cff to your computer and use it in GitHub Desktop.

Select an option

Save masselmello/6d4f4c533b98b2550ee23a7a5e6c6cff to your computer and use it in GitHub Desktop.
iOS widget powered by the Scriptable app that shows the current capacity of your McFit gym (RSG group)
/**
* Script for scriptable to get the current capacity of McFit Gyms
*/
let gymId = 1731068920
let param = args.widgetParameter
if (param != null && param.length > 0) {
gymId = param
}
const currentGymCapacity = await fetchGymCapacity(gymId)
const storeInfo = await fetchGymInfo(gymId)
const gymName = await fetchGymInfo(gymId)
const widget = new ListWidget()
await createWidget()
if (!config.runsInWidget) {
await widget.presentSmall()
}
Script.setWidget(widget)
Script.complete()
//Create the widget
async function createWidget() {
const headlineText = widget.addText("🏋️ Capacity")
headlineText.font = Font.mediumRoundedSystemFont(19)
widget.addSpacer(30)
const capacityText = widget.addText(currentGymCapacity.toString() + "%")
capacityText.font = Font.mediumRoundedSystemFont(50)
if (currentGymCapacity < 20) {
capacityText.textColor = new Color("#33cc33")
} else if (currentGymCapacity < 30){
capacityText.textColor = new Color("#ff9900")
}else{
capacityText.textColor = new Color("#ff3300")
}
widget.addSpacer(1)
const gymNameText = widget.addText(gymName)
gymNameText.font = Font.regularSystemFont(12)
}
//Fetches the current capacity of the McFit gym
async function fetchGymCapacity(id) {
const url = `https://my.mcfit.com/nox/public/v1/studios/${id}/utilization/v2/today`
const req = new Request(url)
req.headers = {
'x-tenant': 'rsg-group'
}
const result = await req.loadJSON()
return result.find((item) => item.current)?.percentage ?? 0
}
//Fetches the name of the gym
async function fetchGymInfo(id) {
const url = 'https://rsg-group.api.magicline.com/connect/v1/studio?studioTags=AKTIV-391B8025C1714FB9B15BB02F2F8AC0B2'
const req = new Request(url)
const apiResult = await req.loadJSON()
for(var i in apiResult){
if(apiResult[i].id == id){
return apiResult[i].studioName
}
}
return 'Your McFit'
}
@marvinjoa
Copy link

Sehr nice, dass ich nichtmal die gymID ändern musste, weil der OP wohl mal im gleichen Gym trainiert hat :D

@DerSchiman
Copy link

thanks @lorenzlars

@TimoReusch
Copy link

@iToab Die Studios von Jumpers Fitness findet man auf jeden Fall hier: https://bestfit.api.magicline.com/connect/v1/studio

Hier gibts die Daten: https://bestfit.api.magicline.com/connect/v1/studio/{studioId}/utilization - bin mir aber nicht sicher, ob die tatsächlich live sind oder einfach jeden Tag das gleiche angezeigt wird.

@erikspall FYI

@XCame
Copy link

XCame commented Jul 1, 2025

bump, damit @masselmello die funktion von @lorenzlars implementiert und zukünftigen Besuchern das scrollen durch die Kommentare erspart. ❤️

Thx by the way für das Script.

@masselmello
Copy link
Author

Done ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment