POST /api/judge#
Run one program against up to 25 test cases in one call. Each test case runs in its own fresh box with that case's stdin, and what the program prints is checked against expected. You get one result per case: AC when the output matches (right answer), WA when the program ran but printed something else (wrong answer), or the run's own result code (TLE, RE, MLE, ...) when it did not finish cleanly.
Request#
curl -s -X POST https://api.rustbox.sh/api/judge \
-H "X-API-Key: rb_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"language": "python",
"code": "a, b = map(int, input().split())\nprint(a + b)",
"cases": [
{ "stdin": "1 2", "expected": "3" },
{ "stdin": "2 2", "expected": "5" },
{ "stdin": "x", "expected": "0" }
]
}' | jq| Field | Type | Meaning |
|---|---|---|
language | string | Any supported language |
code | string | The program. It reads the case as input and prints the answer |
cases | array, 1 to 25 | { "stdin", "expected" } per case |
profile | string, optional | Defaults to judge: no internet, the same limits every time |
Response#
{
"results": [
{
"verdict": "AC", "passed": true,
"stdout": "3\n", "stderr": "", "expected": "3",
"exit_code": 0, "wall_time_secs": 0.03
},
{
"verdict": "WA", "passed": false,
"stdout": "4\n", "stderr": "", "expected": "5",
"exit_code": 0, "wall_time_secs": 0.03
},
{
"verdict": "RE", "passed": false,
"stdout": "", "stderr": "Traceback ... ValueError: invalid literal ...", "expected": "0",
"exit_code": 1, "wall_time_secs": 0.03
}
],
"all_passed": false
}| Field | Meaning |
|---|---|
results[].verdict | AC, WA, or the run's result code |
results[].passed | true only for AC |
results[].stdout, stderr, exit_code, wall_time_secs | What the program did on that case |
all_passed | true when every case passed |
Comparison#
Before checking, spaces at the start and end are trimmed and runs of spaces inside are treated as one, so a trailing newline or a double space never turns a right answer into WA. Anything more, such as "close enough" decimals or answers in any order, is not supported yet: check stdout yourself or talk to us.
Problems that ask for a function#
/api/judge gives the program input and reads what it prints. For a problem that asks for a function, wrap the solution in a few lines that read the case from input, call the function and print the result.
Limits#
| Limit | Value |
|---|---|
| Cases per request | 25 (400 with too many cases above that) |
| Per case | The profile's limits: see Profiles |
| Rate | Each case counts as one run against your plan |
| All or nothing | If any case would be refused (rate limit, monthly cap, full queue), no case runs and none counts toward your monthly cap |
| Open requests | A judge request waits for its cases, so it takes one of your concurrent waiting slots, like ?wait=true |