You can get a test report using following API endpoint:
https://api.hackerearth.com/partner/hackerearth/events/report/
The client authentication is done using your unique client_id and client_secret.
You can refer to your Dashboard settings, for client_id and client_secret under API details.
Type: String
Description: client_id is a 67 character random key that serves as an identification for a particular client and must be provided when communicating with the API as a parameter to the API endpoint.
Example: d8a20ae8e475209er4b1faa72ede88a174423cc2029c.api.hackerearth.com
Type: String
Description: client_secret is a 40 character random key that serves as an identification for a particular client and must be provided when communicating with the API as a parameter to the API endpoint.
Example: 2b0ff29f4f8751487540604cdab5611e6135f41c
Test reports are accessible only for published test.
client_id, client_secret and test_id are the required parameters for making request to this API endpoint.
All the requests to the API must be made using POST request method.
client_id and client_secret are explained above.
Type: Integer
Description: test_id is a unique integer for your test. Refer to this article for a better understanding. In this article, Recruiter API ID is the test_id.
Example: 5841
Sample request using python
#!/usr/bin/env python
import requests
CLIENT_ID = "d8a20ae8e475209e0eb1faa72ede88a174423cc2029c.api.hackerearth.com"
CLIENT_SECRET = "2b0ff29f4f8751487450604cdab5611e6135f41c"
TEST_ID = 53
payload = {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'test_id': TEST_ID
}
r = requests.post("https://api.hackerearth.com/partner/hackerearth/events/report/", data=json.dumps(payload))
print r.json()
Using cURL
curl --data '{"client_id":"d8a20ae8e475209e0eb1faa72ede88a174423cc2029c.api.hackerearth.com","client_secret":"2b0ff29f4f8751487450604cdab5611e6135f41c","test_id":20}' https://api.hackerearth.com/partner/hackerearth/events/report/
Response returned will be in JSON format.
Sample response
{
"report": {
"currently_taking": {
"status": "success",
"details": [
{
"phone_number": "1234567890",
"start_datetime": "04-02-2020 13:41:48 UTC",
"resume": null,
"candidate_name": "alice",
"candidate_total_score": 4.0,
"email": "alice@bob.com",
"candidate_id": null,
"percentage": 4,
"time_taken": "0:33:25"
}
]
},
"compeleted_test": {
"status": "success",
"details": [
{
"phone_number": null,
"start_datetime": "12-08-2019 09:46:34 UTC",
"resume": null,
"candidate_name": "alice23",
"candidate_total_score": 12.0,
"email": "alice23@bob.com",
"candidate_id": null,
"finish_datetime": "12-08-2019 09:47:03 UTC",
"percentage": 3,
"time_taken": "0:00:29"
}
]
}
},
"message": "success",
"ecode": [],
"emessage": [],
"mcode": "success"
}
Type : String
Description: Message code abbreviated as mcode.
Type: String
Description: A message for user regarding the success of request.
message and mcode are related to each other according to the following table:
mcode | message |
---|---|
SUCCESS | Request successful |
FAILED | Request failed |
Type: List
Description: Error codes abbreviated as ecode.
Type: List
Description: A message explaining the error occurred during request processing.
emessage and ecode are related to each other according to the following table:
ecode | emessage |
---|---|
AUTHFAILED | Authentication Failed |
ARGMISSING | Request argument missing |
MUSTBEINT | Test ID must be integer |
TESTNOTFOUND | Test not found |
NOREPORT | No report exist. |
LIMITEXCEEDED | Client exceeded its request limit. Please contact support@hackerearth.com. |
RATELIMITEXCEEDED | The rate at which the API requests are made has reached. Please try again after one minute. |
Type: Dictionary (JSON)
Description: This JSON will contain two dictionary type fields currently_taking and compeleted_test. Each of them contains a details field which is a list of reports of all the candidates who are currently taking the test and who have already completed the test respectively.
Candidate's personal details like resume and candidate_id will be set in response, if these fields were marked in Candidate Settings under Test Settings section and candidate has filled these details, otherwise, the value of these will be null.
If you have provided wrong client_id or client_secret, the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"AUTHFAILED"
],
"emessage": [
"Authentication Failed"
],
"mcode": "FAILED"
}
If mandatory POST arguments are not provided, the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"ARGMISSING"
],
"emessage": [
"Request argument missing: 'test_id'"
],
"mcode": "FAILED"
}
If the type of test_id is not integer, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"MUSTBEINT"
],
"emessage": [
"Test ID must be integer"
],
"mcode": "FAILED"
}
If wrong test_id is provided or the test has already been deleted, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"TESTNOTFOUND"
],
"emessage": [
"Test not found"
],
"mcode": "FAILED"
}
If user is not authorized to access the test, the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"ACCESSERROR"
],
"emessage": [
"You are not authorized to access this feature. Please contact support@hackerearth.com."
],
"mcode": "FAILED"
}
If the limit of API requests (15000 requests) is reached, then the JSON response that is returned is as follows:
{
"message": "Request failed",
"ecode": [
"LIMITEXCEEDED"
],
"emessage": [
"The limit of the API requests has been reached. Contact support@hackerearth.com."
],
"mcode": "FAILED"
}
If the rate (60 per min or 10000 per day) at which API requests are made by a specific user is reached, then the JSON response that is returned is as follows:
{
"message": "Request failed",
"ecode": [
"RATELIMITEXCEEDED"
],
"emessage": [
"The rate at which the API requests are made has reached. Please try again after some time."
],
"mcode": "FAILED"
}
If no candidates have taken the test, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"NOREPORT"
],
"emessage": [
"No report exist."
],
"mcode": "FAILED"
}
If any other issue occurred do reach us out at api@hackerearth.com