Docs

Run code: get a program's output, errors and exit code

POST source code, a compiler id and optional input. /api/run-code-sync/ waits for the run and returns its output, errors, exit code, run time and memory in the response; /api/run-code/ answers at once and POSTs the same result to the callback URL on your API key.

Run Code (Sync)

New

Execute code and get results in a single request. No callback URL needed: the response contains the execution output directly. Ideal for simple integrations, scripts, and AI agents.

POST /api/run-code-sync/

Request Body

ParameterTypeRequiredDescription
compilerstringYesCompiler identifier (see list below)
codestringYesSource code to execute (max 100KB)
inputstringNoStandard input for the program (max 100KB)
time_limitnumberNoSeconds the program may run, above 0 and up to 30. The run is stopped at this limit with exit code 124; compiling before it does not count, but Java, Groovy and F# get a start-up allowance on top. Without it, the run gets what is left of the 30-second timeout.

Response (200)

Response
{
  "output": "Hello, World!\n",
  "error": "",
  "status": "success",
  "exit_code": 0,
  "signal": null,
  "truncated": false,
  "time": "0.0248",
  "total": "0.0330",
  "memory": "8192"
}

Examples

Terminal
curl -X POST https://api.onlinecompiler.io/api/run-code-sync/ \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "compiler": "python-3.14",
    "code": "name = input()\nprint(f\"Hello, {name}!\")",
    "input": "World"
  }'
Note: The sync endpoint blocks until execution completes (up to 30 seconds). For high-throughput or long-running code, use the async endpoint or WebSocket instead.

Run Code (Async)

POST /api/run-code/

Request Body

ParameterTypeRequiredDescription
compilerstringYesCompiler identifier (see list below)
codestringYesSource code to execute (max 100KB)
inputstringNoStandard input for the program (max 100KB)
time_limitnumberNoSeconds the program may run, above 0 and up to 30. The run is stopped at this limit with exit code 124; compiling before it does not count, but Java, Groovy and F# get a start-up allowance on top. Without it, the run gets what is left of the 30-second timeout.
extra_paramsobjectNoJSON object returned in the callback (max 8KB)
Async execution: The API returns 202 Accepted immediately with a queue ID. Results are delivered to your API key's redirect URL as a POST callback. Use a public HTTP(S) URL; private addresses, embedded credentials, and HTTP redirects are not supported.

Code Examples

Terminal
curl -X POST https://api.onlinecompiler.io/api/run-code/ \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "compiler": "python-3.14",
    "code": "name = input()\nprint(f\"Hello, {name}!\")",
    "input": "World"
  }'

Response

Immediate Response (202)

Response
{ "status": "queued", "id": 42 }

Callback POST Body

Once execution completes, results are POSTed to your API key's redirect URL:

Callback Payload
{
  "output": "Hello, World!\n",
  "error": "",
  "status": "success",
  "exit_code": 0,
  "signal": null,
  "truncated": false,
  "time": "0.0248",
  "total": "0.0330",
  "memory": "8192",
  "time_limit": 30,
  "extra_params": {}
}
FieldDescription
outputStandard output (up to 64 KB; NUL and invalid UTF-8 bytes come back as U+FFFD)
errorStandard error / compilation errors (up to 64 KB; NUL and invalid UTF-8 bytes come back as U+FFFD)
status"success" or "error"
exit_codeProcess exit code (0 = success)
signalSignal number if killed (e.g. 9 for SIGKILL), null otherwise
truncatedtrue if output or error went over 64 KB and was cut
timeRun-command wall time in seconds; includes the compilation Java, F#, Deno, Dart, Erlang, Elixir, Clojure, Groovy and Racket do as they run
totalScript wall time in seconds, including separate compilation; excludes container startup
memoryMemory usage in KB
time_limitThe run's time limit in seconds: yours, or 30 without one
extra_paramsYour custom data, passed through unchanged

Exit Codes & Signals

The exit_code field contains the process exit code. A value of 0 means the program ran successfully. Any non-zero value indicates an error.

When exit_code is greater than 128, the process was killed by a signal. The signal field provides the signal number (i.e. exit_code - 128). When the process exits normally, signal is null.

Exit CodeSignalMeaning
0nullSuccess
1nullRuntime error (e.g. uncaught exception, assertion failure)
2nullMisuse of command / invalid arguments
1379 (SIGKILL)Killed: over the 512 MB memory limit
13911 (SIGSEGV)Segmentation fault: invalid memory access
124nullTimeout: the run went over your time_limit (plus the start-up allowance for Java, Groovy and F#), or compile and run together went over 30 seconds
15325 (SIGXFSZ)Stopped for flooding output: more than 8 MB across both streams
71nullToo many processes: more than 16 running at once, so the sandbox stopped. Output printed before that is kept, and error says what happened

Questions

Should I use the sync or the async endpoint?
Use /api/run-code-sync/ when you can wait for the result in the same request: it returns when the run ends, within 30 seconds, and answers 429 when your account's runs at once are all busy. Use /api/run-code/ to queue runs: it answers 202 at once, waits for a free sandbox and POSTs each result to your callback URL.
How do I send input to the program?
Send it as input, up to 100 KB: the program reads it as standard input. SQL is the exception, because SQLite reads the program from standard input; there the script reads input with readfile('input').
What do exit codes 124, 137, 153 and 71 mean?
124: the run went over its time_limit, or compiling and running together went over 30 seconds. 137 (signal 9): the program was killed at the 512 MB memory limit. 153 (signal 25): it printed more than 8 MB. 71: it had more than 16 processes running at once, so the sandbox stopped; error says so. Other codes come from the program itself, such as 1 for an uncaught Python exception.