Skip to content

feat: add workout trends API (gateway endpoints) - #136

Merged
NodeJSmith merged 3 commits into
mainfrom
new-version
Aug 7, 2026
Merged

feat: add workout trends API (gateway endpoints)#136
NodeJSmith merged 3 commits into
mainfrom
new-version

Conversation

@NodeJSmith

@NodeJSmith NodeJSmith commented Aug 6, 2026

Copy link
Copy Markdown
Owner

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.

  • New base URL api.gateway.orangetheory.com (API_GATEWAY_BASE_URL in client.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.
  • New TrendClient/TrendApi pair (src/otf_api/api/trends/) following the existing two-layer client/api convention used by bookings, studios, workouts, and members.
  • Exposed as otf.trends on the Otf client: get_workout_stats(trend_type, start_date=None, end_date=None) for a single metric's time series (defaults to the last 90 days), and get_workout_stats_preview(workout_count=10) for a cross-metric snapshot of recent workouts.
  • New models in 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 .category property mapping to TrendCategory (effort/treadmill/rower), plus StatPoint, WorkoutStatsResponse, and WorkoutStatsPreviewResponse.
  • Data goes back roughly 3 years per OTF's gateway API.
  • CLAUDE.md updated 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

  • The gateway API reports treadmill data for Strength 50 classes — this is expected, since Strength 50 templates include treadmill time, not a bug in this library.
  • Since ~January 2026, class_name values 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

    • Added access to workout trends through the main API client.
    • Retrieve workout statistics for supported metrics over a selected date range.
    • View summary previews for recent workouts, with a default preview of the 10 latest workouts.
    • Added structured trend categories, metric types, and response data for easier analysis.
  • Documentation

    • Expanded API documentation with Gateway API details, authentication, endpoints, response formats, and supported statistics.

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)
@NodeJSmith
NodeJSmith marked this pull request as ready for review August 6, 2026 23:52
Copilot AI lite review requested due to automatic review settings August 6, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@NodeJSmith, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 04f8f8e6-e939-49d0-b2a9-3d353d83a839

📥 Commits

Reviewing files that changed from the base of the PR and between e754ff8 and 4fdf997.

📒 Files selected for processing (1)
  • CLAUDE.md
📝 Walkthrough

Walkthrough

The change adds a Gateway API for workout trends. It introduces typed trend models, Gateway request handling, date-range statistics, workout previews, and the public Otf.trends API.

Changes

Workout trends

Layer / File(s) Summary
Trend models and exports
src/otf_api/models/trends/*, src/otf_api/models/__init__.py
Adds trend categories, metric types, time-series models, preview models, and package exports.
Gateway retrieval and Otf integration
src/otf_api/api/client.py, src/otf_api/api/trends/*, src/otf_api/api/api.py, CLAUDE.md
Adds Gateway requests, date-range and preview methods, Otf.trends, and API documentation.
Estimated code review effort: 3 (Moderate) ~20 minutes

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a workout trends API through gateway endpoints.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc84df6 and e754ff8.

📒 Files selected for processing (10)
  • CLAUDE.md
  • src/otf_api/api/api.py
  • src/otf_api/api/client.py
  • src/otf_api/api/trends/__init__.py
  • src/otf_api/api/trends/trend_api.py
  • src/otf_api/api/trends/trend_client.py
  • src/otf_api/models/__init__.py
  • src/otf_api/models/trends/__init__.py
  • src/otf_api/models/trends/enums.py
  • src/otf_api/models/trends/trends.py

Comment thread CLAUDE.md Outdated
Comment thread src/otf_api/api/trends/trend_client.py
Copilot AI review requested due to automatic review settings August 7, 2026 00:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@NodeJSmith
NodeJSmith merged commit a001cd6 into main Aug 7, 2026
4 checks passed
@NodeJSmith
NodeJSmith deleted the new-version branch August 7, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants