onlinecompiler.io

Code execution API documentation

Get an API key, send it in the Authorization header, and POST source code to https://api.onlinecompiler.io/api/run-code-sync/ to get its output back. The pages below cover every endpoint, in 46 languages.

Try it without an API key

Edit the program or its input and press Run. It runs for real, and below you get the request your code would send and the response it would get back.

name = input()
print(f"Hello, {name}!")
World

The request

bash
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"
}'

The response

Press Run in the editor to see it.

To send it from your own code, get a free API key: 100,000 runs a month, no credit card.

Authentication

All API requests require an API key passed in the Authorization header.

Authorization: YOUR_API_KEY

Key Types

There are two types of API keys, each scoped to specific endpoints:

Key TypeCreated FromAllowed EndpointsUse Case
APIAPI Keys pageREST API (sync & async)Server-side integrations, scripts, AI agents
WebSocketWidgets pageWebSocket & embeddable widgetEmbedded editors, browser-based apps
Why two types? WebSocket keys are embedded in public HTML and visible to anyone. Separating key types ensures a scraped widget key cannot be used to call the REST API directly. You can also restrict a REST API key to one IP address, and a widget key to the domain that embeds it.
How to get an API key: Sign up at api.onlinecompiler.io. Your first API key is made for you and shown on your dashboard. Make more under API Keys (for REST API) or Widgets (for WebSocket/embeds).

Run your first program

With your API key in place of YOUR_API_KEY, this runs a Python program with one line of input and waits for the result:

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"
  }'

The response has the program's output, errors, exit code, run time in seconds and memory in KB:

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

No key yet? Send the same request with no Authorization header to /api/guest/run-code/ to try it. Guest runs take the compiler, the code, up to 64 KB of input and up to 5 seconds; each address gets 20 an hour, and the answer adds a guest object with the runs left. For anything more, the free key above has 100,000 runs a month.

Terminal: a guest run, no key
curl -X POST https://api.onlinecompiler.io/api/guest/run-code/ \
  -H "Content-Type: application/json" \
  -d '{"compiler": "python-3.14", "code": "print(sum(range(10)))"}'

Every field, the async endpoint and the exit codes are in Run code. Other languages take their own compiler id, listed in Compilers.

A request over one of your account's limits gets HTTP 429 and nothing runs. When the limit clears by itself (per minute, pending, runs at once, busy sandboxes), the answer has a Retry-After header with the seconds to wait before sending it again; a spent monthly allowance has none.

An OpenAPI 3.1 description of the REST API is at https://api.onlinecompiler.io/openapi.json, for Postman, Swagger UI or an agent's tool builder. It covers run-code-sync, run-code, run-tests, stored problems, submissions (list, look up, delete and share), receipts, compilers, limits, usage and health.

Node.js client

The official client, onlinecompiler on npm, covers the REST API: runs, run-tests and test suites, background judging, stored problems, widget sessions, submissions, and webhook and receipt verification. It has no dependencies (it uses the global fetch and Web Crypto), includes TypeScript types, and works on Node 22.13+, Deno, Bun and Cloudflare Workers.

Terminal
npm install onlinecompiler

It reads your API key from ONLINECOMPILER_API_KEY, or takes it as apiKey. This runs the program above, then judges another against two tests:

example.js
import { OnlineCompiler } from 'onlinecompiler';

const client = new OnlineCompiler(); // reads ONLINECOMPILER_API_KEY

const result = await client.run({
  compiler: 'python-3.14',
  code: 'name = input()\nprint(f"Hello, {name}!")',
  input: 'World',
});
console.log(result.output); // Hello, World!

const judged = await client.runTests({
  compiler: 'python-3.14',
  code: 'a, b = map(int, input().split())\nprint(a + b)',
  tests: [
    { input: '1 2', expected_output: '3' },
    { input: '10 20', expected_output: '30', hidden: true },
  ],
});
console.log(judged.verdict, judged.score); // accepted 100

Request and response fields keep the API's own snake_case names, so these docs apply as written: client.iterSubmissions({ external_ref: 'student-42' }) goes through one candidate's submissions, every page of them. Use the client on your server: an API key in a browser bundle can be copied. To run code in the browser, use the widget, whose keys can be restricted to your domain. Every method is described in the README on npm, and the source is on GitHub. For models built with the Vercel AI SDK, the package also has runCode and runTests tools.

Python client

The official client, onlinecompiler on PyPI, covers the same REST API as the Node.js client. It uses only the standard library, includes type hints, and needs Python 3.10 or newer. Verifying receipts needs one extra, pip install "onlinecompiler[receipts]", which adds cryptography.

Terminal
pip install onlinecompiler

It reads your API key from ONLINECOMPILER_API_KEY, or takes it as OnlineCompiler(api_key). The same two calls in Python:

example.py
from onlinecompiler import OnlineCompiler

client = OnlineCompiler()  # reads ONLINECOMPILER_API_KEY

result = client.run("python-3.14", 'name = input()\nprint(f"Hello, {name}!")', input="World")
print(result["output"])  # Hello, World!

judged = client.run_tests(
    "python-3.14",
    "a, b = map(int, input().split())\nprint(a + b)",
    tests=[
        {"input": "1 2", "expected_output": "3"},
        {"input": "10 20", "expected_output": "30", "hidden": True},
    ],
)
print(judged["verdict"], judged["score"])  # accepted 100

Results are dicts with the API's own field names, and client.iter_submissions(external_ref="student-42") goes through one candidate's submissions, every page of them. Every method is described in the README on PyPI, and the source is on GitHub. Code written for the old runcode package runs again after pip install -U runcode, which now works through this client.

All docs pages

Questions

Which endpoint should I use?
To run a program and wait for its output, /api/run-code-sync/. To queue many runs and get each result by callback, /api/run-code/. To judge a program against test cases, /api/run-tests/. To keep a problem's tests on the server and judge code against it by id, the stored problems API at /api/problems/ (see /docs/problems). To run code from a browser page, the WebSocket or the widget, with a widget key. Code written for Judge0 or Piston can keep its requests and use the compatible endpoints, and Moodle CodeRunner can use the Jobe-compatible endpoints in place of a Jobe server.
Can I run code with a GET request, or without an API key?
No. A run is a POST request with a JSON body and your API key in the Authorization header; there is no GET or keyless endpoint, so code never travels in a URL, where it would be cut short and kept in browser history and server logs. The key is free: sign in with Google at https://api.onlinecompiler.io/compilers/api-keys/ and your first key is made for you, with 100,000 runs a month on the Free plan, commercial use allowed and no card. To try a run before signing up, use "Try it without an API key" on this page. AI assistants can run code through the MCP server at https://api.onlinecompiler.io/mcp, which signs in with OAuth or takes an API key.
Do I need an SDK?
No. The API is HTTPS and JSON, so curl, fetch, requests or any HTTP client works, and each page has examples. For Node.js and Python there are official clients, npm install onlinecompiler and pip install onlinecompiler, with types and no dependencies. The WebSocket uses Socket.IO, and AI agents connect through the MCP server, which takes an OAuth sign-in or an API key.
How long does a run take?
A small Python program comes back in a median 0.56 seconds from request to response, and a Java one in 2.25, most of it compiling. Each run is limited to 30 seconds. The compilers page has the measured time for every language.