For coding-interview & assessment platforms

Build coding interviews that grade themselves

Run candidate code together with your grading harness in a secure sandbox, capture stdout/stderr, and return a deterministic verdict to your product. Start with 8 modern languages, streaming output, batch execution, and gVisor isolation.

The grading primitive

SandboxAPI tells you whether the sandboxed run completed, failed, or timed out. Your harness owns the domain verdict: which tests passed, what feedback to show, and how to score the submission.

completed The process exited cleanly. Parse stdout for your harness verdict.
timeout The candidate code exceeded the execution budget.
error The compiler, interpreter, or program returned a non-zero exit code.

Single-call grading with a harness

For interview-style problems, send a small wrapper that combines the candidate's function with your hidden tests and prints a machine-readable verdict.

# The harness runs inside the sandbox and prints JSON.
curl -X POST https://sandboxapi.p.rapidapi.com/v1/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{
    "language": "python3",
    "timeout": 30,
    "code": "import json\n\ndef solve(nums):\n    return sum(nums)\n\ncases = [([1,2,3], 6), ([10,-4], 6)]\npassed = sum(1 for inp, exp in cases if solve(inp) == exp)\nprint(json.dumps({\"passed\": passed, \"total\": len(cases)}))"
  }'

Verdict in one round trip

The API response gives you execution metadata and the harness output. Your product maps that into candidate-facing feedback.

{
  "id": "exec_xyz",
  "status": "completed",
  "language": "python3",
  "stdout": "{\"passed\":2,\"total\":2}\n",
  "stderr": "",
  "exit_code": 0,
  "execution_time_ms": 187,
  "memory_used_kb": 12544,
  "timeout": 30,
  "created_at": "2026-06-25T10:00:00Z"
}

Map status straight into your candidate-facing UI:

Multi-language support

The same endpoint runs Python, JavaScript, TypeScript, Bash, Java, C, C++, and Go. Keep one API integration and swap the language field plus your per-language harness template.

End-to-end Python example

import requests
import json

def build_python_harness(candidate_code: str) -> str:
    return f"""{candidate_code}

import json
cases = [([1, 2, 3], 6), ([10, -4], 6)]
passed = sum(1 for inp, exp in cases if solve(inp) == exp)
print(json.dumps({{"passed": passed, "total": len(cases)}}))
"""

def grade_python(candidate_code: str, time_limit=10):
    payload = {
        "language": "python3",
        "code": build_python_harness(candidate_code),
        "timeout": time_limit,
    }
    r = requests.post(
        "https://sandboxapi.p.rapidapi.com/v1/execute",
        headers={"X-RapidAPI-Key": API_KEY, "Content-Type": "application/json"},
        json=payload,
    )
    return r.json()

# Grade a candidate's solution
result = grade_python(candidate_code)

# Map verdict to candidate-facing message
if result["status"] == "completed":
    verdict = json.loads(result["stdout"])
    print(f"Passed {verdict['passed']} of {verdict['total']} cases.")
elif result["status"] == "timeout":
    print("Time limit exceeded.")
else:
    print("Code failed:", result["stderr"][:500])

Why teams pick SandboxAPI for assessments

Recommendation: start on Pro for the 60s timeout, sessions, package install, async polling, and 50-snippet batches. Move to Ultra at scale for 300s timeouts and 100-snippet batches.

Start with Pro

Pro is $19/month for 10,000 executions, 60s timeouts, and 50-snippet batches — enough headroom for most coding-assessment workloads from day one.

Subscribe to Pro Execution docs