You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ahref="https://cloud.layer5.io/system/api/docs">Open API Endpoints in new window <iclass="fa fa-external-link"aria-hidden="true"></i></a>
31
+
<ahref="https://cloud.layer5.io/system/api/docs"target="_blank">Open API Endpoints in new window <iclass="fa fa-external-link"aria-hidden="true"></i></a>
32
32
{{< /alert >}}
33
+
34
+
## API Example
35
+
36
+
The following example demonstrate how to retrieve information from the Academy REST APIs.
37
+
38
+
### Get the total number of registered learners in Academy
39
+
40
+
Use the Layer5 Cloud API to retrieve the *total* number of registered learners. Pass your [Security Token](https://docs.layer5.io/cloud/security/tokens/) as a Bearer token in the `Authorization` header (as shown in [Authenticating with API](/cloud/reference/api-reference/#authenticating-with-the-api)). The response JSON includes an array of user objects.
41
+
42
+
43
+
{{< tabpane >}}
44
+
{{< tab header="cURL" >}}
45
+
curl -s -X GET "https://cloud.layer5.io/api/academy/cirricula" \
46
+
-H "Authorization: Bearer <Your-Token>" \
47
+
| jq '[.data[].registration_count] | add'
48
+
49
+
{{< /tab >}}
50
+
51
+
{{< tab header="JavaScript" >}}
52
+
53
+
const token = "Your-Token"
54
+
55
+
async function getTotalLearners() {
56
+
const res = await fetch("https://cloud.layer5.io/api/academy/cirricula", {
57
+
headers: { Authorization: `Bearer ${token}` },
58
+
});
59
+
const data = await res.json();
60
+
const total = data.data.reduce((sum, path) => sum + path.registration_count, 0);
0 commit comments