Runnable examples for executing code in SandboxAPI's isolated sandboxes.
Subscribe to SandboxAPI on RapidAPI and copy your key. Set it in the terminal where you run these examples:
export RAPIDAPI_KEY='YOUR_RAPIDAPI_KEY'Keep your real key out of source files and Git commits. Requests use the
RapidAPI endpoint at https://sandboxapi.p.rapidapi.com.
Requires Python 3; uses only the standard library.
python3 execute.pyThe example executes print(2 + 2) and prints 4.
Requires Node.js 18 or newer; no npm dependencies.
node execute.mjsThe example executes console.log(2 + 2) and prints 4.
curl --fail-with-body --show-error --silent \
https://sandboxapi.p.rapidapi.com/v1/execute \
-H "Content-Type: application/json" \
-H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
-H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
-d '{"language":"python3","code":"print(2 + 2)"}'Inspect the response's status, stdout, stderr, and exit_code: a successful
HTTP response can still report an error in the submitted code.
- API documentation and code examples
- Interactive playground
- MCP client setup
- Plans and API subscription
These examples call your subscribed RapidAPI endpoint and count toward your plan's request allowance. The examples are licensed under MIT.