Activities¶
-
GET
/api/activities
¶ Get activities for the authenticated user.
Example requests:
without parameters
GET /api/activities/ HTTP/1.1
with some query parameters
GET /api/activities?from=2019-07-02&to=2019-07-31&sport_id=1 HTTP/1.1
Example responses:
returning at least one activity
HTTP/1.1 200 OK Content-Type: application/json { "data": { "activities": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "id": 1, "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_activity": 3, "notes": null, "pauses": null, "previous_activity": null, "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 4, "record_type": "MS", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 3, "record_type": "LD", "sport_id": 1, "user_id": 1, "value": "0:17:04" }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 2, "record_type": "FD", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 1, "record_type": "AS", "sport_id": 1, "user_id": 1, "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, "user_id": 1, "weather_end": null, "weather_start": null, "with_gpx": false } ] }, "status": "success" }
returning no activities
HTTP/1.1 200 OK Content-Type: application/json { "data": { "activities": [] }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id
- Query Parameters
page (integer) – page if using pagination (default: 1)
per_page (integer) – number of activities per page (default: 5)
sport_id (integer) – sport id
from (string) – start date (format:
%Y-%m-%d
)to (string) – end date (format:
%Y-%m-%d
)distance_from (float) – minimal distance
distance_to (float) – maximal distance
duration_from (string) – minimal duration (format:
%H:%M
)duration_to (string) – maximal distance (format:
%H:%M
)ave_speed_from (float) – minimal average speed
ave_speed_to (float) – maximal average speed
max_speed_from (float) – minimal max. speed
max_speed_to (float) – maximal max. speed
order (string) – sorting order (default:
desc
)
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
200 OK – no error
401 Unauthorized – invalid token
-
GET
/api/activities/
(int: activity_id)¶ Get an activity
Example request:
GET /api/activities/3 HTTP/1.1
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "activities": [ { "activity_date": "Sun, 07 Jul 2019 07:00:00 GMT", "ascent": null, "ave_speed": 16, "bounds": [], "creation_date": "Sun, 14 Jul 2019 18:57:14 GMT", "descent": null, "distance": 12, "duration": "0:45:00", "id": 5, "map": null, "max_alt": null, "max_speed": 16, "min_alt": null, "modification_date": "Sun, 14 Jul 2019 18:57:22 GMT", "moving": "0:45:00", "next_activity": 4, "notes": "activity without gpx", "pauses": null, "previous_activity": 3, "records": [], "segments": [], "sport_id": 1, "title": "biking on sunday morning", "user_id": 1, "weather_end": null, "weather_start": null, "with_gpx": false } ] }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id
activity_id (integer) – activity id
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
200 OK – No error
401 Unauthorized – Provide a valid auth token
403 Forbidden – You do not have permissions
404 Not Found – Activity not found
-
POST
/api/activities
¶ Post an activity with a gpx file
Example request:
POST /api/activities/ HTTP/1.1 Content-Type: multipart/form-data
Example response:
HTTP/1.1 201 CREATED Content-Type: application/json { "data": { "activities": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "id": 1, "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_activity": 3, "notes": null, "pauses": null, "previous_activity": null, "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 4, "record_type": "MS", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 3, "record_type": "LD", "sport_id": 1, "user_id": 1, "value": "0:17:04" }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 2, "record_type": "FD", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 1, "record_type": "AS", "sport_id": 1, "user_id": 1, "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, "user_id": 1, "weather_end": null, "weather_start": null, "with_gpx": false } ] }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id
- Form Parameters
file – gpx file
data – sport id and notes (example:
{"sport_id": 1, "notes": ""}
)
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
201 Created – activity created
400 Bad Request – invalid payload
401 Unauthorized – invalid token
-
POST
/api/activities/no_gpx
¶ Post an activity without gpx file
Example request:
POST /api/activities/ HTTP/1.1 Content-Type: application/json
Example response:
HTTP/1.1 201 CREATED Content-Type: application/json { "data": { "activities": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "id": 1, "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_activity": 3, "notes": null, "pauses": null, "previous_activity": null, "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 4, "record_type": "MS", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 3, "record_type": "LD", "sport_id": 1, "user_id": 1, "value": "0:17:04" }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 2, "record_type": "FD", "sport_id": 1, "user_id": 1, "value": 10.0 }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", "activity_id": 1, "id": 1, "record_type": "AS", "sport_id": 1, "user_id": 1, "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, "user_id": 1, "weather_end": null, "weather_start": null, "with_gpx": false } ] }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id
- Request JSON Object
activity_date (string) – activity date (format:
%Y-%m-%d %H:%M
)distance (float) – activity distance in km
duration (integer) – activity duration in seconds
notes (string) – notes
sport_id (integer) – activity sport id
title (string) – activity title
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
201 Created – activity created
400 Bad Request – invalid payload
401 Unauthorized – invalid token
-
PATCH
/api/activities/
(int: activity_id)¶ Update an activity
-
DELETE
/api/activities/
(int: activity_id)¶ Delete an activity
-
GET
/api/activities/
(int: activity_id)/gpx
¶ Get gpx file for an activity
-
GET
/api/activities/
(int: activity_id)/chart_data
¶ Get chart data from an activity gpx file