onlinecompiler.io

Autograder API: grade programming assignments against test cases

OnlineCompiler.io's run tests API is an autograder you call from your own course tools. Send a student's submission with the assignment's test cases and get back a verdict for each test and a score for partial credit, while hidden tests return nothing a student could read the inputs from. It grades Python, Java, C, C++ and 42 other languages, each submission in a fresh sandbox, and it's free up to 100,000 runs a month.

Também em portuguêsTambién en español

Grade a submission in one request

The assignment: print the largest of a line of numbers, or empty when there are none. Tests are worth 2, 3 and 5 points, and the 5-point test is hidden. Get an API key by signing in, then send the student's code with the tests:

Terminal
curl -X POST https://api.onlinecompiler.io/api/run-tests/ \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "compiler": "python-3.14",
    "code": "nums = list(map(int, input().split()))\nprint(max(nums))",
    "tests": [
      {"input": "3 9 4\n", "expected_output": "9\n", "weight": 2},
      {"input": "-5 -2 -8\n", "expected_output": "-2\n", "weight": 3},
      {"input": "\n", "expected_output": "empty\n", "weight": 5, "hidden": true}
    ],
    "scoring": "weighted"
  }'

The submission passes both visible tests and crashes on the hidden empty line, so it earns 5 of 10 points. Each test ran in its own fresh sandbox:

Response
{
  "verdict": "runtime_error",
  "score": 50.0,
  "passed": 2,
  "total": 3,
  "time_limit": 2,
  "compile_error": null,
  "tests": [
    {"verdict": "accepted", "hidden": false, "time": "0.0204", "memory": "9000",
     "exit_code": 0, "signal": null, "output": "9\n", "error": "", "truncated": false},
    {"verdict": "accepted", "hidden": false, "time": "0.0198", "memory": "9000",
     "exit_code": 0, "signal": null, "output": "-2\n", "error": "", "truncated": false},
    {"verdict": "runtime_error", "hidden": true}
  ]
}

score is the share of points earned. To record points rather than a percentage, multiply it by the assignment's total: 50 × 10 / 100 = 5.

Points, partial credit and hidden tests

  • Points: each test's weight is its points with "scoring": "weighted". percent counts every test the same, and all_or_nothing, the default, stops at the first failure.
  • Hidden tests: return only their verdict, so students can't print the hidden inputs and hard-code the answers.
  • Comparing output: trim, the default, ignores trailing spaces and blank lines; tokens ignores all spacing and line breaks; float accepts numbers within a tolerance; exact compares byte for byte.
  • Verdicts students understand: accepted, wrong_answer, time_limit_exceeded, memory_limit_exceeded, runtime_error and compilation_error, with the program's output and errors for visible tests.
  • Time limits: 2 seconds per test by default and up to 30, so a slow solution fails a large test the way it would on a judge.

The full list of fields, checkers and verdicts is in the run tests API reference. For a project with its own pytest, Jest, JUnit or xUnit tests, send the suite instead: see the pytest and Jest autograder and the Java autograder. SQL questions have their own guides, for SQLite and PostgreSQL.

Grade a folder of submissions into a gradebook

Put the tests in tests.json (the same list as "tests" above) and one file per student in submissions/. This script grades every file and writes grades.csv:

grade.py
import csv, json, pathlib, time
import requests  # pip install requests

API = "https://api.onlinecompiler.io/api/run-tests/"
KEY = "YOUR_API_KEY"
tests = json.loads(pathlib.Path("tests.json").read_text())

with open("grades.csv", "w", newline="") as f:
    grades = csv.writer(f)
    grades.writerow(["student", "verdict", "passed", "score"])
    for path in sorted(pathlib.Path("submissions").glob("*.py")):
        body = {"compiler": "python-3.14", "code": path.read_text(),
                "tests": tests, "scoring": "weighted"}
        while True:
            res = requests.post(API, json=body, headers={"Authorization": KEY}, timeout=90)
            if res.status_code != 429:
                break
            time.sleep(15)  # over the per-minute or pending limit: wait, then retry
        res.raise_for_status()
        result = res.json()
        grades.writerow([path.stem, result["verdict"],
                         f"{result['passed']}/{result['total']}", result["score"]])

Each test counts towards your plan's submissions a minute, so the plan sets the pace: 300 submissions of 10 tests take at least 50 minutes on Free, 10 on Starter and 5 on Pro. The script waits and retries when it gets HTTP 429.

Auto-graded coding quizzes

Form and quiz tools can't run code, so coding questions in them end up as "predict the output" multiple choice: what does for i in range(3): print(i * i) print? A student who picks the right option may have guessed. Ask for the code instead, and grade it by running it:

Terminal
curl -X POST https://api.onlinecompiler.io/api/run-tests/ \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "compiler": "python-3.14",
    "code": "n = int(input())\nfor i in range(1, n + 1):\n    print(i * i)",
    "tests": [
      {"input": "3\n", "expected_output": "0\n1\n4\n"},
      {"input": "5\n", "expected_output": "0\n1\n4\n9\n16\n"},
      {"input": "1\n", "expected_output": "0\n", "hidden": true}
    ],
    "scoring": "percent"
  }'

This student started the loop at 1. With "scoring": "percent" every test runs, so the response is wrong_answer with a score of 0, and each visible test returns what the program printed (1, 4 and 9 for the first): the student sees the off-by-one the multiple-choice question was testing. With range(n), the same request returns accepted and a score of 100. Your quiz page sends the answer to your server, which holds the key and the tests and makes the call, and an embedded editor lets students run their code before they submit.

If your quizzes are in Moodle, there is nothing to build: CodeRunner questions do this inside Moodle quizzes, and the hosted Jobe-compatible API runs them. See Moodle CodeRunner without a Jobe server.

GitHub Classroom has closed: where its autograding goes

GitHub retired GitHub Classroom on 28 August 2026. The website and its APIs are gone, and classroom and assignment names, tests defined outside repositories and LTI rosters were permanently deleted; student accounts and repositories were not affected. GitHub's migration page recommends two replacements:

  • Codio is a hosted learning platform with courseware, browser-based coding environments, auto grading, LMS single sign-on and grade passback, and plagiarism detection. Instructors get free access, and institutions sign a paid agreement (see Codio's pricing).
  • Classroom 50 is free and open source, from the Fifty Foundation. It keeps the GitHub-centred workflow: assignment repositories, inline feedback and grading by GitHub Actions in your own organization. It needs an organization on GitHub's Team or Enterprise plan (free for verified teachers through GitHub Education), and Actions minutes are an organization's to spend: one teacher reported 700 of the 3,000 included minutes used after one 150-student assignment, with grading set to run on every push.

OnlineCompiler.io covers a narrower job: grading what a program prints. Two ways fit courses that do not need students to work in GitHub repositories:

  • Grade with no student GitHub accounts. Students submit through your course site or LMS, and your script sends each submission to POST /api/run-tests/ with the assignment's tests. The score comes back in the response, so there is no organization, no Actions workflow and no minutes to watch.
  • Moodle CodeRunner. If your course already runs on Moodle, point CodeRunner at the hosted Jobe-compatible API, with nothing to install. See Moodle CodeRunner without a Jobe server.

Neither gives you repositories, rosters, deadlines or a gradebook; if the pull-request workflow is why you used GitHub Classroom, Classroom 50 is the closer replacement. If your tests were input and expected-output pairs, each one maps onto a test here:

GitHub Classroom input/output testRun tests API
commandcompiler and code: send the source, not a command
inputtests[].input
expected-outputtests[].expected_output
comparison-method exactchecker exact, or trim to forgive trailing whitespace
comparison-method included or regexNo matching checker: write the expected output in full, or check a visible test's output in your own code
timeout (minutes, 10 by default)time_limit (seconds, 2 by default, up to 30)
max-scoretests[].weight, with "scoring": "weighted"
setup-commandNone: runs have the language's standard library and no package installs

For a worked example, with real output, of moving a Classroom input/output test to a request and to a stored problem with hidden tests, see the guide how to keep auto-grading now that GitHub Classroom has closed.

Autograding software or an autograder API

Autograding software such as CodeGrade and Codio is a platform: it plugs into your LMS through LTI, takes the class list from it, gives students assignments to work on, grades them and passes the grades back to the gradebook. Both also check for plagiarism.

OnlineCompiler.io is only the grading engine, which you script against: one request grades one submission, and your course site, LMS plugin or script decides who submits what, when, and where the score goes. Pick a platform if you want rosters, grade passback and plagiarism checks without building anything. Pick the API if you already have a place where students submit, or you're building one.

What it doesn't do

  • Rosters, repositories and deadlines: your course site or LMS keeps them.
  • Grade passback: nothing posts to Canvas, Moodle or Blackboard; your code sends the score.
  • Plagiarism checks: compare submissions with a tool such as MOSS.
  • Packages and the internet: each run has the language's standard library, 512 MB of memory and no network. The security page has the details.

Building something closer to LeetCode, with problems and a submission queue? See how to build an online judge.

Frequently asked questions

What is an autograder API?

An HTTP API that runs a student's program against an assignment's test cases and returns the results, so your course site, LMS integration or grading script never runs student code itself. OnlineCompiler.io's returns a verdict for each test, an overall verdict and a score from 0 to 100, in 46 languages.

How do I give partial credit?

Give each test a weight equal to its points and send "scoring": "weighted". The score is the share of points earned, from 0 to 100, so a student who passes tests worth 5 of 10 points scores 50. "percent" counts every test the same, and "all_or_nothing" (the default) gives 100 or 0.

Can students see the hidden tests?

No. A hidden test comes back with only its verdict: no output, error, time or memory a student could read the input from. Compiler errors are returned only when at least one test is visible.

How much does autograding a course cost?

Each test is one run. 300 students making 30 graded submissions each against 10 tests, plus 50 other runs each, is 105,000 runs a month: Starter, at $10 a month. Smaller classes fit in the free 100,000 runs. The estimator on the pricing page works it out for your numbers.

Is this autograding software like CodeGrade or Codio?

No. CodeGrade and Codio are platforms: they plug into your LMS through LTI, take the class list from it and pass grades back to its gradebook. This is an autograder API: your course site or script sends a submission with its tests and gets verdicts and a score back. Rosters, grade passback and plagiarism checks stay with you.

Does it replace GitHub Classroom autograding?

It replaces the input/output tests: the program, its input, the expected output, a timeout and points. It does not replace rosters, assignment repositories or deadlines, which your course site or LMS keeps.

Can it run unit tests, such as pytest or JUnit?

Yes: pytest for Python, Jest, Mocha and node:test for JavaScript, JUnit for Java, and xUnit or NUnit for C#. Send the project's files with the suite and get each test back by name, the whole suite counting as one run (see the pytest and Jest autograder page). On Pro and above, a Python or JavaScript suite can also start a fresh PostgreSQL database, seeded with your data, for apps and SQL questions that need one. For the other languages, append a short driver to the submission that calls the function and prints the result, and compare that.