Docs

Judge0-compatible API

A Judge0 CE-compatible API at https://api.onlinecompiler.io/api/judge0, with the same submissions, batches, languages and statuses endpoints, so a Judge0 client moves by changing its base URL and key. The differences from Judge0 are listed below.

Code written for Judge0 CE runs here with two changes: point its base URL at https://api.onlinecompiler.io/api/judge0, and send your API key in X-Auth-Token (or Authorization). Submissions, tokens, batches, base64_encoded, fields, expected_output, callbacks and status ids work as on Judge0, and wait=true works too.

MethodPath under /api/judge0What it does
POST/submissionsRuns one submission. With ?wait=true the result comes back in the response; without it, a token to poll.
GET/submissions/{token}The submission and its result, with ?fields= and ?base64_encoded= as on Judge0.
POST/submissions/batchUp to 20 submissions at once, and no more than your account's pending limit.
GET/submissions/batch?tokens=Several submissions by token, in the order asked.
GET/languages, /languages/all, /languages/{id}Judge0 language ids for our compilers. No key needed.
GET/statusesJudge0's 14 statuses. No key needed.
Terminal
curl -X POST "https://api.onlinecompiler.io/api/judge0/submissions?wait=true" \
  -H "X-Auth-Token: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "language_id": 71,
    "source_code": "print(int(input()) * 2)",
    "stdin": "21",
    "expected_output": "42"
  }'

Response (201)

Response
{
  "token": "6f1c2b9e-0d4a-4a53-9f7e-2b8c1d3e4f50",
  "time": "0.0213",
  "memory": 9216,
  "stdout": "42\n",
  "stderr": null,
  "compile_output": null,
  "message": null,
  "status": { "id": 3, "description": "Accepted" }
}

Differences from Judge0

  • Older language ids, such as 71 for Python 3.8 and 62 for Java 13, run on the current version. Ids for other languages answer 422.
  • The lower of cpu_time_limit and wall_time_limit, capped at 30 seconds, stops the run and gives Time Limit Exceeded; compiling does not count, Java, Groovy and F# get a start-up allowance on top (Java (1 s), Groovy (1.5 s) and F# (2.5 s)), and 0 means no limit of your own. time is wall-clock seconds. The other limits are accepted and ignored: every run gets our memory limit.
  • time is the run command's wall-clock seconds, which for Java, F#, TypeScript, Dart, Erlang, Elixir, Clojure and Groovy includes compiling as they start.
  • Compilation Error (6) comes with compile_output for C, C++, C#, Go, Rust, Haskell, Fortran, Visual Basic, Kotlin, Swift, COBOL, Pascal, Assembly, OCaml, D, FreeBASIC, Scala and Objective-C. The other languages compile or check code as they run, so their compile errors are Runtime Error (NZEC) with the message in stderr.
  • compiler_options, command_line_arguments, additional_files and enable_network answer 422.
  • A batch is admitted whole or not at all. Account limits answer 429 and a queue failure 503, both as {"error": "..."}.
  • There is no listing or deleting submissions, and compile_cmd and run_cmd are null; our commands are listed above.

Moving a Judge0 integration? See the Judge0 migration guide.

Questions

Do old Judge0 language ids work?
Yes. Older ids, such as 71 for Python 3.8 and 62 for Java 13, run on the current version. Ids for languages we don't run answer 422.
Does wait=true work?
Yes. POST /submissions?wait=true returns the result in the response; without it you get a token to poll with GET /submissions/{token}.
How many submissions fit in a batch?
Up to 20, and no more than your account's pending limit. A batch is admitted whole or not at all.