读取沙箱日志
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
GET
/sandbox/v1/sandboxes/{sandboxID}/logs● 支持请求参数
sandboxIDstring必填path: 沙箱 ID。
cursorinteger可选query: 起始时间戳,单位为 Unix 毫秒。
limitinteger可选query: 最多返回的日志条数。
directionstring可选query: forward 按时间向后读取;backward 按时间向前读取。
levelstring可选query: 最低日志级别,低于该级别的日志会被过滤。
searchstring可选query: 按日志正文的子串筛选,区分大小写。
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/logs \
-H "X-API-Key: $PRAXIS_API_KEY"Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests
api_key = "$PRAXIS_API_KEY"
# Call /sandbox/v1 directly over HTTP.
resp = requests.get(
"https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/logs",
headers={"X-API-Key": api_key},
)
print(resp.status_code, resp.text)TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
const apiKey = "$PRAXIS_API_KEY";
// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/logs`, {
headers: { "X-API-Key": apiKey },
});
console.log(resp.status, await resp.text());响应示例 200
{
"logs": [
{
"timestamp": "2026-10-04T16:10:49.509781499Z",
"level": "debug",
"message": "Started creating sandbox",
"fields": {
"pid": "1"
}
}
]
}响应
HTTP 200
Successfully returned the sandbox logs
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| logs | array<object> | Sandbox logs structured |
| logs[].timestamp | string | Timestamp of the log entry |
| logs[].message | string | Log message content |
| logs[].level | string | State of the sandbox |
| logs[].fields | object | Structured key/value fields attached to the log line. |