Execute Python Code
Copy
curl -X POST http://localhost:8002/api/v1/execute \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "print(\"Hello, World!\")\nprint(2 + 2)",
"language": "python"
}'
Copy
{
"execution_id": "exec-123",
"stdout": "Hello, World!\n4\n",
"stderr": "",
"exit_code": 0,
"execution_time": 0.123,
"language": "python"
}
Execute JavaScript
Copy
curl -X POST http://localhost:8002/api/v1/execute \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "console.log(\"Hello from Node.js\");",
"language": "javascript"
}'
With Standard Input
Copy
curl -X POST http://localhost:8002/api/v1/execute \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "name = input(\"Enter name: \")\nprint(f\"Hello, {name}!\")",
"language": "python",
"stdin": "Nadoo"
}'
With Custom Timeout
Copy
curl -X POST http://localhost:8002/api/v1/execute \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "import time\ntime.sleep(5)\nprint(\"Done!\")",
"language": "python",
"timeout": 10
}'
Async Execution
Copy
# Submit code
curl -X POST http://localhost:8002/api/v1/execute/async \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"code": "print(\"Async execution\")",
"language": "python"
}'
# Get status
curl http://localhost:8002/api/v1/execute/status/exec-123 \
-H "X-API-Key: your-api-key"