curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/assignments' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_assignments(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/assignments"
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:
assignments = get_user_assignments("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
for assignment in assignments['assignments']:
course = assignment['course']
print(f"Course: {course['name']}")
print(f"Progress: {assignment['progressValue']}%")
print(f"Status: {'Completed' if assignment['isCourseFinished'] else 'In Progress'}")
print("---")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserAssignments(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/assignments`,
{
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
getUserAssignments('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(data => {
data.assignments.forEach(assignment => {
console.log(`Course: ${assignment.course.name}`);
console.log(`Progress: ${assignment.progressValue}%`);
console.log(`Status: ${assignment.isCourseFinished ? 'Completed' : 'In Progress'}`);
console.log('---');
});
})
.catch(error => console.error('Error:', error.message));
{
"assignments": [
{
"assignedAt": 1443183322,
"startedAt": 1443188932,
"deadlineAt": 1444188932,
"finishedAt": 1443188946,
"progressValue": 100,
"resultValue": 50,
"isCourseStarted": true,
"isCourseFinished": true,
"isExpired": false,
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Learn the basics of sales",
"isDraft": false,
"createdAt": 1507807711,
"updatedAt": 1507808372,
"publishedAt": 1508225229,
"image": null
}
}
]
}
{
"status": 404,
"message": "Not found"
}
Users
Get User Assignments
Get a list of courses assigned to the user
GET
/
users
/
{userId}
/
assignments
curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/assignments' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_assignments(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/assignments"
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:
assignments = get_user_assignments("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
for assignment in assignments['assignments']:
course = assignment['course']
print(f"Course: {course['name']}")
print(f"Progress: {assignment['progressValue']}%")
print(f"Status: {'Completed' if assignment['isCourseFinished'] else 'In Progress'}")
print("---")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserAssignments(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/assignments`,
{
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
getUserAssignments('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(data => {
data.assignments.forEach(assignment => {
console.log(`Course: ${assignment.course.name}`);
console.log(`Progress: ${assignment.progressValue}%`);
console.log(`Status: ${assignment.isCourseFinished ? 'Completed' : 'In Progress'}`);
console.log('---');
});
})
.catch(error => console.error('Error:', error.message));
{
"assignments": [
{
"assignedAt": 1443183322,
"startedAt": 1443188932,
"deadlineAt": 1444188932,
"finishedAt": 1443188946,
"progressValue": 100,
"resultValue": 50,
"isCourseStarted": true,
"isCourseFinished": true,
"isExpired": false,
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Learn the basics of sales",
"isDraft": false,
"createdAt": 1507807711,
"updatedAt": 1507808372,
"publishedAt": 1508225229,
"image": null
}
}
]
}
{
"status": 404,
"message": "Not found"
}
Retrieve a list of all courses assigned to a specific user.
Request Headers
API Key. Go to your Konstantly site > Settings > API and copy the value from there.
URL Parameters
User API ID
Response
Array of course assignments
Show Assignment properties
Show Assignment properties
Timestamp when course was assigned
Timestamp when user started the course
Timestamp when assignment expires
Timestamp when user finished the course
Current progress (0-100)
Course result (0-100)
Whether user has started the course
Whether user has finished the course
Whether assignment has expired
Course details
Show Course properties
Show Course properties
Course ID
Course name
Course annotation
Draft status
Creation timestamp
Last update timestamp
Publication timestamp
Course cover image
Error Responses
curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/assignments' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
def get_user_assignments(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/assignments"
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:
assignments = get_user_assignments("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
for assignment in assignments['assignments']:
course = assignment['course']
print(f"Course: {course['name']}")
print(f"Progress: {assignment['progressValue']}%")
print(f"Status: {'Completed' if assignment['isCourseFinished'] else 'In Progress'}")
print("---")
except Exception as e:
print(f"Error: {str(e)}")
const axios = require('axios');
async function getUserAssignments(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/assignments`,
{
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
getUserAssignments('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(data => {
data.assignments.forEach(assignment => {
console.log(`Course: ${assignment.course.name}`);
console.log(`Progress: ${assignment.progressValue}%`);
console.log(`Status: ${assignment.isCourseFinished ? 'Completed' : 'In Progress'}`);
console.log('---');
});
})
.catch(error => console.error('Error:', error.message));
{
"assignments": [
{
"assignedAt": 1443183322,
"startedAt": 1443188932,
"deadlineAt": 1444188932,
"finishedAt": 1443188946,
"progressValue": 100,
"resultValue": 50,
"isCourseStarted": true,
"isCourseFinished": true,
"isExpired": false,
"course": {
"id": 123,
"name": "Introduction to Sales",
"annotation": "Learn the basics of sales",
"isDraft": false,
"createdAt": 1507807711,
"updatedAt": 1507808372,
"publishedAt": 1508225229,
"image": null
}
}
]
}
{
"status": 404,
"message": "Not found"
}
Was this page helpful?
⌘I