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 structured 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 recommended Pro for the 60s timeout, up to 2 concurrent sessions per RapidAPI account, stable direct-artifact pip/npm install, and up to 50 accepted items per batch. Move to Ultra for 150s sync/session work, 300s production async jobs, up to 100 accepted items per batch, and a 5-session per-account ceiling. Choose Mega for 200,000 requests per RapidAPI subscription period, 150s sync/session work, 600s production async jobs, up to 200 accepted items per batch, and an 8-session per-account ceiling. Items run through bounded workers and the entire batch request has a 150-second wall-clock budget under RapidAPI's 180-second gateway maximum. Session caps are per-RapidAPI-account ceilings. Shared service capacity is not reserved; during saturation, session creation may return HTTP 503 with Retry-After.

Start with Pro

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

Subscribe to Pro Execution docs