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
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
array
required
Array of course assignments
Show Assignment properties
Show Assignment properties
integer
required
Timestamp when course was assigned
integer
required
Timestamp when user started the course
integer
required
Timestamp when assignment expires
integer
required
Timestamp when user finished the course
integer
required
Current progress (0-100)
integer
required
Course result (0-100)
boolean
required
Whether user has started the course
boolean
required
Whether user has finished the course
boolean
required
Whether assignment has expired
Error Responses
object
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