读取文件
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
GET
/sandbox/v1/sandboxes/{sandbox_id}/files● 支持请求参数
sandbox_idstring必填path: Sandbox ID returned by sandboxes.create or sandboxes.list.
pathstring必填query: File or directory path inside the sandbox; relative paths use the user's home directory.
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl "https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/files?path=/tmp/docs-files/hello.txt" \
-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/files?path=/tmp/docs-files/hello.txt",
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/files?path=/tmp/docs-files/hello.txt`, {
headers: { "X-API-Key": apiKey },
});
console.log(resp.status, await resp.text());响应示例 200
Hello from Praxis!响应
HTTP 200
Operation completed
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| $ | string | File content as UTF-8 text. |
准备示例文件
在新建沙箱中,先运行写入文件的示例,创建 /tmp/docs-files/hello.txt 及父目录,再运行本页示例。使用自己的文件时替换 path。试用后调用删除沙箱清理沙箱及其中的文件。