---
updatedAt: 2026-04-23T15:43:35.000Z
agentTools:
  projectIndex: https://360learning.readme.io/llms.txt
---

# Migrate getCoursesStats

This guide covers transitioning from the v1 `getCoursesStats` endpoint to the more efficient v2 consolidated endpoint.

<Callout icon="💡" theme="default">
  ### Key changes

  * **Consolidation:** The `getCoursesStats`, `getUserCourseStats`, `getUserCourses`, and `getCourseStats` v1 endpoints are now merged into the single, more efficient [List all courses statistics](https://360learning.readme.io/reference/v2coursesgetallcoursestatscontroller_getallcoursestats) v2 endpoint.
  * **Pagination:** The v2 endpoint is paginated and returns 500 courses statistics per page.
</Callout>

### Documentation links

Here are the links to the API reference for:

* [API v1](https://api.360learning.com/#09c434d1-a263-4bef-a81e-e2d6edc6dde2)
* [API v2](https://360learning.readme.io/reference/v2coursesgetallcoursestatscontroller_getallcoursestats)

### Endpoint mapping

Here's the direct correlation between the v1 and v2 endpoint URLs:

* API v1: `/api/v2/courses/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

```Text Shell
curl --location -g 'https://{{host}}/api/v1/courses/stats?company={{company}}&apiKey={{apiKey}}'
```

#### API v2 input example

```Text Shell
curl --request GET \
     --url https://app.staging.360learning-dev.com/api/v2/courses/stats \
     --header '360-api-version: v2.0' \
     --header 'accept: application/json'
```

#### Main input differences

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Change type
      </th>

      <th>
        API v1
      </th>

      <th>
        API v2
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Query parameters
      </td>

      <td>
        `createdAtBefore` / `createdAtAfter` (Optional): Timestamp filters, in the format`YYYY-MM-DDTHH:mm:ss.sssZ`.
      </td>

      <td>
        `completedAt` (Optional): Modified name, functionality, syntax, and date format. Now, this single filter combines the functionalities of `completedAtBefore` and `completedAtAfter`. It filters courses by completion date range using the LHS bracket notation. The date format is now `YYYY-MM-DD`.
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-removed">Removed</span><br />Query parameters
      </td>

      <td>
        `firstActivityAtBefore` / `firstActivityAtAfter` (Optional): Removed and not replaced in v2.
      </td>

      <td>
        * <br />
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-removed">Removed</span><br />Query parameters
      </td>

      <td>
        `lastActivityAtBefore` / `lasstActivityAtAfter` (Optional): Removed and not replaced in v2.
      </td>

      <td>
        * <br />
      </td>
    </tr>
  </tbody>
</Table>

### Output changes

This section details the specific alterations to the successful output returned between API versions.

#### API v1 output example

```Text JSON
[
  {
    "course": {
      "_id": "62e29a923c24c589a7f21aa5",
      "name": "Welcome to the team!"
    },
    "stats": [
      {
        "attempts": [
          {
            "_id": "63a430d158dedd7933ef84c1",
            "progress": 0,
            "firstActivity": "2022-12-22T10:26:25.648Z",
            "lastActivity": "2022-12-22T10:45:26.896Z",
            "path": "639af419b8a1da7e76278f4e",
            "pathSession": "63a430ae7901ab0524815225",
            "globalTime": 1133849
          }
        ],
        "user": {
          "_id": "62bdbc00291a605543f24386",
          "mail": "mister.crabs@360learning.com"
        }
      }
    ]
  }
]
```

#### API v2 output example

```Text JSON
[
  {
    "_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](https://360learning.readme.io/reference/v2coursesgetallcoursestatscontroller_getallcoursestats) endpoint. Instead of returning all stats 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.

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Change type
      </th>

      <th>
        API v1
      </th>

      <th>
        API v2
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <span class="param-removed">Removed</span><br />Output property
      </td>

      <td>
        `course.name`: Removed and not replaced in v2.
      </td>

      <td>
        * <br />
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-removed">Removed</span><br />Output property
      </td>

      <td>
        `user.mail`: Removed and not replaced in v2.
      </td>

      <td>
        * <br />
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-added">Added</span><br />Output property
      </td>

      <td>
        * <br />
      </td>

      <td>
        `score` : (Optional) Score of the attempt (if applicable)
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-added">Added</span><br />Output property
      </td>

      <td>
        * <br />
      </td>

      <td>
        `lang` : (Optional) Language of the course attempted by the learner (if applicable)
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-added">Added</span><br />Output property
      </td>

      <td>
        * <br />
      </td>

      <td>
        `versionNumber` : (Optional) Version of the course attempted by the learner (if applicable)
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Output property
      </td>

      <td>
        `course._id`: Course unique identifier.
      </td>

      <td>
        `courseId`: (Required) Course unique identifier.
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Output property
      </td>

      <td>
        `user._id`: User unique identifier.
      </td>

      <td>
        `userId`: (Required) User unique identifier.
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Output property
      </td>

      <td>
        `path`: Path unique identifier.
      </td>

      <td>
        `pathId`: (Optional) Path unique identifier.
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Output property
      </td>

      <td>
        `pathSession`: Path session unique identifier.
      </td>

      <td>
        `pathSessionId`: (Optional) Path session unique identifier.
      </td>
    </tr>

    <tr>
      <td>
        <span class="param-modified">Modified</span><br />Output property
      </td>

      <td>
        `globalTime`: Time spent (in millis) by the learner on this attempt.
      </td>

      <td>
        `timeSpent`: (Required) Time spent (in millis) by the learner on this attempt.
      </td>
    </tr>
  </tbody>
</Table>