API Documentation
Programmatically access exam results with our secure REST API endpoints
The CBT Host API allows authorized users to retrieve exam results for individual students or entire exams. All API access requires authentication via specific headers.
Retrieve a specific student's exam result using headers for authentication.
Retrieve all student results for a specific exam identified by its passcode in the URL.
All API requests require authentication using specific headers. The authentication method differs between endpoints.
Include the following headers in your API requests:
| Endpoint | Header | Description | Example | Required |
|---|---|---|---|---|
| Single Result | cbt-pass-code | Student's unique CBT pass code | cbthost-pssi-0069 | Required |
| Single Result | test-id | Identifier for the CBT test | solomonpolycap3@gmail.com | Required |
| Both Endpoints | Accept | Ensures JSON output | application/json | Required |
Important: Missing or invalid credentials will return a 401 Unauthorized response. For the Mass Results API, the passcode is included directly in the URL path instead of headers.
Retrieve a specific student's exam result using headers for authentication.
| Header | Description | Example | Required |
|---|---|---|---|
| cbt-pass-code | Student's unique CBT pass code | cbthost-pssi-0069 | Required |
| test-id | Identifier for the CBT test | solomonpolycap3@gmail.com | Required |
| Accept | Ensures JSON output | application/json | Required |
{
"status": "success",
"data": {
"cbt_test_id": "solomonpolycap3@gmail.com",
"cbt_test_info": "solomonpolycap3@gmail.com",
"cbt_pass_code": "cbthost-pssi-0069",
"cbt_total_score": 5
}
}
{
"serverstatus": 400,
"message": "Missing required headers: cbt_pass_code, test_id"
}
{
"serverstatus": 404,
"message": "cbt pass code is invalid, or no record found"
}
Retrieve all student results for a specific exam by including the passcode directly in the URL.
| Header | Description | Example | Required |
|---|---|---|---|
| Accept | Ensures JSON output | application/json | Required |
{
"status": "success",
"data": [
{
"cbt_pass_code": "cbthost-pssi-0069",
"cbt_test_id": "solomonpolycap3@gmail.com",
"cbt_total_score": 5
},
{
"cbt_pass_code": "cbthost-pssi-0070",
"cbt_test_id": "solomonpolycap3@gmail.com",
"cbt_total_score": 8
}
]
}
{
"status": "error",
"message": "No results found for this test ID"
}
Implementation examples in popular programming languages and tools
// Single Result API using Fetch
const fetchSingleResult = async () => {
const url = 'https://cbthost.com/api/result';
const response = await fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/json',
'cbt-pass-code': 'cbthost-pssi-0069',
'test-id': 'solomonpolycap3@gmail.com'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Student Result:', data);
};
// Mass Results API using Fetch
const fetchMassResults = async () => {
const passcode = 'cbthost-pssi-0069';
const url = `https://cbthost.com/api/result/${passcode}`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Mass Results:', data);
};
// Call the functions
fetchSingleResult();
fetchMassResults();
Tools and resources to help you integrate with our API
Our support team is ready to assist you with API integration