CodeExec API Documentation
About
CodeExec API is an Online Code Execution API that allows users to run arbitrary code without installing compilers/interpreters, and is much safer for those who wanted to build a service that requires running untrusted code, for example, an Online Judge or Online IDE.
CodeExec was inspired by Judge0 API, and after redesigning service architecture and adopting cloud computing services, we’re able to provide an Online Code Execution API at a lower price with higher scalability and performance.
Getting Started
You may visit CodeExec API on RapidAPI to try on these API endpoints for free, or subscribe to a plan that fits your needs.
Submission & Task ¶
Submission ¶
Headers
Content-Type: application/jsonBody
{
"source_code": "bmFtZSA9IGlucHV0KCkKcHJpbnQoZiJIZWxsbywge25hbWV9ISIpCg==",
"language_id": 2,
"tasks": [
{
"stdin": "SmFzb24K",
"expected_output": "SGVsbG8sIEphc29uIQo="
}
]
}If the submission is successfully created, the response contains the submission token and all the tokens of its tasks.
Headers
Content-Type: application/jsonBody
{
"token": "ce78c8bc-0288-4132-ac07-91c861610812",
"tasks": [
{
"token": "65658f40-f147-4b7b-8bb9-4d5ecb5d813e"
}
]
}If any value is not valid, a 400 Bad Request response is returned with a message.
Headers
Content-Type: application/jsonBody
{
"message": "invalid language"
}Create SubmissionPOST/submission
Create submission with multiple tasks, each submission will be compiled (if needed), then run with each task environment specified, the result can be queried or send back with a webhook. The request should be a valid submission:
Submission
| Name (*required) | Description |
|---|---|
source_code * |
The base64 encoded source code to be compiled and executed |
language_id * |
The id of the language that source code is written in, look language section for more information. The maximum number of tasks one submission may have is limited by the configuration, see server configuration for more information. |
tasks * |
The tasks to be run, the task format is explaned below |
compile_options |
The extra arguments that will be passed to the compiler |
additional_files |
The base64 encoded content of the zip file that will be extracted before compilation and execution. |
Task
| Name | Description |
|---|---|
stdin |
The base64 encoded stdin to be passed to the running program |
limits |
The limits of the task, see below for more infomation about limits |
command_line_arguments |
The extra arguments to be passed when executing the program |
expected_output |
The expected stdout of the program, if is not null, the output will be compared and if different from expected output, the status will be set to “Wrong Answer” |
callback_url |
If is given, the result will be PUT to the callback url |
Limits
| Name | Description | Default | Unit |
|---|---|---|---|
time |
The time limit shared by all the process and threads | 15.0 | second |
memory |
The memory limit shared by all the process and threads | 262144 | kB |
filesize |
The maximum size that can be written to I/O | 4096 | kB |
process |
The maximum amount limit of thread and process | 1 | |
network |
Whether the program can have network access | false |
Headers
Content-Type: application/jsonBody
{
"token": "ce78c8bc-0288-4132-ac07-91c861610812",
"source_code": "bmFtZSA9IGlucHV0KCkKcHJpbnQoZiJIZWxsbywge25hbWV9ISIpCg==",
"language": "Python 3.9.7",
"tasks": [
{
"token": "65658f40-f147-4b7b-8bb9-4d5ecb5d813e",
"time": 0.032,
"memory": 5656,
"status": "Accepted"
}
]
}If the submission doesn’t exist, a 404 Not Found error is returned.
Headers
Content-Type: application/jsonBody
{
"message": "Submission doesn't exist."
}Get SubmissionGET/submission/{token}
After a submission is successfully created, the submission token and task tokens are returned, you may use the submission token to retrieve the submission result. In the submission result, the basic information about each task result is returned, for example: the status and time/memory consumption and the token of each task.
- token
string(required)The unique token for the submission
Task ¶
Headers
Content-Type: application/jsonBody
{
"token": "65658f40-f147-4b7b-8bb9-4d5ecb5d813e",
"stdout": "SGVsbG8sIEphc29uIQo=",
"stderr": "",
"exit_code": 0,
"time": 0.032,
"memory": 5656,
"message": "",
"status": "Accepted",
"timestamp": "2022-03-07T12:53:54.424986032Z"
}Get TaskGET/task/{token}
For more specific result information, you may query each task with the task token, the full information of the task result will be returned, which includes the stdout, stderr, exitcode and time/memory consumption, along with the status message and the timestamp of the result.
- token
string(required)The unique token for the Submission
Server Configurations ¶
Configuration Information ¶
Headers
Content-Type: application/jsonBody
{
"max_task": 32,
"max_time": 15,
"max_memory": 262144,
"max_process": 16,
"max_filesize": 4096
}Configuration InformationGET/config
Get the current configuration that server is running on.
Language ¶
Headers
Content-Type: application/jsonBody
[
{
"id": 1,
"name": "C (gcc 10.3.1)"
},
{
"id": 2,
"name": "C++ (g++ 10.3.1)"
},
{
"id": 3,
"name": "Python 3.9.7"
}
]Get LanguagesGET/languages
Get current available langauges on the server.
Headers
Content-Type: application/jsonBody
{
"id": 3,
"name": "Python 3.9.7",
"source_file": "source.py",
"compile_command": "",
"run_command": "/usr/bin/python3 source.py %s"
}Get LanguageGET/language/{id}
Get more specific information (how program is compiled, run) about a language supported on the server.
- id
number(required)The id of language to get
Generated by aglio on 15 Mar 2022