跳转到内容
EN

列出文件

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET/sandbox/v1/sandboxes/{sandbox_id}/files:list● 支持

请求参数

  • 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:list?path=/tmp/docs-files" \
  -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:list?path=/tmp/docs-files",
    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:list?path=/tmp/docs-files`, {
  headers: { "X-API-Key": apiKey },
});
console.log(resp.status, await resp.text());

响应示例 200

[
  {
    "name": "hello.txt",
    "path": "/tmp/docs-files/hello.txt",
    "size": 18,
    "type": "file"
  }
]

响应

HTTP 200

Operation completed

application/json

名称 类型 说明
[].name string Entry basename.
[].path string Entry path in the sandbox.
[].type string file is a regular file, dir a directory, symlink a symbolic link.
[].size number Entry size in bytes.

准备示例文件

在新建沙箱中,先运行写入文件的示例,创建 /tmp/docs-files/hello.txt 及父目录,再运行本页示例。使用自己的文件时替换 path。试用后调用删除沙箱清理沙箱及其中的文件。