应用:下载应用
路由 URL
POST https://playcanvas.com/api/apps/download
说明
下载可在自己的服务器上托管的应用。请求会启动下载任务并返回详情,可以按 ID 轮询任务,直至状态为 complete 或 error。完成后,任务数据包含应用包下载 URL。
通过 format 选择包类型。省略或设为 static 时生成标准自行托管包,设为 npm 时生成基于 Vite 的 npm 项目。详见下载格式和 NPM 项目结构。
示例
curl -H "Authorization: Bearer {accessToken}" -H "Content-Type: application/json" -X POST -d '{"project_id": 9999999, "scenes": [9999999], "name": "My App", "format": "npm"}' "https://playcanvas.com/api/apps/download"
参数
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
project_id | number | ✔️ | 项目 ID。 |
name | string | ✔️ | 应用名称,必须少于 1000 个字符。 |
scenes | number[] | ✔️ | 应用包含的场景 ID 列表,列表中的第一个场景作为初始场景。 |
branch_id | string | 分支 ID,未指定时使用主分支。 | |
description | string | 应用描述,必须少于 10,000 个字符。 | |
version | string | 应用版本,字符串长度最多为 20 个字符。 | |
release_notes | string | 应用发布说明,字符串长度最多为 10,000 个字符。 | |
scripts_concatenate | boolean | 设为 true 可合并脚本。 | |
scripts_minify | boolean | 设为 true 可压缩脚本,默认为 true。 | |
scripts_sourcemaps | boolean | 设为 true 可生成脚本 Source Map,默认为 false。 | |
optimize_scene_format | boolean | 设为 true 可使用优化场景格式,详见优化场景格式。 | |
format | string | 下载包类型为 static 或 npm,默认为 static,详见下载项目。 | |
engine_version | string | 需要指定引擎时,填写版本字符串,详见全部发布版本。默认根据项目使用编辑器支持的最新主版本。 |
响应结构
Status: 201 Created
{
"status": "running" | "complete" | "error",
"messages": list of strings,
"created_at": date,
"modified_at": date,
"data": {
"concatenate": boolean,
"branch_id": string,
"optimize_scene_format": boolean,
"format": "static" | "npm",
"minify": boolean,
"name": string,
"sourcemaps": boolean,
"scenes": list of int scene ids,
"engineVersion": string,
"preload_bundle": boolean,
"project_id": int,
"owner_id": int
},
"id": int
}
错误
| 状态码 | 说明 |
|---|---|
| 401 | 未通过身份验证 |
| 403 | 禁止访问 |
| 404 | 未找到项目 |
| 404 | 未找到所有者 |
| 404 | 未找到场景 |
| 429 | 请求过多 |
请求限流
此路由采用严格限流。