curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/statistics' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_statistics(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/statistics"
headers = {"X-API-KEY": api_key}
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
return response.json()
# Example usage
try:
stats = get_user_statistics("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
# Print general statistics
print("Course Statistics:")
print(f"Started: {stats['courses']['startedCoursesCount']}")
print(f"Finished: {stats['courses']['finishedCoursesCount']}")
print(f"Average Result: {stats['courses']['averageResultValue']}%")
# Print in-progress courses
print("\nIn Progress Courses:")
for course in stats['started']:
print(f"Course: {course['course']['name']}")
print(f"Progress: {course['progressValue']}%")
print(f"Current Element: {course['courseElement']['name']}")
print("---")
# Print tag performance
print("\nPerformance by Tag:")
for tag in stats['tags']:
print(f"{tag['tag']}: {tag['resultValue']}%")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserStatistics(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/statistics`,
{
headers: {
'X-API-KEY': apiKey
}
}
);
return response.data;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
getUserStatistics('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(stats => {
// Print general statistics
console.log('Course Statistics:');
console.log(`Started: ${stats.courses.startedCoursesCount}`);
console.log(`Finished: ${stats.courses.finishedCoursesCount}`);
console.log(`Average Result: ${stats.courses.averageResultValue}%`);
// Print in-progress courses
console.log('\nIn Progress Courses:');
stats.started.forEach(course => {
console.log(`Course: ${course.course.name}`);
console.log(`Progress: ${course.progressValue}%`);
console.log(`Current Element: ${course.courseElement.name}`);
console.log('---');
});
// Print tag performance
console.log('\nPerformance by Tag:');
stats.tags.forEach(tag => {
console.log(`${tag.tag}: ${tag.resultValue}%`);
});
})
.catch(error => console.error('Error:', error.message));
{
"courses": {
"sharedCoursesCount": 5,
"assignedCoursesCount": 10,
"startedCoursesCount": 8,
"finishedCoursesCount": 6,
"averageResultValue": 85
},
"virgin": [
{
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Basic sales concepts",
"isDraft": false
},
"deadlineAt": 1704067200
}
],
"started": [
{
"course": {
"id": 124,
"name": "Advanced Sales Techniques",
"annotation": "Advanced sales strategies",
"isDraft": false
},
"progressValue": 75,
"courseElement": {
"id": 456,
"name": "Customer Psychology",
"type": "page"
},
"updatedAt": 1673531200,
"deadlineAt": 1704067200,
"isCourseStarted": true,
"isCourseFinished": false
}
],
"results": {
"0": 2,
"1-10": 0,
"11-20": 1,
"21-30": 0,
"31-40": 1,
"41-50": 0,
"51-60": 1,
"61-70": 2,
"71-80": 1,
"81-90": 1,
"91-99": 0,
"100": 1
},
"tags": [
{
"tagId": 1,
"tag": "Sales",
"resultValue": 85
},
{
"tagId": 2,
"tag": "Communication",
"resultValue": 90
}
]
}
{
"status": 404,
"message": "Not found"
}
Users
Get User Statistics
Get detailed statistics for a specific user
GET
/
users
/
{userId}
/
statistics
curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/statistics' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_statistics(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/statistics"
headers = {"X-API-KEY": api_key}
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
return response.json()
# Example usage
try:
stats = get_user_statistics("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
# Print general statistics
print("Course Statistics:")
print(f"Started: {stats['courses']['startedCoursesCount']}")
print(f"Finished: {stats['courses']['finishedCoursesCount']}")
print(f"Average Result: {stats['courses']['averageResultValue']}%")
# Print in-progress courses
print("\nIn Progress Courses:")
for course in stats['started']:
print(f"Course: {course['course']['name']}")
print(f"Progress: {course['progressValue']}%")
print(f"Current Element: {course['courseElement']['name']}")
print("---")
# Print tag performance
print("\nPerformance by Tag:")
for tag in stats['tags']:
print(f"{tag['tag']}: {tag['resultValue']}%")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserStatistics(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/statistics`,
{
headers: {
'X-API-KEY': apiKey
}
}
);
return response.data;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
getUserStatistics('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(stats => {
// Print general statistics
console.log('Course Statistics:');
console.log(`Started: ${stats.courses.startedCoursesCount}`);
console.log(`Finished: ${stats.courses.finishedCoursesCount}`);
console.log(`Average Result: ${stats.courses.averageResultValue}%`);
// Print in-progress courses
console.log('\nIn Progress Courses:');
stats.started.forEach(course => {
console.log(`Course: ${course.course.name}`);
console.log(`Progress: ${course.progressValue}%`);
console.log(`Current Element: ${course.courseElement.name}`);
console.log('---');
});
// Print tag performance
console.log('\nPerformance by Tag:');
stats.tags.forEach(tag => {
console.log(`${tag.tag}: ${tag.resultValue}%`);
});
})
.catch(error => console.error('Error:', error.message));
{
"courses": {
"sharedCoursesCount": 5,
"assignedCoursesCount": 10,
"startedCoursesCount": 8,
"finishedCoursesCount": 6,
"averageResultValue": 85
},
"virgin": [
{
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Basic sales concepts",
"isDraft": false
},
"deadlineAt": 1704067200
}
],
"started": [
{
"course": {
"id": 124,
"name": "Advanced Sales Techniques",
"annotation": "Advanced sales strategies",
"isDraft": false
},
"progressValue": 75,
"courseElement": {
"id": 456,
"name": "Customer Psychology",
"type": "page"
},
"updatedAt": 1673531200,
"deadlineAt": 1704067200,
"isCourseStarted": true,
"isCourseFinished": false
}
],
"results": {
"0": 2,
"1-10": 0,
"11-20": 1,
"21-30": 0,
"31-40": 1,
"41-50": 0,
"51-60": 1,
"61-70": 2,
"71-80": 1,
"81-90": 1,
"91-99": 0,
"100": 1
},
"tags": [
{
"tagId": 1,
"tag": "Sales",
"resultValue": 85
},
{
"tagId": 2,
"tag": "Communication",
"resultValue": 90
}
]
}
{
"status": 404,
"message": "Not found"
}
Retrieve comprehensive statistics about a user’s learning activities, including course progress, test results, and performance metrics.
Request Headers
string
required
API Key. Go to your Konstantly site > Settings > API and copy the value from there.
URL Parameters
string
required
User API ID
Response
object
required
General course statistics
Show Course statistics properties
Show Course statistics properties
integer
required
Number of courses created by user
integer
required
Number of courses published by user
integer
required
Number of courses shared with user
integer
required
Number of courses assigned to user
integer
required
Number of courses started by user
integer
required
Number of courses completed by user
integer
required
Average progress across all courses
array
required
array
required
Array of started courses
Show Started course properties
Show Started course properties
object
required
Course information
integer
required
Current progress (0-100)
object
required
integer
required
Last progress update timestamp
integer
required
Assignment deadline timestamp
boolean
required
Course start status
boolean
required
Course completion status
object
required
Distribution of course results
Show Results properties
Show Results properties
integer
Number of courses with 0% result
integer
Courses with 1-10% result
integer
Courses with 11-20% result
integer
Courses with 21-30% result
integer
Courses with 31-40% result
integer
Courses with 41-50% result
integer
Courses with 51-60% result
integer
Courses with 61-70% result
integer
Courses with 71-80% result
integer
Courses with 81-90% result
integer
Courses with 91-99% result
integer
Number of courses with 100% result
array
required
Error Responses
object
curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/statistics' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_statistics(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/statistics"
headers = {"X-API-KEY": api_key}
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
return response.json()
# Example usage
try:
stats = get_user_statistics("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
# Print general statistics
print("Course Statistics:")
print(f"Started: {stats['courses']['startedCoursesCount']}")
print(f"Finished: {stats['courses']['finishedCoursesCount']}")
print(f"Average Result: {stats['courses']['averageResultValue']}%")
# Print in-progress courses
print("\nIn Progress Courses:")
for course in stats['started']:
print(f"Course: {course['course']['name']}")
print(f"Progress: {course['progressValue']}%")
print(f"Current Element: {course['courseElement']['name']}")
print("---")
# Print tag performance
print("\nPerformance by Tag:")
for tag in stats['tags']:
print(f"{tag['tag']}: {tag['resultValue']}%")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserStatistics(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/statistics`,
{
headers: {
'X-API-KEY': apiKey
}
}
);
return response.data;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
getUserStatistics('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(stats => {
// Print general statistics
console.log('Course Statistics:');
console.log(`Started: ${stats.courses.startedCoursesCount}`);
console.log(`Finished: ${stats.courses.finishedCoursesCount}`);
console.log(`Average Result: ${stats.courses.averageResultValue}%`);
// Print in-progress courses
console.log('\nIn Progress Courses:');
stats.started.forEach(course => {
console.log(`Course: ${course.course.name}`);
console.log(`Progress: ${course.progressValue}%`);
console.log(`Current Element: ${course.courseElement.name}`);
console.log('---');
});
// Print tag performance
console.log('\nPerformance by Tag:');
stats.tags.forEach(tag => {
console.log(`${tag.tag}: ${tag.resultValue}%`);
});
})
.catch(error => console.error('Error:', error.message));
{
"courses": {
"sharedCoursesCount": 5,
"assignedCoursesCount": 10,
"startedCoursesCount": 8,
"finishedCoursesCount": 6,
"averageResultValue": 85
},
"virgin": [
{
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Basic sales concepts",
"isDraft": false
},
"deadlineAt": 1704067200
}
],
"started": [
{
"course": {
"id": 124,
"name": "Advanced Sales Techniques",
"annotation": "Advanced sales strategies",
"isDraft": false
},
"progressValue": 75,
"courseElement": {
"id": 456,
"name": "Customer Psychology",
"type": "page"
},
"updatedAt": 1673531200,
"deadlineAt": 1704067200,
"isCourseStarted": true,
"isCourseFinished": false
}
],
"results": {
"0": 2,
"1-10": 0,
"11-20": 1,
"21-30": 0,
"31-40": 1,
"41-50": 0,
"51-60": 1,
"61-70": 2,
"71-80": 1,
"81-90": 1,
"91-99": 0,
"100": 1
},
"tags": [
{
"tagId": 1,
"tag": "Sales",
"resultValue": 85
},
{
"tagId": 2,
"tag": "Communication",
"resultValue": 90
}
]
}
{
"status": 404,
"message": "Not found"
}
Was this page helpful?
⌘I