Events List


You can get list of tests using following API endpoint:

 https://api.hackerearth.com/partner/hackerearth/events-list/

Authentication

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.

client_id

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

client_secret

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


Making requests

Only the private Invite-Only tests which have been published and were created by the admin (whose client id and secret are passed in the request) will get listed out when this API is requested.

client_id and client_secret are the required parameters for making request to this API endpoint. These have been explained above. filters, page_number and page_size are optional parameters which are explained below.

All the requests to the API must be made using POST request method.

filters (Optional)

Type: Dictionary

Description: This field can accept five type of filters ids, start_datetime, end_datetime, creation_datetime and event_type.

The field idsaccepts list of test ids (integer).

start_datetime, end_datetime and creation_datetime are date-range fields that accept two attributes: min and max, that should be in ISO8601 date format. A date-range field should have at-least one of the two attributes.

Combination of above filters is supported.

Example:

{
    "ids": [850266, 626315],
    "event_type": "invite_only",
    "start_datetime":
    {
        "min": "2019-07-31T21:25:02+05:30",
        "max": "2019-08-02T23:25:02+05:30"
    },
    "end_datetime":
    {
        "min": "2019-07-31T22:25:02+05:30",
        "max": "2019-08-02T23:25:02+05:30"
    },
    "creation_datetime":
    {
        "min": "2019-07-31T20:25:02+05:30",
        "max": "2019-08-02T23:25:02+05:30"
    },
}

page_number (Optional)

Type: Integer

Description: page_number is a valid page number for paginated events list. If this field is not provided, then by default the page_number will be 1

page_size (Optional)

Type: Integer

Description: page_size is a valid page size for paginated events list. If this field is not provided, then by default page_size will be 25. The maximum permitted value for page_size is 50.

event_type (Optional)

Type: String

Description: event_type is a valid event type for example invite_only, public, all. If this field is not provided, then by default event_type will be invite_only.

Sample request using python

    #!/usr/bin/env python

    import json
    import requests

    CLIENT_ID = "abcdefghijklm123456789nopqrstuvwxyz.api.hackerearth.com"
    CLIENT_SECRET = "abcdefghijklm123456789nopqrstuvwxyz"
    FILTERS = {
    "ids": [850266,626315],
            "start_datetime":
            {
                "min": "2018-08-01T21:25:02+05:30",
                "max": "2019-08-21T23:25:02+05:30"
            },
            "end_datetime":
            {
                "min": "2018-08-01T22:25:02+05:30",
                "max": "2019-08-21T23:25:02+05:30"
            },
            "creation_datetime":
            {
                "min": "2018-08-01T20:25:02+05:30",
                "max": "2019-08-21T10:25:02+05:30"
            },
            "event_type": "invite_only"
          }
PAGE_NUMBER = 1
PAGE_SIZE = 5

payload = {
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'filters': FILTERS,
    'page_number': PAGE_NUMBER,
    'page_size': PAGE_SIZE
}
r = requests.post("https://api.hackerearth.com/partner/hackerearth/events-list/", data=json.dumps(payload))
print r.json()

Using cURL

curl --data '{
"client_id": "abcdefghijklm123456789nopqrstuvwxyz.api.hackerearth.com",
"client_secret": "abcdefghijklm123456789nopqrstuvwxyz",
"filters": {
            "ids": [850266, 626315],
            "start_datetime":
            {
                "min": "2018-08-01T21:25:02+05:30",
                "max": "2019-08-21T23:25:02+05:30"
             },
            "end_datetime":
            {
                "min": "2018-08-01T22:25:02+05:30",
                "max": "2019-08-21T23:25:02+05:30"
            },
            "creation_datetime":
            {
                "min": "2018-08-01T20:25:02+05:30",
                "max": "2019-08-21T10:25:02+05:30"
            },
            "event_type": "invite_only"
           },
"page_number": 1,
"page_size": 5
}' https://api.hackerearth.com/partner/hackerearth/events-list/


Response

Response returned will be in JSON format.

Sample response

{
   "mcode": "success"
   "message": "success",
   "ecode": [],
   "emessage": [],
   "has_more": false,
   "events": [
       {
           "start_datetime": "2019-08-19T07:47:00-05:51",
           "creation_datetime": "2019-08-19T07:47:00-05:51",
           "end_datetime": "2019-08-21T23:25:02+05:30",
           "id": 850266,
           "title": "Algorithms",
           "slug": "algorithms-test-212",
           "duration": 5400.0,
           "cutoff_score": 47.0,
           "skills_at_creation": ["AWS", "Python"],
           "job_role": "jr python 1",
           "test_description": null,
           "tags": "Python",
           "skills": ["algorithms", "Data structures"],
           "problem_types_data": {
               "Objective": {
                   "total_score": 16,
                   "num_problems": 5
               },
               "Data Science": {
                   "total_score": 100,
            "num_problems": 1
               },
               "Java Project": {
                   "total_score": 20,
          "num_problems": 1
               },
            "Programming": {
                   "total_score": 50,
                   "num_problems": 2
               },
               "File": {
                   "total_score": 100,
                   "num_problems": 1
               }
           },
           "practice_test_slug": "practice-test-36741"
       },
       {
           "start_datetime": "2019-08-19T07:47:00-05:51",
           "creation_datetime": "2019-08-15T07:47:00-05:51",
           "end_datetime": "2019-08-20T23:25:02+05:30",
           "id": 626315,
           "title": "Invite",
           "slug": "invite",
           "duration": 6000.0,
           "cutoff_score": 98.0,
           "skills_at_creation": ["AWS", "Python"],
           "job_role": "jr python 1",
           "test_description": null,
           "tags": "Python",
           "skills": ["algorithms", "Data structures"],
           "problem_types_data": {
                          "Objective": {
                   "total_score": 76,
                   "num_problems": 20
               }
        },
          "practice_test_slug": "practice-test-36742"
       }
   ],
}

mcode

Type : String

Description: Message code abbreviated as mcode.

message

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

ecode

Type: List

Description: Error codes abbreviated as ecode.

emessage

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
BADDATA Invalid request data.
PAGINATIONBADDATA Invalid pagination request data.
LIMITEXCEEDED The limit of the API requests has been reached. Contact support@hackerearth.com.
RATELIMITEXCEEDED The rate at which the API requests are made has reached. Please try again after one minute.

events

Type: List

Description: It is a list of dictionaries where each dictionary represents an event's details i.e. start_datetime, creation_datetime, end_datetime, duration (seconds), id, title, slug, cutoff_score, problem_types_data and practice_test_slug.

These event details are ordered in descending order of event creation datetime.

has_more

Type: Boolean value (True/False)

Description: The value of this field indicates that whether next page exists or not. If the value of has_more is false, then the current page is the last page in paginated events list.

Errors (Mishandled API responses)

If the client_id or client_secret attribute is incorrect, then the JSON response that is returned is as follows:

{
    "message": "Request failed",
    "ecode": [
         "AUTHFAILED"
    ],
    "emessage": [
        "Authentication Failed"
    ],
    "mcode": "FAILED"
}

If the provided data is invalid, then the JSON response that is returned is as follows:

{
    "message": "Request failed",
    "ecode": [
         "BADDATA"
    ],
    "emessage": [
        "Invalid request data."
    ],
    "mcode": "FAILED"
}

If the provided pagination data is invalid, then the JSON response that is returned is as follows:

{
    "message": "Request failed",
    "ecode": [
    "PAGINATIONBADDATA"
    ],
    "emessage": [
       "Invalid pagination request data."
    ],
    "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 JSONresponse 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 any other issue occurred do reach us out at api@hackerearth.com

Notifications
View All Notifications

?