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)
NewExecute 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.
/api/run-code-sync/Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| compiler | string | Yes | Compiler identifier (see list below) |
| code | string | Yes | Source code to execute (max 100KB) |
| input | string | No | Standard input for the program (max 100KB) |
| time_limit | number | No | Seconds 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)
{
"output": "Hello, World!\n",
"error": "",
"status": "success",
"exit_code": 0,
"signal": null,
"truncated": false,
"time": "0.0248",
"total": "0.0330",
"memory": "8192"
}Examples
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"
}'Run Code (Async)
/api/run-code/Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| compiler | string | Yes | Compiler identifier (see list below) |
| code | string | Yes | Source code to execute (max 100KB) |
| input | string | No | Standard input for the program (max 100KB) |
| time_limit | number | No | Seconds 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_params | object | No | JSON object returned in the callback (max 8KB) |
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
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)
{ "status": "queued", "id": 42 }Callback POST Body
Once execution completes, results are POSTed to your API key's redirect URL:
{
"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": {}
}| Field | Description |
|---|---|
| output | Standard output (up to 64 KB; NUL and invalid UTF-8 bytes come back as U+FFFD) |
| error | Standard error / compilation errors (up to 64 KB; NUL and invalid UTF-8 bytes come back as U+FFFD) |
| status | "success" or "error" |
| exit_code | Process exit code (0 = success) |
| signal | Signal number if killed (e.g. 9 for SIGKILL), null otherwise |
| truncated | true if output or error went over 64 KB and was cut |
| time | Run-command wall time in seconds; includes the compilation Java, F#, Deno, Dart, Erlang, Elixir, Clojure, Groovy and Racket do as they run |
| total | Script wall time in seconds, including separate compilation; excludes container startup |
| memory | Memory usage in KB |
| time_limit | The run's time limit in seconds: yours, or 30 without one |
| extra_params | Your 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 Code | Signal | Meaning |
|---|---|---|
| 0 | null | Success |
| 1 | null | Runtime error (e.g. uncaught exception, assertion failure) |
| 2 | null | Misuse of command / invalid arguments |
| 137 | 9 (SIGKILL) | Killed: over the 512 MB memory limit |
| 139 | 11 (SIGSEGV) | Segmentation fault: invalid memory access |
| 124 | null | Timeout: 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 |
| 153 | 25 (SIGXFSZ) | Stopped for flooding output: more than 8 MB across both streams |
| 71 | null | Too 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.