Activities API reference
Activity detail
Authenticated route for the combined activity detail.
read_activity_detail
read_activity_detail(activity_id, token_user_id, db, response)
Return an activity with its laps, sets and workout steps in one read.
Equivalent to reading the activity and each collection separately, with the access decision made
once. The activity carries its media when the caller owns it, and owner is the owner's
public profile. Streams stay on their own route. The ETag is the activity's, to echo in
If-Match when saving it.
Source code in backend/app/modules/activities/activity_detail/router.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
Pydantic schema for the combined activity detail.
ActivityDetailRead
Bases: BaseModel
An activity together with the first page of each child collection the detail view shows.
Each collection is the page envelope its own route returns, so a client that finds a next page
continues with that route. A collection hidden from the viewer, or one the activity has none of,
is an empty page.
Attributes:
| Name | Type | Description |
|---|---|---|
activity |
ActivityRead
|
The activity, masked as the viewer may see it. Its |
owner |
UserPublicRead | None
|
The activity owner's public profile, the projection |
laps |
ActivityLapsPage
|
The activity's laps. |
sets |
ActivitySetsPage
|
The activity's performed workout sets. |
workout_steps |
ActivityWorkoutStepsPage
|
The activity's planned workout steps. |
Source code in backend/app/modules/activities/activity_detail/schema.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
Activity streams
Authenticated activity stream endpoints.
list_activity_streams
list_activity_streams(request, activity_id, token_user_id, db, page)
Return one page of the given activity's streams, with the matching total.
Source code in backend/app/modules/activities/activity_streams/router.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
read_activity_stream
read_activity_stream(request, activity_id, stream_type, token_user_id, db)
Get a specific stream type for an activity.
Not found when the activity has no such stream or is not visible to the
caller. A single resource that does not exist is a 404 rather than
200 null, and the two cases are indistinguishable so the endpoint cannot
be used to probe which activities exist.
Source code in backend/app/modules/activities/activity_streams/router.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
Pydantic schemas for activity stream data.
ActivityStreamZones
Bases: BaseModel
A stream's zone breakdowns, by metric.
Attributes:
| Name | Type | Description |
|---|---|---|
hr |
HrZoneBreakdown
|
The heart-rate zone breakdown. |
Source code in backend/app/modules/activities/activity_streams/schema.py
44 45 46 47 48 49 50 51 | |
ActivityStreamsBase
Bases: BaseModel
Schema for activity stream data.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Unique stream identifier. |
|
activity_id |
UUID
|
Parent activity identifier. |
stream_type |
StrictInt
|
Stream type code, as stored (1-8); a client reads it as |
stream_waypoints |
list[dict[str, Any]]
|
Waypoint data points, as stored: JSON objects with a |
strava_activity_stream_id |
StrictInt | None
|
Strava stream ID. |
Source code in backend/app/modules/activities/activity_streams/schema.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
ActivityStreamsRead
Bases: ActivityStreamsBase
A stored stream, as the services handle it before it is typed for a client.
Its waypoints are the stored JSON objects. Routes answer with the typed
:data:ActivityStreamResponse of the same stream.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique stream identifier. |
zone_percentages |
ActivityStreamZones | None
|
The stream's zone breakdowns. Computed when the stream is served, from the owner's current thresholds; never stored, so it cannot go stale. |
Source code in backend/app/modules/activities/activity_streams/schema.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
CadenceStreamRead
Bases: _ActivityStreamResponse[CadenceWaypoint]
The cadence stream (cadence).
Source code in backend/app/modules/activities/activity_streams/schema.py
217 218 | |
CadenceWaypoint
Bases: StreamWaypoint
A sample of the cadence stream.
Attributes:
| Name | Type | Description |
|---|---|---|
cad |
_Number | None
|
Cadence in rpm (spm for running). |
Source code in backend/app/modules/activities/activity_streams/schema.py
115 116 117 118 119 120 121 122 123 124 | |
ElevationStreamRead
Bases: _ActivityStreamResponse[ElevationWaypoint]
The elevation stream (elevation).
Source code in backend/app/modules/activities/activity_streams/schema.py
221 222 | |
ElevationWaypoint
Bases: StreamWaypoint
A sample of the elevation stream.
Attributes:
| Name | Type | Description |
|---|---|---|
ele |
_Number | None
|
Elevation in meters. |
Source code in backend/app/modules/activities/activity_streams/schema.py
127 128 129 130 131 132 133 134 | |
HeartRateStreamRead
Bases: _ActivityStreamResponse[HeartRateWaypoint]
The heart-rate stream (heart_rate).
Source code in backend/app/modules/activities/activity_streams/schema.py
209 210 | |
HeartRateWaypoint
Bases: StreamWaypoint
A sample of the heart-rate stream.
Attributes:
| Name | Type | Description |
|---|---|---|
hr |
_Number | None
|
Heart rate in bpm. |
Source code in backend/app/modules/activities/activity_streams/schema.py
95 96 97 98 99 100 101 102 | |
MapStreamRead
Bases: _ActivityStreamResponse[MapWaypoint]
The GPS map stream (map).
Source code in backend/app/modules/activities/activity_streams/schema.py
233 234 | |
MapWaypoint
Bases: StreamWaypoint
A GPS sample of the map stream.
Attributes:
| Name | Type | Description |
|---|---|---|
lat |
_Number | None
|
Latitude in decimal degrees. |
lon |
_Number | None
|
Longitude in decimal degrees. |
Source code in backend/app/modules/activities/activity_streams/schema.py
157 158 159 160 161 162 163 164 165 166 | |
PaceStreamRead
Bases: _ActivityStreamResponse[PaceWaypoint]
The pace stream (pace).
Source code in backend/app/modules/activities/activity_streams/schema.py
229 230 | |
PaceWaypoint
Bases: StreamWaypoint
A sample of the pace stream.
Attributes:
| Name | Type | Description |
|---|---|---|
pace |
_Number | None
|
Pace in s/m; 0 where the speed is 0. |
Source code in backend/app/modules/activities/activity_streams/schema.py
147 148 149 150 151 152 153 154 | |
PowerStreamRead
Bases: _ActivityStreamResponse[PowerWaypoint]
The power stream (power).
Source code in backend/app/modules/activities/activity_streams/schema.py
213 214 | |
PowerWaypoint
Bases: StreamWaypoint
A sample of the power stream.
Attributes:
| Name | Type | Description |
|---|---|---|
power |
_Number | None
|
Power in watts. |
Source code in backend/app/modules/activities/activity_streams/schema.py
105 106 107 108 109 110 111 112 | |
SpeedStreamRead
Bases: _ActivityStreamResponse[SpeedWaypoint]
The speed stream (speed).
Source code in backend/app/modules/activities/activity_streams/schema.py
225 226 | |
SpeedWaypoint
Bases: StreamWaypoint
A sample of the speed stream.
Attributes:
| Name | Type | Description |
|---|---|---|
vel |
_Number | None
|
Speed in m/s. |
Source code in backend/app/modules/activities/activity_streams/schema.py
137 138 139 140 141 142 143 144 | |
StreamWaypoint
Bases: BaseModel
What every stream sample carries, served as it was stored.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
Annotated[str | _Number | None, Field(exclude_if=lambda value: value is None, description='When the sample was taken: a UTC timestamp, or seconds from the start for a Strava stream')]
|
When the sample was taken: a UTC |
Source code in backend/app/modules/activities/activity_streams/schema.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
TemperatureStreamRead
Bases: _ActivityStreamResponse[TemperatureWaypoint]
The temperature stream (temperature).
Source code in backend/app/modules/activities/activity_streams/schema.py
237 238 | |
TemperatureWaypoint
Bases: StreamWaypoint
A sample of the temperature stream.
Attributes:
| Name | Type | Description |
|---|---|---|
temp |
_Number | None
|
Temperature in degrees Celsius. |
Source code in backend/app/modules/activities/activity_streams/schema.py
169 170 171 172 173 174 175 176 | |
Activity summary
FastAPI routes for activity summaries (authenticated).
Thin HTTP adapter: it validates query parameters and delegates every decision to
:mod:activity_summary_service. Mounted under /activities/summaries as a sub-resource
of activities, and the period is a query parameter, not a path segment, because
week/month/
year/lifetime are four views of one resource, not four resources.
read_activity_summary
read_activity_summary(request, token_user_id, db, period=activity_constants.SummaryPeriod.WEEK, anchor_date=None, target_year=None, activity_type=None)
Return the authenticated user's activity summary for one period.
Source code in backend/app/modules/activities/activity/summary_router.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Activity workout steps
Authenticated routes for activity workout steps.
list_activity_workout_steps
list_activity_workout_steps(activity_id, token_user_id, db, page)
Return one page of the activity's workout steps, with the matching total.
Source code in backend/app/modules/activities/activity_workout_steps/router.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Activity workout steps schemas.
ActivityWorkoutStepsBase
Bases: BaseModel
Fields that describe one workout step.
Attributes:
| Name | Type | Description |
|---|---|---|
message_index |
StrictInt
|
Workout step message index. |
duration_type |
StrictStr
|
Workout step duration type. |
duration_value |
StrictFloat | None
|
Workout step duration value. |
target_type |
StrictStr | None
|
Workout step target type. |
target_value |
StrictInt | None
|
Workout step target value. |
intensity |
StrictStr | None
|
Workout step intensity type. |
notes |
StrictStr | None
|
Workout step notes. |
exercise_category |
StrictInt | None
|
Workout step exercise category. |
exercise_name |
StrictInt | None
|
Exercise name ID. |
exercise_weight |
StrictFloat | None
|
Workout step exercise weight. |
weight_display_unit |
StrictStr | None
|
Workout step weight display unit. |
secondary_target_value |
StrictStr | None
|
Workout step secondary target value. |
Source code in backend/app/modules/activities/activity_workout_steps/schema.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
ActivityWorkoutStepsRead
Bases: ActivityWorkoutStepsBase
A stored workout step, as the API returns it.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Primary key. |
activity_id |
UUID
|
FK to activities table. |
Source code in backend/app/modules/activities/activity_workout_steps/schema.py
63 64 65 66 67 68 69 70 71 72 | |
Activity file import
Public parser-registry operations for activity files.
auto_lap_distance_km
auto_lap_distance_km(imperial)
Return the distance of an automatic lap in the athlete's units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imperial
|
bool
|
Whether the athlete uses imperial units. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One mile in km for imperial athletes, 1 km otherwise. |
Source code in backend/app/modules/activities/activity_file_import/integration_service.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
get_parser
get_parser(file_extension)
Return the parser registered for a file extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_extension
|
str
|
The file extension, including the dot. |
required |
Returns:
| Type | Description |
|---|---|
FileParser | None
|
The parser, or None when the extension is unsupported. |
Source code in backend/app/modules/activities/activity_file_import/integration_service.py
9 10 11 12 13 14 15 16 17 18 | |
supported_extensions
supported_extensions()
Return the file extensions accepted by the parser registry.
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The accepted extensions. |
Source code in backend/app/modules/activities/activity_file_import/integration_service.py
21 22 23 24 25 26 27 | |