feat: add workout trends API (gateway endpoints) - #136
Conversation
Add support for the new OTF workout trends/stats endpoints discovered
in the Android app v5.6.0. These use a new API surface at
api.gateway.orangetheory.com with two endpoints:
- GET /consumer-mobile/v1/users/me/workout-stats/{statsKey}
- GET /consumer-mobile/v1/users/me/workout-stats/preview
Available stat keys: splat_points, average_hr, peak_hr, tread_top_speed,
rower_500m_split_time, rower_top_power.
New files:
- api/trends/ (TrendsClient + TrendsApi)
- models/trends/ (TrendType, TrendCategory, StatPoint, etc.)
Usage: otf.trends.get_workout_stats(TrendType.SplatPoints)
otf.trends.get_workout_stats_preview(workout_count=10)
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. 📝 WalkthroughWalkthroughThe change adds a Gateway API for workout trends. It introduces typed trend models, Gateway request handling, date-range statistics, workout previews, and the public ChangesWorkout trends
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Otf
participant TrendApi
participant TrendClient
participant GatewayAPI
Caller->>Otf: access trends
Otf->>TrendApi: call trend method
TrendApi->>TrendClient: request statistics
TrendClient->>GatewayAPI: send authenticated request
GatewayAPI-->>TrendClient: return workout statistics
TrendClient-->>TrendApi: return response data
TrendApi-->>Caller: return typed response
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b16e42f1-816b-4b1d-950f-7111daa3fd7a
📒 Files selected for processing (10)
CLAUDE.mdsrc/otf_api/api/api.pysrc/otf_api/api/client.pysrc/otf_api/api/trends/__init__.pysrc/otf_api/api/trends/trend_api.pysrc/otf_api/api/trends/trend_client.pysrc/otf_api/models/__init__.pysrc/otf_api/models/trends/__init__.pysrc/otf_api/models/trends/enums.pysrc/otf_api/models/trends/trends.py
Workout Trends API
Adds support for OTF's workout trends/stats data, discovered by decompiling the Android app v5.6.0. This surfaces a third API host the library didn't previously talk to.
api.gateway.orangetheory.com(API_GATEWAY_BASE_URLinclient.py), alongside the existing v1 (api.orangetheory.co) and v2 (api.orangetheory.io) surfaces. Same Cognito bearer auth as the other two, but snake_case JSON responses rather than camelCase.TrendClient/TrendApipair (src/otf_api/api/trends/) following the existing two-layer client/api convention used by bookings, studios, workouts, and members.otf.trendson theOtfclient:get_workout_stats(trend_type, start_date=None, end_date=None)for a single metric's time series (defaults to the last 90 days), andget_workout_stats_preview(workout_count=10)for a cross-metric snapshot of recent workouts.src/otf_api/models/trends/:TrendType(the six available stat keys — splat points, average/peak heart rate, treadmill top speed, rower 500m split time, rower top power) with a.categoryproperty mapping toTrendCategory(effort/treadmill/rower), plusStatPoint,WorkoutStatsResponse, andWorkoutStatsPreviewResponse.CLAUDE.mdupdated with a new "Gateway API" reference table, consistent with the existing V1/V2 documentation, so the versioning section now covers all three surfaces.Notable Changes
class_namevalues from OTF's API changed from human-readable strings (e.g."Strength 50 (Lower)") to raw enum slugs (e.g."STRENGTH_50"). This is an upstream OTF API change, unrelated to this PR, called out here so it isn't mistaken for a regression introduced by these endpoints.Summary by CodeRabbit
New Features
Documentation