← Back to marketplace

Code Sandbox

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.

infra
by APIHub1 endpoint100% uptime28ms avg

Includes 25 free calls per month

After the free quota, standard per-request pricing applies via x402 (USDC on Base).

Endpoints

POST/execute
$0.0020/req

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

codestringrequired

JavaScript or TypeScript code to execute. Use return to send back a value.

languagestring

Language (default: javascript)

timeoutnumber

Max execution time in ms (default: 5000, max: 10000)

Response schema

okboolean
resultunknown

Return value from the code

logsarray

Captured console.log/warn/error output

execution_time_msnumber
typestring

JavaScript type of the result

Quick start

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)

Pricing calculator

Estimate your monthly cost for Code Sandbox.

POST /execute$0.0020/req
-