strava

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Troubleshooting

故障排查

If requests fail, run
zero doctor check-connector --env-name STRAVA_TOKEN
or
zero doctor check-connector --url https://www.strava.com/api/v3/athlete --method GET
如果请求失败,请运行
zero doctor check-connector --env-name STRAVA_TOKEN
zero doctor check-connector --url https://www.strava.com/api/v3/athlete --method GET

Athlete

运动员账号

Get Authenticated Athlete Profile

获取已认证运动员资料

bash
curl -s "https://www.strava.com/api/v3/athlete" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, firstname, lastname, city, country, sex, premium, created_at, follower_count, friend_count}'
bash
curl -s "https://www.strava.com/api/v3/athlete" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, firstname, lastname, city, country, sex, premium, created_at, follower_count, friend_count}'

Get Athlete Statistics

获取运动员统计数据

Replace
<athlete-id>
with the
id
from the athlete profile above:
bash
curl -s "https://www.strava.com/api/v3/athletes/<athlete-id>/stats" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{recent_run_totals, recent_ride_totals, ytd_run_totals, ytd_ride_totals, all_run_totals, all_ride_totals}'
替换
<athlete-id>
为上述运动员资料中的
id
bash
curl -s "https://www.strava.com/api/v3/athletes/<athlete-id>/stats" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{recent_run_totals, recent_ride_totals, ytd_run_totals, ytd_ride_totals, all_run_totals, all_ride_totals}'

Activities

活动

List Recent Activities

列出近期活动

bash
curl -s "https://www.strava.com/api/v3/athlete/activities?per_page=30" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, sport_type, distance, moving_time, elapsed_time, total_elevation_gain, start_date_local, average_speed, max_speed}'
Query parameters:
  • before=EPOCH
    — Activities before timestamp
  • after=EPOCH
    — Activities after timestamp
  • page=1
    — Page number
  • per_page=30
    — Results per page (max 200)
bash
curl -s "https://www.strava.com/api/v3/athlete/activities?per_page=30" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, sport_type, distance, moving_time, elapsed_time, total_elevation_gain, start_date_local, average_speed, max_speed}'
查询参数:
  • before=EPOCH
    — 指定时间戳之前的活动
  • after=EPOCH
    — 指定时间戳之后的活动
  • page=1
    — 页码
  • per_page=30
    — 每页结果数(最大200)

Get Activity Details

获取活动详情

bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, sport_type, distance, moving_time, elapsed_time, total_elevation_gain, average_speed, max_speed, average_heartrate, max_heartrate, calories, description, gear_id}'
bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, sport_type, distance, moving_time, elapsed_time, total_elevation_gain, average_speed, max_speed, average_heartrate, max_heartrate, calories, description, gear_id}'

Create Manual Activity

创建手动活动

Write to
/tmp/strava_request.json
:
json
{
  "name": "Morning Run",
  "sport_type": "Run",
  "start_date_local": "2025-01-15T08:00:00Z",
  "elapsed_time": 3600,
  "distance": 10000,
  "description": "Easy morning run"
}
Then run:
bash
curl -s -X POST "https://www.strava.com/api/v3/activities" --header "Authorization: Bearer $STRAVA_TOKEN" --header "Content-Type: application/json" -d @/tmp/strava_request.json | jq '{id, name, sport_type, distance}'
Required fields:
name
,
sport_type
,
start_date_local
(ISO 8601),
elapsed_time
(seconds). Optional:
distance
(meters),
description
,
trainer
(0/1),
commute
(0/1).
Sport types:
Run
,
TrailRun
,
Ride
,
MountainBikeRide
,
GravelRide
,
EBikeRide
,
Swim
,
Walk
,
Hike
,
WeightTraining
,
Yoga
,
Workout
,
Rowing
,
Kayaking
,
Surfing
,
RockClimbing
,
Golf
,
Soccer
,
Tennis
,
Pickleball
,
Skateboard
,
Snowboard
,
AlpineSki
,
NordicSki
, etc.
写入
/tmp/strava_request.json
json
{
  "name": "Morning Run",
  "sport_type": "Run",
  "start_date_local": "2025-01-15T08:00:00Z",
  "elapsed_time": 3600,
  "distance": 10000,
  "description": "Easy morning run"
}
然后运行:
bash
curl -s -X POST "https://www.strava.com/api/v3/activities" --header "Authorization: Bearer $STRAVA_TOKEN" --header "Content-Type: application/json" -d @/tmp/strava_request.json | jq '{id, name, sport_type, distance}'
必填字段:
name
sport_type
start_date_local
(ISO 8601格式)、
elapsed_time
(秒)。 可选字段:
distance
(米)、
description
trainer
(0/1)、
commute
(0/1)。
运动类型:
Run
TrailRun
Ride
MountainBikeRide
GravelRide
EBikeRide
Swim
Walk
Hike
WeightTraining
Yoga
Workout
Rowing
Kayaking
Surfing
RockClimbing
Golf
Soccer
Tennis
Pickleball
Skateboard
Snowboard
AlpineSki
NordicSki
等。

Update Activity

更新活动

Write to
/tmp/strava_request.json
:
json
{
  "name": "Updated Name",
  "description": "Updated description",
  "sport_type": "Run",
  "gear_id": "<gear-id>",
  "commute": false,
  "hide_from_home": false
}
Then run:
bash
curl -s -X PUT "https://www.strava.com/api/v3/activities/<activity-id>" --header "Authorization: Bearer $STRAVA_TOKEN" --header "Content-Type: application/json" -d @/tmp/strava_request.json | jq '{id, name, description, sport_type}'
Updatable fields:
name
,
sport_type
,
description
,
gear_id
(set to
"none"
to remove),
trainer
,
commute
,
hide_from_home
.
写入
/tmp/strava_request.json
json
{
  "name": "Updated Name",
  "description": "Updated description",
  "sport_type": "Run",
  "gear_id": "<gear-id>",
  "commute": false,
  "hide_from_home": false
}
然后运行:
bash
curl -s -X PUT "https://www.strava.com/api/v3/activities/<activity-id>" --header "Authorization: Bearer $STRAVA_TOKEN" --header "Content-Type: application/json" -d @/tmp/strava_request.json | jq '{id, name, description, sport_type}'
可更新字段:
name
sport_type
description
gear_id
(设为
"none"
可移除)、
trainer
commute
hide_from_home

Uploads

上传

Upload Activity File (GPX/FIT/TCX)

上传活动文件(GPX/FIT/TCX)

bash
curl -s -X POST "https://www.strava.com/api/v3/uploads" --header "Authorization: Bearer $STRAVA_TOKEN" -F "data_type=gpx" -F "file=@/path/to/activity.gpx" -F "name=My Activity" -F "description=Uploaded via API"
Supported formats:
fit
,
fit.gz
,
tcx
,
tcx.gz
,
gpx
,
gpx.gz
.
bash
curl -s -X POST "https://www.strava.com/api/v3/uploads" --header "Authorization: Bearer $STRAVA_TOKEN" -F "data_type=gpx" -F "file=@/path/to/activity.gpx" -F "name=My Activity" -F "description=Uploaded via API"
支持格式:
fit
fit.gz
tcx
tcx.gz
gpx
gpx.gz

Check Upload Status

检查上传状态

Uploads are processed asynchronously. Poll for status:
bash
curl -s "https://www.strava.com/api/v3/uploads/<upload-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, status, error, activity_id}'
When
activity_id
is populated, the upload is complete.
上传为异步处理,请轮询状态:
bash
curl -s "https://www.strava.com/api/v3/uploads/<upload-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, status, error, activity_id}'
activity_id
被填充时,上传完成。

Activity Details

活动详情

List Activity Comments

列出活动评论

bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/comments" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, text, created_at, athlete: .athlete.firstname}'
bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/comments" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, text, created_at, athlete: .athlete.firstname}'

List Activity Kudoers

列出活动点赞者

bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/kudos" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, firstname, lastname}'
bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/kudos" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, firstname, lastname}'

Get Activity Laps

获取活动分段

bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/laps" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, elapsed_time, distance, average_speed, average_heartrate}'
bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/laps" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, elapsed_time, distance, average_speed, average_heartrate}'

Get Activity Streams (GPS/HR/Power Data)

获取活动数据流(GPS/心率/功率数据)

bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/streams?keys=time,distance,heartrate,velocity_smooth&key_by_type=true" --header "Authorization: Bearer $STRAVA_TOKEN" | jq 'keys'
Available stream keys:
time
,
distance
,
latlng
,
altitude
,
velocity_smooth
,
heartrate
,
cadence
,
watts
,
temp
,
moving
,
grade_smooth
.
bash
curl -s "https://www.strava.com/api/v3/activities/<activity-id>/streams?keys=time,distance,heartrate,velocity_smooth&key_by_type=true" --header "Authorization: Bearer $STRAVA_TOKEN" | jq 'keys'
可用数据流键:
time
distance
latlng
altitude
velocity_smooth
heartrate
cadence
watts
temp
moving
grade_smooth

Segments

路段

List Starred Segments

列出已收藏路段

bash
curl -s "https://www.strava.com/api/v3/segments/starred" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, distance, average_grade, maximum_grade, city, state, country}'
bash
curl -s "https://www.strava.com/api/v3/segments/starred" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, distance, average_grade, maximum_grade, city, state, country}'

Get Segment Details

获取路段详情

bash
curl -s "https://www.strava.com/api/v3/segments/<segment-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, activity_type, distance, average_grade, maximum_grade, elevation_high, elevation_low, city, country, effort_count, athlete_count}'
bash
curl -s "https://www.strava.com/api/v3/segments/<segment-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, activity_type, distance, average_grade, maximum_grade, elevation_high, elevation_low, city, country, effort_count, athlete_count}'

Gear

装备

Get Athlete's Gear

获取运动员装备

bash
curl -s "https://www.strava.com/api/v3/athlete" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{bikes: .bikes, shoes: .shoes}'
bash
curl -s "https://www.strava.com/api/v3/athlete" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{bikes: .bikes, shoes: .shoes}'

Get Gear Details

获取装备详情

Bike IDs start with
b
, shoe IDs start with
g
:
bash
curl -s "https://www.strava.com/api/v3/gear/<gear-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, brand_name, model_name, distance, converted_distance}'
自行车ID以
b
开头,鞋子ID以
g
开头:
bash
curl -s "https://www.strava.com/api/v3/gear/<gear-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, brand_name, model_name, distance, converted_distance}'

Clubs

俱乐部

List Athlete Clubs

列出运动员所属俱乐部

bash
curl -s "https://www.strava.com/api/v3/athlete/clubs" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, sport_type, city, country, member_count}'
bash
curl -s "https://www.strava.com/api/v3/athlete/clubs" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, sport_type, city, country, member_count}'

Get Club Details

获取俱乐部详情

bash
curl -s "https://www.strava.com/api/v3/clubs/<club-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, sport_type, city, country, member_count, description}'
bash
curl -s "https://www.strava.com/api/v3/clubs/<club-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, name, sport_type, city, country, member_count, description}'

List Club Activities

列出俱乐部活动

bash
curl -s "https://www.strava.com/api/v3/clubs/<club-id>/activities?per_page=20" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {name, sport_type, distance, moving_time, athlete: (.athlete.firstname + " " + .athlete.lastname)}'
bash
curl -s "https://www.strava.com/api/v3/clubs/<club-id>/activities?per_page=20" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {name, sport_type, distance, moving_time, athlete: (.athlete.firstname + " " + .athlete.lastname)}'

Routes

路线

Get Athlete Routes

获取运动员路线

bash
curl -s "https://www.strava.com/api/v3/athletes/<athlete-id>/routes?per_page=20" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, type, distance, elevation_gain, estimated_moving_time}'
bash
curl -s "https://www.strava.com/api/v3/athletes/<athlete-id>/routes?per_page=20" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '.[] | {id, name, type, distance, elevation_gain, estimated_moving_time}'

Guidelines

指南

  1. Token expiry: Access tokens expire every 6 hours — the platform handles refresh automatically via the connector
  2. Pagination: Use
    page
    and
    per_page
    (max 200) for list endpoints
  3. Time filters: Use Unix epoch timestamps for
    before
    /
    after
    parameters
  4. Scope requirements: Ensure token has correct scopes;
    activity:read_all
    needed for private activities,
    activity:write
    needed to create/edit
  5. Rate limits: 200 req/15min, 2000 req/day — add delays for bulk operations. Returns
    429
    when exceeded
  6. Distance units: All distances are in meters, speeds in meters/second
  7. Time units: All durations are in seconds
  8. Sport type vs type: Prefer
    sport_type
    over deprecated
    type
    field
  1. 令牌过期:访问令牌每6小时过期一次——平台会通过连接器自动处理刷新
  2. 分页:列表接口使用
    page
    per_page
    (最大200)参数
  3. 时间筛选
    before
    /
    after
    参数使用Unix时间戳
  4. 权限范围要求:确保令牌拥有正确的权限范围;访问私人活动需要
    activity:read_all
    ,创建/编辑活动需要
    activity:write
  5. 速率限制:15分钟内最多200次请求,一天最多2000次请求——批量操作时需添加延迟。超出限制会返回
    429
    状态码
  6. 距离单位:所有距离单位为,速度单位为米/秒
  7. 时间单位:所有时长单位为
  8. 运动类型字段:优先使用
    sport_type
    字段,而非已弃用的
    type
    字段

API Reference

API参考