API Reference
HTTP endpoints exposed by the Gin server for upload and sandboxed execution.
Endpoints
| Method | Path | Handler | Description |
|---|---|---|---|
POST |
/upload |
handler.Upload |
Store a script in Redis |
POST |
/run/*targetPath |
handler.Run |
Execute a stored script |
POST |
/run-now |
handler.RunNow |
Execute submitted code immediately |
POST /upload
Upload and store a script, returning a version timestamp.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | Access path; must not contain .. |
code |
string |
Yes | Source code |
language |
string |
Yes | python, javascript, or typescript |
Success response
{
"path": "math/add",
"language": "python",
"version": 1739000000
}
Errors
| Status | When |
|---|---|
400 |
Invalid JSON, path with .., unsupported language |
500 |
Redis write failure |
POST /run/*targetPath
Load code from Redis and run it in the sandbox. Path param is the script path after /run/.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
version |
int64 |
No | Timestamp version; invalid/missing uses latest |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
input |
string |
No | JSON string available as event / input |
stream |
bool |
No | Enable SSE streaming |
code / language in the body are overwritten by Redis metadata.
Success (non-stream)
{
"data": 8,
"type": "number"
}
Errors
| Status | When |
|---|---|
400 |
Invalid body |
404 |
Script or version not found |
500 |
Sandbox failure / timeout |
POST /run-now
Execute without Redis storage.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
code |
string |
Yes | Source code |
language |
string |
Yes | python, javascript, or typescript |
input |
string |
No | JSON string input |
stream |
bool |
No | Enable SSE |
Errors
| Status | When |
|---|---|
400 |
Unsupported language, empty code, bad JSON |
500 |
Execution failure |
Response type values
type |
Meaning |
|---|---|
string |
JSON string |
number |
Numeric JSON value |
json |
Object or array |
text |
Non-JSON output |
SSE format
With stream: true, each event is:
data: {"event":"log","data":"0","type":"text"}
data: {"event":"result","data":"done","type":"string"}
event |
Meaning |
|---|---|
log |
Intermediate stdout line |
result |
Final return value |
error |
Failure message |
Headers: Content-Type: text/event-stream, Cache-Control: no-cache, Connection: keep-alive.
Supported languages
| Language | Runtime | Extension | Globals |
|---|---|---|---|
| Python | python3 |
.py |
event, input |
| JavaScript | node |
.js |
event, input |
| TypeScript | tsx |
.ts |
event, input |
Examples
Upload:
curl -X POST http://localhost:8080/upload \
-H "Content-Type: application/json" \
-d '{"path":"math/add","language":"python","code":"return event.get(\"a\", 0) + event.get(\"b\", 0)"}'
Run latest:
curl -X POST http://localhost:8080/run/math/add \
-H "Content-Type: application/json" \
-d '{"input":"{\"a\": 3, \"b\": 5}"}'
Run-now with stream:
curl -X POST http://localhost:8080/run-now \
-H "Content-Type: application/json" \
-d '{"language":"python","code":"return 1","input":"{}","stream":true}'