跳转到正文

应用

App 是 Capgo 中的基础实体。每个 App 代表一个唯一的 Capacitor 应用,你可以通过平台对其进行管理和更新。Apps API 支持你进行 App 配置的增删改查。

Capgo 中的 App 代表你的 Capacitor 应用,包含:

  • App ID: 应用的唯一标识符
  • 名称: 应用的可读名称
  • 图标: 在 dashboard 中用于识别应用的视觉标识
  • 配置: 控制更新分发方式的设置
  • 所有权: 组织与用户访问权限信息
  • 使用统计: 关于安装与更新的指标数据
  1. 命名规范: 为你的应用使用清晰、易识别的名称
  2. 安全: 保护您的 API 密钥和访问凭据
  3. 组织: 将相关应用归到同一组织下
  4. 监控: 定期检查应用统计数据和性能
  5. 备份: 为关键应用维护配置备份

https://api.capgo.app/app/

获取您的应用信息。

  • page:选填。用于分页的页码
  • limit: 可选。每页结果数(默认:50)
  • org_id: 可选。通过组织 ID 筛选应用。若未提供,则返回用户有权访问的所有组织的 App

获取特定 App:

  • 在 URL 路径中使用 App ID: https://api.capgo.app/app/:app_id

注意: last_version 指该 App 上传的最后一个 bundle(版本)。

interface App {
app_id: string
block_provider_infra_requests: boolean
created_at: string | null
default_upload_channel: string
icon_url: string
id: string | null
last_version: string | null // last bundle (version) name
name: string | null
owner_org: string
retention: number
transfer_history: Json[] | null
updated_at: string | null
user_id: string | null
}
终端窗口
# Get all apps
curl -H "authorization: your-api-key" \
"https://api.capgo.app/app/"
# Get apps from a specific organization
curl -H "authorization: your-api-key" \
"https://api.capgo.app/app/?org_id=046a36ac-e03c-4590-9257-bd6c9dba9ee8"
# Get specific app
curl -H "authorization: your-api-key" \
"https://api.capgo.app/app/com.demo.app"
{
"data": [
{
"block_provider_infra_requests": true,
"app_id": "com.demo.app",
"created_at": "2024-01-01T00:00:00Z",
"default_upload_channel": "dev",
"icon_url": "https://example.com/icon.png",
"id": "550e8400-e29b-41d4-a716-446655440000",
"last_version": "1.0.0",
"name": "Demo App",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8",
"retention": 2592000,
"transfer_history": null,
"updated_at": "2024-01-01T00:00:00Z",
"user_id": "6aa76066-55ef-4238-ade6-0b32334a4097"
}
]
}

https://api.capgo.app/app/

创建一个新应用。

interface CreateApp {
app_id: string
name: string
icon?: string
owner_org: string
}
终端窗口
# Create new app
curl -X POST \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "My New App",
"app_id": "com.demo.myapp", // this id is unique in Capgo This cannot be reused by any account.
"icon": "https://example.com/icon.png",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8"
}' \
https://api.capgo.app/app/
{
"block_provider_infra_requests": true,
"app_id": "My New App",
"created_at": "2024-01-01T00:00:00Z",
"default_upload_channel": "dev",
"icon_url": "https://example.com/icon.png",
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "My New App",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8",
"retention": 2592000,
"updated_at": "2024-01-01T00:00:00Z"
}

https://api.capgo.app/app/:app_id

更新现有应用。应用 ID 在 URL 路径中指定。

interface UpdateApp {
block_provider_infra_requests?: boolean
name?: string
icon?: string
retention?: number
}
终端窗口
curl -X PUT \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"block_provider_infra_requests": true,
"name": "Updated App Name",
"icon": "https://example.com/updated-icon.png",
"retention": 45
}' \
https://api.capgo.app/app/com.demo.app
{
"app_id": "com.demo.app",
"created_at": "2024-01-01T00:00:00Z",
"default_upload_channel": "dev",
"block_provider_infra_requests": true,
"icon_url": "https://example.com/updated-icon.png",
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Updated App Name",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8",
"retention": 45,
"updated_at": "2024-01-01T00:00:00Z"
}

https://api.capgo.app/app/:app_id

删除应用及其所有关联资源。应用 ID 在 URL 路径中指定。请务必极其谨慎,此操作无法撤销。

终端窗口
curl -X DELETE \
-H "authorization: your-api-key" \
https://api.capgo.app/app/com.demo.app
{
"status": "ok"
}

所有错误均采用以下文档中描述的标准错误格式: API 概览.

常见的错误场景及其响应:

// Missing or invalid API key (HTTP 401)
{
"error": "invalid_apikey",
"message": "Invalid apikey",
"moreInfo": {}
}
// app_id is not a reverse-domain identifier
{
"error": "invalid_app_id",
"message": "App ID must be a reverse domain string",
"moreInfo": { "app_id": "my app" }
}
// The API key has no access to this app (HTTP 401)
{
"error": "cannot_access_app",
"message": "You can't access this app",
"moreInfo": { "app_id": "com.example.app" }
}
// Creating an app in an organization the key cannot write to (HTTP 403)
{
"error": "cannot_access_organization",
"message": "You can't access this organization",
"moreInfo": { "org_id": "046a36ac-e03c-4590-9257-bd6c9dba9ee8" }
}
// Retention above the two-year limit on update
{
"error": "retention_to_big",
"message": "Retention cannot be bigger than 63113903 (2 years)",
"moreInfo": { "retention": 99999999 }
}
  1. 创建新 App
// Set up a new app
{
"name": "Production App",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8"
}
  1. 更新 App 配置
// Change app name and icon
{
"name": "Rebranded App Name",
"icon": "https://example.com/new-icon.png"
}
  1. 设置保留策略
// Configure automatic bundle cleanup
{
"retention": 30 // Keep bundles for 30 days
}
  1. 按组织获取 App
终端窗口
# List all apps in a specific organization
curl -H "authorization: your-api-key" \
"https://api.capgo.app/app/?org_id=046a36ac-e03c-4590-9257-bd6c9dba9ee8"
  1. 存储优化: 监控存储使用情况并设置合理的保留策略
  2. 组织: 将相关应用归类到同一个组织下
  3. 访问控制: 管理团队成员对应用设置的修改权限
  4. 备份策略: 备份关键的应用配置与设置

如果你正在使用 应用 要规划 dashboard 和 API 操作,请将其连接到 API 概览 关于 API Overview 中的实现细节, 简介 关于 Introduction 中的实现细节, API 密钥 有关 API Keys 的实现细节, 设备 有关 Devices 的实现细节,以及 Bundle 有关 Bundles 中的实现细节。