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
FieldTypeMeaning
languagestringAny supported language
codestringThe program. It reads the case as input and prints the answer
casesarray, 1 to 25{ "stdin", "expected" } per case
profilestring, optionalDefaults 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
}
FieldMeaning
results[].verdictAC, WA, or the run's result code
results[].passedtrue only for AC
results[].stdout, stderr, exit_code, wall_time_secsWhat the program did on that case
all_passedtrue 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#

LimitValue
Cases per request25 (400 with too many cases above that)
Per caseThe profile's limits: see Profiles
RateEach case counts as one run against your plan
All or nothingIf any case would be refused (rate limit, monthly cap, full queue), no case runs and none counts toward your monthly cap
Open requestsA judge request waits for its cases, so it takes one of your concurrent waiting slots, like ?wait=true