Create manual activity
Related Strava API route: createActivity
Other useful links:
- API reference
- API authentication
- Get a Strava API access token with write permission
- Building A Strava Authentication CLI In Rust
-
stravacli
(Golang CLI)
Create activity process is a bit annoying, due to authorization & grant access to user data:
- Create an account
- Configure API
- Authorize to access to a user account
- Your browser asks you to confirm acces
-
<AUTH_CODE>
is given in the response URL - Use
<AUTH_CODE>
to get anaccess_token
- Response with profile details &
<ACCESS_T>
- Create activity withe given
<ACCESS_T>
- Response with the created activity details
Click to expand all the comands
- Authorize to access to a user account
https://www.strava.com/oauth/authorize?client_id=<CLIENT_ID>&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=activity:write
- Your browser asks you to confirm access
-
<AUTH_CODE>
is given in the response URL
http://localhost/exchange_token?state=&code=<AUTH_CODE>&scope=read,activity:write
- Use
<AUTH_CODE>
to get anaccess_token
user@laptop ~ % http POST https://www.strava.com/oauth/token \
client_id=<CLIENT_ID> \
client_secret=<CLIENT_SECRET> \
code=<AUTH_CODE> \
grant_type=authorization_code
- Response with profile details &
<ACCESS_T>
HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
[…snip…]
{
"access_token":"<ACCESS_T>",
"athlete": {
"badge_type_id": 0,
"bio": "Ah ah ah! BIOGRAPHIE!!!",
"firstname": "Geo",
"id": <ID>,
"resource_state": 2,
[…snip…]
"weight": 0.0
},
"expires_at": 1647584825,
"expires_in": 21600,
"refresh_token":"<REFRESH_T>"
"token_type": "Bearer"
}
- Create activity withe given
<ACCESS_T>
user@laptop ~ % http POST "https://www.strava.com/api/v3/activities" \
name='03 manual' \
type='ride' \
start_date_local='2022-03-16T18:02:13Z' \
elapsed_time='3600' \
description='description for manual activity #03' \
distance='15' \
trainer='0' \
commute='0' \
hide_from_home='false' \
"Authorization: Bearer <ACCESS_T>"
- Response with the created activity details:
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json; charset=utf-8
[…snip…]
{
"achievement_count": 0,
"athlete": {
"id": <ID>,
"resource_state": 1
},
"athlete_count": 1,
"available_zones": [],
"average_speed": 0.004,
"calories": 0,
"comment_count": 0,
"commute": false,
"description": "description for manual activity #03",
"display_hide_heartrate_option": false,
"distance": 15.0,
"elapsed_time": 3600,
"manual": true,
[…snip…]
"map": {
[…snip…]
},
"max_speed": 0,
"moving_time": 3600,
"name": "03 manual",
"perceived_exertion": null,
"photo_count": 0,
"photos": {
"count": 0,
"primary": null
},
"pr_count": 0,
"prefer_perceived_exertion": null,
"private": false,
"private_note": null,
"resource_state": 3,
"segment_efforts": [],
"start_date": "2022-03-16T17:02:13Z",
"start_date_local": "2022-03-16T18:02:13Z",
"start_latitude": null,
"start_latlng": [],
"start_longitude": null,
"stats_visibility": [
{
"type": "heart_rate",
"visibility": "everyone"
},
{
"type": "pace",
"visibility": "everyone"
},
{
"type": "power",
"visibility": "everyone"
},
{
"type": "speed",
"visibility": "everyone"
},
{
"type": "calories",
"visibility": "everyone"
}
],
"timezone": "(GMT+01:00) Europe/Paris",
"total_elevation_gain": 0,
"total_photo_count": 0,
"trainer": false,
"type": "Ride",
"upload_id": null,
"utc_offset": 3600.0,
"visibility": "everyone",
"workout_type": null
}
Edited by freezed