{"slug":"gym-capacity-tracker-live-booking-api","title":"How I Built a Real-Time Gym Capacity Tracker Using AvailEngine's Live Booking API","excerpt":"I built a mobile-friendly app that shows real-time gym occupancy — 34 of 50 slots filled right now — and lets members book one of the remaining spots instantly. Here's how the live-dynamic booking endpoint makes it possible with zero polling, zero database reads from the client, and about 20 lines of integration code.","date":"July 9, 2026","category":"Tutorial","categoryColor":"bg-purple-50 text-purple-700","keywords":"gym booking API, real-time capacity tracker, live availability API, dynamic booking slots","content_html":"<pre>A friend of mine runs a CrossFit box in Athens. His biggest operational headache isn't programming WODs or managing coaches — it's people showing up when the gym is full. The fire code caps him at 50 occupants, and on a Tuesday evening he'd have 60 members parked outside waiting while 15 spots inside were held by people who booked but never came.\n\n### The Problem\n\nHe needed a live counter that members could check from their phone: *how many people are in the gym right now, and can I still get in?* If the answer was yes, he wanted them to be able to book — and pay a small deposit so the no-show problem disappeared too.\n\n### The Solution\n\nAvailEngine's **live-dynamic booking** endpoint (`GET /v1/availability/{business_id}`) returns real-time slot availability based on capacity and existing bookings. For the gym, I configured:\n\n- **One resource** — the gym floor — with **max capacity of 50**\n- **Booking slots** in 60-minute increments, auto-released if no check-in happens 15 minutes past the start time\n- **A €2 deposit** per slot (high enough to deter no-shows, low enough not to annoy members)\n\nWith those settings, the availability endpoint already handles the capacity math. When 34 people have active bookings for the 6 PM slot, the API returns **16 remaining spots** — no manual counting, no server-side occupancy logic to write.\n\n### The App (About 20 Lines of Integration)\n\nThe gym members open a simple mobile web app. Here's the core logic:\n\n```\n// Fetch real-time availability\nconst { available, capacity, booked } = await fetch(\n  `https://api.availengine.com/v1/availability/${gymId}\n    ?date=${today}&resource_id=gym-floor`\n).then(r => r.json())\n\n// Display on screen\ndocument.getElementById('occupancy').textContent =\n  `${booked} of ${capacity} spots filled`\n\n// If spots remain, show the booking button\nif (available > 0) {\n  document.getElementById('book-btn').disabled = false\n  document.getElementById('book-btn').textContent =\n    `Book a spot — ${available} left`\n}\n```\n\nThat's the entire integration. The availability call returns `booked`, `capacity`, and `available` — everything you need to render a live counter. The booking endpoint takes care of deposits, so the gym gets paid for every held slot whether the member shows up or not.\n\n### Why This Works\n\nThe key insight is that **capacity management is just resource-based availability**. A gym with 50 slots is the same problem as a restaurant with 20 tables — AvailEngine's resource model handles both. The live counter comes for free because the availability endpoint computes occupancy in real time from confirmed bookings.\n\nMembers check before they drive over, no-shows cost something (so they stop), and the owner sees a live dashboard of who's actually in the building. The whole integration took me about an hour — most of that was making the mobile UI look decent.\n\nGet an API key and try it yourself. If you can model it as slots, you can track it in real time.</pre>"}