Migrate getCourseStats
This guide covers transitioning from the v1 getCourseStats endpoint to the more efficient v2 consolidated endpoint.
Key changes
- Consolidation: The
getCoursesStats,getUserCourseStats,getUserCourses, andgetCourseStatsv1 endpoints are now merged into the single, more efficient List all courses statistics v2 endpoint.- Pagination: The v2 endpoint is paginated and returns 500 courses statistics per page.
Documentation links
Here are the links to the API reference for:
Endpoint mapping
Here's the direct correlation between the v1 and v2 endpoint URLs:
- API v1:
/api/v1/courses/:courseId/stats - API v2:
/api/v1/courses/stats
Behavior changes
Thanks to API v2 pagination mechanism, there is no more limitation on the number of statistics to be fetched through this endpoint.
Input changes
This section details the specific alterations to the input requirements between API versions.
API v1 input example
curl --location -g 'https://{{host}}/api/v1/courses/62e29a923c24c589a7f21aa5/stats?company={{company}}&apiKey={{apiKey}}'API v2 input example
curl --request GET \
--url 'https://app.staging.360learning-dev.com/api/v2/courses/stats?courseId[eq]=507f1f77bcf86cd799439011' \
--header '360-api-version: v2.0' \
--header 'accept: application/json'Main input differences
Change type | API v1 | API v2 |
|---|---|---|
Modified |
|
|
Removed |
| |
Removed |
| |
Modified |
|
|
Output changes
This section details the specific alterations to the successful output returned between API versions.
API v1 output example
[
{
"attempts": [
{
"_id": "62f244ffb4ccfd37306abbe7",
"progress": 9,
"completedAt": "2022-08-11T09:07:37.371Z",
"firstActivity": "2022-08-09T11:29:03.498Z",
"lastActivity": "2022-08-09T11:30:08.658Z",
"globalTime": 51190
},
{
"_id": "6307bb41627414ebe6fa4a96",
"progress": 100,
"score": 75,
"completedAt": "2022-08-25T18:11:55.650Z",
"firstActivity": "2022-08-25T18:11:14.238Z",
"lastActivity": "2022-08-25T18:11:55.628Z",
"path": "6307bb2f66977c8e2316d6d5",
"pathSession": "6307bb305ab5e0ebdb1138e8",
"globalTime": 41390
}
],
"user": {
"_id": "62bdbc00291a605543f24386",
"mail": "[email protected]"
}
}
]API v2 output example
[
{
"_id": "507f1f77bcf86cd799439011",
"versionNumber": 0,
"lang": "bg",
"firstActivityAt": "2025-06-30T13:23:56.059Z",
"lastActivityAt": "2025-06-30T13:23:56.059Z",
"timeSpent": 0,
"progress": 0,
"score": 0,
"completedAt": "2025-06-30T13:23:56.059Z",
"pathId": "507f1f77bcf86cd799439011",
"pathSessionId": "507f1f77bcf86cd799439011",
"courseId": "507f1f77bcf86cd799439011",
"userId": "507f1f77bcf86cd799439011"
}
]Main output differences
API v2 output has been flattened: no more sub-objects in the response body, you only get raw attempts.
API v2 introduces pagination for the List all courses statistics endpoint. Instead of returning all groups in a single response, it now returns a maximum of 500 course statistics per page. To retrieve subsequent pages, you need to follow the URL provided in the Link header of the response.
Change type | API v1 | API v2 |
|---|---|---|
Removed |
| |
Added |
| |
Added |
| |
Added |
| |
Modified |
|
|
Modified |
|
|
Modified |
|
|
Modified |
|
|
Updated 21 days ago
