读取沙箱日志
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
GET
/e2b/v2/sandboxes/{sandboxID}/logs● 支持请求参数
sandboxIDstring必填path:
cursorinteger可选query: 起始时间戳,单位为 Unix 毫秒。
limitinteger可选query: 最多返回的日志条数。
directionstring可选query: forward 按时间向后读取;backward 按时间向前读取。
levelstring可选query: 最低日志级别,低于该级别的日志会被过滤。
searchstring可选query: 按日志正文的子串筛选,区分大小写。
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/e2b/v2/sandboxes/sbx_123/logs \
-H "X-API-Key: $PRAXIS_API_KEY"Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests
opts = dict(
api_key="$PRAXIS_API_KEY",
api_url="https://api.deepraxis.com/e2b",
domain="sandbox.praxisusercontent.com",
)
# Read the v2 sandbox logs over HTTP.
resp = requests.get(
f"{opts['api_url']}/v2/sandboxes/sbx_123/logs",
headers={"X-API-Key": opts["api_key"]},
)
print(resp.json())TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
const opts = {
apiKey: "$PRAXIS_API_KEY",
apiUrl: "https://api.deepraxis.com/e2b",
domain: "sandbox.praxisusercontent.com",
};
// Read the v2 sandbox logs over HTTP.
const resp = await fetch(`${opts.apiUrl}/v2/sandboxes/sbx_123/logs`, {
headers: { "X-API-Key": opts.apiKey },
});
console.log(await resp.json());响应示例 200
{
"logs": [
{
"timestamp": "2026-10-04T16:11:20.455459068Z",
"level": "info",
"message": "Sandbox created",
"fields": {
"pid": "1"
}
},
{
"timestamp": "2026-10-04T16:11:20.017565389Z",
"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 |