Submission is used for running arbitrary source code in one of the available programming languages with specified runtime constraints.

Submission has 32 attributes. Attributes 1-19 are used for creating a new submissions, whereas attributes 20-32 give detailed information of submission after it’s execution.

Attributes 7-17 are called configuration variables and can be used to configure submission runtime constraints such as time and memory limits.

# Name Type Unit Description Default Value 1 source_code text Program’s source code. No default. This attribute is required for single-file programs. 2 language_id integer Language ID. No default. This attribute is required. 3 compiler_options string (max. 512 chars) Options for the compiler (i.e. compiler flags). null 4 command_line_arguments string (max. 512 chars) Command line arguments for the program. null 5 stdin text Input for program. null . Program won’t receive anything to standard input. 6 expected_output text Expected output of program. Used when you want to compare with stdout . null . Program’s stdout won’t be compared with expected_output . 7 cpu_time_limit float second Default runtime limit for every program. Time in which the OS assigns the processor to different tasks is not counted. Depends on configuration. 8 cpu_extra_time float second When a time limit is exceeded, wait for extra time, before killing the program. This has the advantage that the real execution time is reported, even though it slightly exceeds the limit. Depends on configuration. 9 wall_time_limit float second Limit wall-clock time in seconds. Decimal numbers are allowed. This clock measures the time from the start of the program to its exit, so it does not stop when the program has lost the CPU or when it is waiting for an external event. We recommend to use cpu_time_limit as the main limit, but set wall_time_limit to a much higher value as a precaution against sleeping programs. Depends on configuration. 10 memory_limit float kilobyte Limit address space of the program. Depends on configuration. 11 stack_limit integer kilobyte Limit process stack. Depends on configuration. 12 max_processes_and_or_threads integer Maximum number of processes and/or threads program can create. Depends on configuration. 13 enable_per_process_and_thread_time_limit boolean If true then cpu_time_limit will be used as per process and thread. Depends on configuration. 14 enable_per_process_and_thread_memory_limit boolean If true then memory_limit will be used as per process and thread. Depends on configuration. 15 max_file_size integer kilobyte Limit file size created or modified by the program. Depends on configuration. 16 redirect_stderr_to_stdout boolean If true standard error will be redirected to standard output. Depends on configuration. 17 number_of_runs integer Run each program number_of_runs times and take average of time and memory . Depends on configuration. 18 additional_files Base64 Encoded String Additional files that should be available alongside the source code. Value of this string should represent the content of a .zip that contains additional files. This attribute is required for multi-file programs. null 19 callback_url string URL on which Judge0 will issue PUT request with the submission in a request body after submission has been done. null 20 stdout text Standard output of the program after execution. 21 stderr text Standard error of the program after execution. 22 compile_output text Compiler output after compilation. 23 message text If submission status is Internal Error then this message comes from Judge0 itself, otherwise this is status message from isolate. 24 exit_code integer The program’s exit code. 25 exit_signal integer Signal code that the program recieved before exiting. 26 status object Submission status. 27 created_at datetime Date and time when submission was created. 28 finished_at datetime Date and time when submission was processed. null if submission is still in queue or if submission is processing. 29 token string Unique submission token which can be used to get a specific submission. 30 time float second Program’s run time. 31 wall_time float second Program’s wall time. Will be greater or equal to time . 32 memory float kilobyte Memory used by the program after execution.

Single-file programs and multi-file programs ¶

Judge0 can run both single-file and multi-file programs in a sandboxed environment with specified resource limitations. The usage of multi-file programs is slightly different from single-file programs and this section explains their differences and when they should be used.

This is the simplest way to run a program with Judge0. Pick a language with language_id , provide a source_code and Judge0 will use predefined compilation and execution scripts for specified language. Additionally you can set custom compile flags, provide command line arguments and send additional_files that will be available in the sandbox alongside your single-file program.

With additional_files you can send, for example, Python modules which are imported by your main program that you provided in source_code attribute. For C or C++ programs with additional_files you can send header files which are included by your main program that you provided in source_code attribute.

Even though you can send and use multiple Python modules or C and C++ header files, we call this single-file programs because for compiled languages only one source file is compiled with predefined compilation scripts.

Multi-file programs are available since v1.10.0 and they allow you specify your own compilation and execution scripts that Judge0 will use.

To use multi-file program feature you need to choose a language called Multi-file program whoose ID is 89. Moreover, you need to send all program files with additional_files attribute. With multi-file programs attribute source_code cannot be used, i.e. all files should be sent with additional_files attribute.

As mentioned in the table above, additional_files attribute should be a content of a Base64 encoded .zip archive. This archive will be extracted in the sandbox before compilation and execution.

For the Judge0 to know how to compile and execute your multi-file program you need to provide two special files that should be available in the root of the .zip archive that you are sending with additional_files attribute. These files should be named compile and run , and are expected to be Bash scripts that know how to compile and execute your multi-file program. If your multi-file program does not need compilation step, then you don’t need to provide compile script. Take a look at this example to learn how to use this feature to compile and run multi-file C++ project that uses CMake.

Create a Submission POST /submissions/{?base64_encoded,wait} Creates new submission. Created submission waits in queue to be processed. On successful creation, you are returned submission token which can be used to check submission status. If submission’s source_code , stdin or expected_output contains non printable characters, or characters which cannot be sent with JSON, then set base64_encoded parameter to true and send these attributes Base64 encoded. Your responsibility is to encode each of mentioned attributes ( source_code , stdin and expected_output ) even if just one of them contains non printable characters. By default, this parameter is set to false and Judge0 assumes you are sending plain text data. By default you are returned submission token on successful submission creation. With this token you can check submission status. Instead of checking submission status by making another request, you can set the wait query parameter to true which will enable you to get submission status immediately as part of response to the request you made. Please note that this feature may or may not be enabled on all Judge0 hosts. So before using this feature please check configuration of Judge0 you are using. On an official Judge0 this feature is not enabled. Note We do not recommend the use of wait=true feature because it does not scale well. Example URI POST https://api.judge0.com /submissions/? base64_encoded= false & wait= false URI Parameters Hide Show base64_encoded boolean (optional) Default: false Example: false Set to true if you want to send Base64 encoded data to Judge0. wait boolean (optional) Default: false Example: false Set to true to immediately get submission result. Request Hide Show Headers Content-Type : application/json Body { " source_code ": "#include <stdio.h>



int main(void) {

char name[10];

scanf(\"%s\", name);

printf(\"hello, %s

\", name);

return 0;

}" , " language_id ": 4 , " stdin ": "world" } Response 201 Hide Show Headers Content-Type : application/json Body { " token ": "d85cd024-1548-4165-96c7-7bc88673f194" } Request Hide Show Headers Content-Type : application/json Body { " source_code ": "#include <stdio.h>



int main(void) {

char name[10];

scanf(\"%s\", name);

printf(\"hello, %s

\", name);

return 0;

}" } Response 422 Hide Show Headers Content-Type : application/json Body { " language_id ": [ "can't be blank" ] } Request Hide Show Headers Content-Type : application/json Body { " source_code ": "#include <stdio.h>



int main(void) {

char name[10];

scanf(\"%s\", name);

printf(\"hello, %s

\", name);

return 0;

}" , " language_id ": 150000 , " stdin ": "world" , " expected_output ": "hello, world" } Response 422 Hide Show Headers Content-Type : application/json Body { " language_id ": [ "language with id 150000 doesn't exist" ] } Request Hide Show Headers Content-Type : application/json Body { " source_code ": "#include <stdio.h>



int main(void) {

char name[10];

scanf(\"%s\", name);

printf(\"hello, %s

\", name);

return 0;

}" , " language_id ": 4 , " number_of_runs ": 1 , " stdin ": "Judge0" , " expected_output ": "hello, Judge0" , " cpu_time_limit ": 1 , " cpu_extra_time ": 0.5 , " wall_time_limit ": 100000 , " memory_limit ": 128000 , " stack_limit ": 128000 , " enable_per_process_and_thread_time_limit ": false , " enable_per_process_and_thread_memory_limit ": false , " max_file_size ": 1024 } Response 422 Hide Show Headers Content-Type : application/json Body { " wall_time_limit ": [ "must be less than or equal to 150" ] } Request Hide Show Sending Base64 encoded source_code and stdin . Note that in this request base64_encoded query parameter must be set to true . Headers Content-Type : appliction/json Body { " source_code ": "I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbih2b2lkKSB7CiAgY2hhciBuYW1lWzEwXTsKICBzY2FuZigiJXMiLCBuYW1lKTsKICBwcmludGYoImhlbGxvLCAlc1xuIiwgbmFtZSk7CiAgcmV0dXJuIDA7Cn0=" , " language_id ": 4 , " input ": "SnVkZ2Uw" } Response 201 Hide Show Headers Content-Type : application/json Body { " token ": "f3fe0215-72f3-4fe6-97f5-353df6682db4" } Request Hide Show Creating a submission with wait=true that results with one or more attributes that cannot be serialized to JSON without Base64 encoding. Headers Content-Type : application/json Body { " language_id ": 70 , " source_code ": "print(\"\xFE\")" } Response 201 Hide Show Headers Content-Type : application/json Body { " token ": "fcd0de6d-ee52-4a9d-8a00-6e0d98d394cf" , " error ": "some attributes for this submission cannot be converted to UTF-8, use base64_encoded=true query parameter" } Request Hide Show Waiting for submission to finish. Note that in this request wait query parameter must be set to true . Headers Content-Type : application/json Body { " source_code ": "#include <stdio.h>



int main(void) {

char name[10];

scanf(\"%s\", name);

printf(\"hello, %s

\", name);

return 0;

}" , " language_id ": "4" , " stdin ": "Judge0" , " expected_output ": "hello, Judge0" } Response 201 Hide Show Headers Content-Type : application/json Body { " stdout ": "hello, Judge0

" , " time ": "0.001" , " memory ": 380 , " stderr ": null , " token ": "eb0dd001-66db-47f4-8a69-b736c9bc23f6" , " compile_output ": null , " message ": null , " status ": { " id ": 3 , " description ": "Accepted" } } Response 400 Hide Show If wait is not allowed. Headers Content-Type : application/json Body { " error ": "wait not allowed" } Response 503 Hide Show If submission queue is full. Headers Content-Type : application/json Body { " error ": "queue is full" } Response 401 Hide Show Authentication failed. Please read about authentication process.

Get a Submission GET /submissions/{token}{?base64_encoded,fields} Returns details about submission. Just like in create submission you can receive Base64 encoded data for every text type attribute (check the table to see which attributes are text type). By default, this parameter is set to false and Judge0 will send you raw data. By default Judge0 is sending 8 attributes for submission. By sending fields query parameter you can specify exactly which attributes you want from Judge0. Special value * will return all available attributes. Example URI GET https://api.judge0.com /submissions/ d85cd024-1548-4165-96c7-7bc88673f194 ? base64_encoded= false & fields= stdout,stderr,status_id,language_id URI Parameters Hide Show token string (required) Example: d85cd024-1548-4165-96c7-7bc88673f194 Token of submission. You got this token when you created submission. base64_encoded boolean (optional) Example: false Set to true if you want to receive Base64 encoded data from Judge0. You should set this to true if you expect the program’s stdout to contain non-printable characters or if you expect the compiler to output non-printable characters during a compile error (GCC does this, for instance). fields string (optional) Default: stdout,time,memory,stderr,token,compile_output,message,status Example: stdout,stderr,status_id,language_id Return only the desired attributes. Response 200 Hide Show Headers Content-Type : applicatiion/json Body { " stdout ": "hello, world

" , " status_id ": 5 , " language_id ": 4 , " stderr ": null } Response 200 Hide Show This is the default response. Leave fields parameter empty if you want to get default response. Headers Content-Type : application/json Body { " stdout ": "hello, Judge0

" , " time ": "0.001" , " memory ": 376 , " stderr ": null , " token ": "8531f293-1585-4d36-a34c-73726792e6c9" , " compile_output ": null , " message ": null , " status ": { " id ": 3 , " description ": "Accepted" } } Response 200 Hide Show Receiving Base64 encoded data for text type attributes. Note that in this request base64_encoded query parameter must be set to true . Headers Content-Type : application/json Body { " stdout ": "aGVsbG8sIEp1ZGdlMAo=

" , " time ": "0.002" , " memory ": 376 , " stderr ": null , " token ": "4e00f214-b8cb-4fcb-977b-429113c81ece" , " compile_output ": null , " message ": null , " status ": { " id ": 3 , " description ": "Accepted" } } Response 400 Hide Show Headers Content-Type : application/json Body { " error ": "some attributes for this submission cannot be converted to UTF-8, use base64_encoded=true query parameter" } Response 401 Hide Show Authentication failed. Please read about authentication process.

Get Submissions GET /submissions/{?base64_encoded,fields,page,per_page} Example URI GET https://api.judge0.com /submissions/? base64_encoded= false & fields= status,language,time & page= 4 & per_page= 2 URI Parameters Hide Show base64_encoded boolean (optional) Default: false Example: false Set to true if you want to receive Base64 encoded data from Judge0. page integer (optional) Default: 1 Example: 4 Pagination page number. per_page integer (optional) Default: 20 Example: 2 Number of submissions to return per page. fields string (optional) Default: stdout,time,memory,stderr,token,compile_output,message,status Example: status,language,time Return only the desired attributes. Response 200 Hide Show Headers Content-Type : application/json Body { " submissions ": [ { " time ": "0.001" , " status ": { " id ": 3 , " description ": "Accepted" } , " language ": { " id ": 4 , " name ": "C (gcc 7.2.0)" } }, { " time ": "0.001" , " status ": { " id ": 3 , " description ": "Accepted" } , " language ": { " id ": 4 , " name ": "C (gcc 7.2.0)" } } ] , " meta ": { " current_page ": 4 , " next_page ": 5 , " prev_page ": 3 , " total_pages ": 31 , " total_count ": 62 } } Response 200 Hide Show When base64_encoded is set to true . Headers Content-Type : application/json Body { " submissions ": [ { " stdout ": "aGVsbG8sIEp1ZGdlMAo=

" , " time ": "0.001" , " memory ": 376 , " stderr ": null , " token ": "a1133bc6-a0f6-46bf-a2d8-6157418c6fe2" , " compile_output ": null , " message ": null , " status ": { " id ": 3 , " description ": "Accepted" } }, { " stdout ": "aGVsbG8sIEp1ZGdlMAo=

" , " time ": "0.001" , " memory ": 380 , " stderr ": null , " token ": "eb0dd001-66db-47f4-8a69-b736c9bc23f6" , " compile_output ": null , " message ": null , " status ": { " id ": 3 , " description ": "Accepted" } } ] , " meta ": { " current_page ": 4 , " next_page ": 5 , " prev_page ": 3 , " total_pages ": 31 , " total_count ": 62 } } Response 400 Hide Show When page parameter is invalid. Headers Content-Type : application/json Body { " error ": "invalid page: -4" } Response 400 Hide Show When per_page parameter is invalid. Headers Content-Type : application/json Body { " error ": "invalid per_page: -2" } Response 400 Hide Show Headers Content-Type : application/json Body { " error ": "some attributes for one or more submissions cannot be converted to UTF-8, use base64_encoded=true query parameter" } Response 401 Hide Show Authentication failed. Please read about authentication process. Response 403 Hide Show Authorization failed. Please read about authorization process.