|
通过托管OAuth认证访问Box API。管理文件、文件夹、协作、共享链接和云存储。
bash
https://gateway.maton.ai/box/2.0/{resource}
网关将请求代理到api.box.com/2.0(对于大多数端点)或upload.box.com/api/2.0(对于上传端点),并自动注入您的OAuth令牌。路由根据端点路径自动处理。
所有请求都需要在Authorization头中包含Maton API密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的API密钥设置为MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在https://ctrl.maton.ai管理您的Box OAuth连接。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=box&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
data = json.dumps({app: box}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connectionid: {connectionid},
status: ACTIVE,
creation_time: 2026-02-08T21:14:41.808115Z,
lastupdatedtime: 2026-02-08T21:16:10.100340Z,
url: https://connect.maton.ai/?session_token=...,
app: box,
metadata: {}
}
}
在浏览器中打开返回的url以完成OAuth授权。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个Box连接,请使用Maton-Connection头指定要使用的连接:
bash
python <
req = urllib.request.Request(https://gateway.maton.ai/box/2.0/users/me)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.addheader(Maton-Connection, {connectionid})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最旧的)活动连接。
bash
GET /box/2.0/users/me
响应:
json
{
type: user,
id: 48806418054,
name: Chris,
login: chris@example.com,
created_at: 2026-02-08T13:12:34-08:00,
modified_at: 2026-02-08T13:12:35-08:00,
language: en,
timezone: America/Los_Angeles,
space_amount: 10737418240,
space_used: 0,
maxuploadsize: 262144000,
status: active,
avatar_url: https://app.box.com/api/avatar/large/48806418054
}
bash
GET /box/2.0/users/{user_id}
根文件夹的ID为0:
bash
GET /box/2.0/folders/0
bash
GET /box/2.0/folders/{folder_id}
响应:
json
{
type: folder,
id: 365037181307,
name: My Folder,
description: Folder description,
size: 0,
path_collection: {
total_count: 1,
entries: [
{type: folder, id: 0, name: All Files}
]
},
created_by: {type: user, id: 48806418054, name: Chris},
owned_by: {type: user, id: 48806418054, name: Chris},
item_status: active
}
bash
GET /box/2.0/folders/{folder_id}/items
查询参数:
响应:
json
{
total_count: 1,
entries: [
{
type: folder,
id: 365036703666,
name: Subfolder
}
],
offset: 0,
limit: 100
}
bash
POST /box/2.0/folders
Content-Type: application/json
{
name: New Folder,
parent: {id: 0}
}
响应:
json
{
type: folder,
id: 365037181307,
name: New Folder,
created_at: 2026-02-08T14:56:17-08:00
}
bash
PUT /box/2.0/folders/{folder_id}
Content-Type: application/json
{
name: Updated Folder Name,
description: Updated description
}
bash
POST /box/2.0/folders/{folder_id}/copy
Content-Type: application/json
{
name: Copied Folder,
parent: {id: 0}
}
bash
DELETE /box/2.0/folders/{folder_id}
查询参数:
成功时返回204 No Content。
bash
GET /box/2.0/files/{file_id}
bash
GET /box/2.0/files/{file_id}/content
返回下载URL的重定向。
上传新文件(直接上传最多50 MB):
bash
POST /box/api/2.0/files/content
Content-Type: multipart/form-data
attributes={name:file.txt,parent:{id:0}}
file=<二进制数据>
attributes字段是一个JSON字符串,包含:
响应:
json
{
total_count: 1,
entries: [
{
type
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 box-1776419959 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 box-1776419959 技能
skillhub install box-1776419959
文件大小: 7.19 KB | 发布时间: 2026-4-17 18:26