strava
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTroubleshooting
故障排查
If requests fail, run or
zero doctor check-connector --env-name STRAVA_TOKENzero doctor check-connector --url https://www.strava.com/api/v3/athlete --method GET如果请求失败,请运行 或
zero doctor check-connector --env-name STRAVA_TOKENzero doctor check-connector --url https://www.strava.com/api/v3/athlete --method GETAthlete
运动员账号
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 with the from the athlete profile above:
<athlete-id>idbash
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>idbash
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:
- — Activities before timestamp
before=EPOCH - — Activities after timestamp
after=EPOCH - — Page number
page=1 - — Results per page (max 200)
per_page=30
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 - — 每页结果数(最大200)
per_page=30
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.jsonjson
{
"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: , , (ISO 8601), (seconds).
Optional: (meters), , (0/1), (0/1).
namesport_typestart_date_localelapsed_timedistancedescriptiontrainercommuteSport types: , , , , , , , , , , , , , , , , , , , , , , , , etc.
RunTrailRunRideMountainBikeRideGravelRideEBikeRideSwimWalkHikeWeightTrainingYogaWorkoutRowingKayakingSurfingRockClimbingGolfSoccerTennisPickleballSkateboardSnowboardAlpineSkiNordicSki写入 :
/tmp/strava_request.jsonjson
{
"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}'必填字段:、、(ISO 8601格式)、(秒)。
可选字段:(米)、、(0/1)、(0/1)。
namesport_typestart_date_localelapsed_timedistancedescriptiontrainercommute运动类型:、、、、、、、、、、、、、、、、、、、、、、、等。
RunTrailRunRideMountainBikeRideGravelRideEBikeRideSwimWalkHikeWeightTrainingYogaWorkoutRowingKayakingSurfingRockClimbingGolfSoccerTennisPickleballSkateboardSnowboardAlpineSkiNordicSkiUpdate Activity
更新活动
Write to :
/tmp/strava_request.jsonjson
{
"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: , , , (set to to remove), , , .
namesport_typedescriptiongear_id"none"trainercommutehide_from_home写入 :
/tmp/strava_request.jsonjson
{
"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}'可更新字段:、、、(设为可移除)、、、。
namesport_typedescriptiongear_id"none"trainercommutehide_from_homeUploads
上传
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: , , , , , .
fitfit.gztcxtcx.gzgpxgpx.gzbash
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"支持格式:、、、、、。
fitfit.gztcxtcx.gzgpxgpx.gzCheck 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 is populated, the upload is complete.
activity_id上传为异步处理,请轮询状态:
bash
curl -s "https://www.strava.com/api/v3/uploads/<upload-id>" --header "Authorization: Bearer $STRAVA_TOKEN" | jq '{id, status, error, activity_id}'当被填充时,上传完成。
activity_idActivity 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: , , , , , , , , , , .
timedistancelatlngaltitudevelocity_smoothheartratecadencewattstempmovinggrade_smoothbash
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'可用数据流键:、、、、、、、、、、。
timedistancelatlngaltitudevelocity_smoothheartratecadencewattstempmovinggrade_smoothSegments
路段
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 , shoe IDs start with :
bgbash
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以开头,鞋子ID以开头:
bgbash
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
指南
- Token expiry: Access tokens expire every 6 hours — the platform handles refresh automatically via the connector
- Pagination: Use and
page(max 200) for list endpointsper_page - Time filters: Use Unix epoch timestamps for /
beforeparametersafter - Scope requirements: Ensure token has correct scopes; needed for private activities,
activity:read_allneeded to create/editactivity:write - Rate limits: 200 req/15min, 2000 req/day — add delays for bulk operations. Returns when exceeded
429 - Distance units: All distances are in meters, speeds in meters/second
- Time units: All durations are in seconds
- Sport type vs type: Prefer over deprecated
sport_typefieldtype
- 令牌过期:访问令牌每6小时过期一次——平台会通过连接器自动处理刷新
- 分页:列表接口使用和
page(最大200)参数per_page - 时间筛选:/
before参数使用Unix时间戳after - 权限范围要求:确保令牌拥有正确的权限范围;访问私人活动需要,创建/编辑活动需要
activity:read_allactivity:write - 速率限制:15分钟内最多200次请求,一天最多2000次请求——批量操作时需添加延迟。超出限制会返回状态码
429 - 距离单位:所有距离单位为米,速度单位为米/秒
- 时间单位:所有时长单位为秒
- 运动类型字段:优先使用字段,而非已弃用的
sport_type字段type
API Reference
API参考
- REST Reference: https://developers.strava.com/docs/reference/
- Authentication: https://developers.strava.com/docs/authentication/
- Rate Limits: https://developers.strava.com/docs/rate-limits/
- Uploads: https://developers.strava.com/docs/uploads/