Execute JavaScript and TypeScript code in a secure, isolated sandboxed environment. No network access, no filesystem, pure computation. Ideal for agents that need to run calculations, transform data, test logic, or generate outputs programmatically.
Includes 25 free calls per month
After the free quota, standard per-request pricing applies via x402 (USDC on Base).
Execute JavaScript or TypeScript code in a sandboxed environment. Returns the result, console output, and execution time. Network access is blocked for security.
Request schema
JavaScript or TypeScript code to execute. Use return to send back a value.
Language (default: javascript)
Max execution time in ms (default: 5000, max: 10000)
Response schema
Return value from the code
Captured console.log/warn/error output
JavaScript type of the result
Easiest way: the APIHub CLI. Credits cover x402, no wallet needed.
# install and set up once
npx @apihubio/cli register
npx @apihubio/cli topup 10
# call this service
npx @apihubio/cli call "https://proxy.apihub.io/code-sandbox/execute" \
-d '{"code":"example code","language":"javascript","timeout":0}'Or call the proxy directly (curl / any HTTP client):
curl -X POST https://proxy.apihub.io/code-sandbox/execute \
-H "Authorization: Bearer ahk_your_key" \
-H "Content-Type: application/json" \
-d '{"code":"example code","language":"javascript","timeout":0}'
# If credits available: charged automatically, returns 200
# Otherwise: returns 402 (pay via @x402/fetch or top up credits)Estimate your monthly cost for Code Sandbox.