跳过内容

应用

在 Capgo 中,应用程序是基本的实体。每个应用程序代表一个独特的 Capacitor 应用程序,您可以通过平台管理和更新该应用程序。API 中的应用程序允许您创建、检索、更新和删除应用程序配置。

在 Capgo 中的一个应用程序代表您的 Capacitor 应用程序,包括:

  • 应用 ID: 你的应用程序的唯一标识符
  • 名称应用程序的名称
  • 图标应用程序的可视标识符
  • 配置应用程序更新的传递方式
  • 所有权组织和用户访问信息
  • 使用统计应用程序安装和更新的指标

最佳实践

最佳实践
  1. 命名约定: 使用清晰、可识别的名称为您的应用
  2. 安全: 保护您的 API 密钥和访问凭证
  3. 组织: 将相关应用分组到同一组织
  4. 监控: 定期检查应用统计和性能
  5. 备份: 为关键应用维护配置备份

端点

端点

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

获取应用程序信息。

  • page: 可选。分页时的页码
  • limit: 可选。每页显示的结果数量(默认值:50)
  • org_id: 可选。通过组织 ID 过滤应用程序。如果未提供,则返回用户有访问权限的所有组织的应用程序

获取特定应用程序:

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

注意: last_version 最后一次上传的应用程序包(版本)

interface App {
app_id: string
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": [
{
"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/

创建新应用

Request Body

请求体
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/
{
"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 路径中指定。

__CAPGO_KEEP_0__

标题:请求体
interface UpdateApp {
name?: string
icon?: string
retention?: number
}
终端窗口
curl -X PUT \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"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",
"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"
}

常见错误场景和响应:

// App not found
{
"error": "App not found",
"status": "KO"
}
// Duplicate custom ID
{
"error": "Custom ID already in use",
"status": "KO"
}
// Invalid parameters
{
"error": "Invalid app configuration",
"status": "KO"
}
// Permission denied
{
"error": "Insufficient permissions to manage app",
"status": "KO"
}
// Organization access denied
{
"status": "You do not have access to this organization"
}

常见用例

常见用例
  1. 创建新应用
// Set up a new app
{
"name": "Production App",
"owner_org": "046a36ac-e03c-4590-9257-bd6c9dba9ee8"
}
  1. 更新应用配置
// 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. 按组织获取应用
终端窗口
# 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. 备份策略:备份关键应用程序配置和设置

继续从应用程序

继续从应用程序部分

如果您正在使用 应用 来规划仪表板和API操作,连接它与 API概览 了解API概览中的实现细节在 介绍 了解介绍中的实现细节在 API密钥 了解API密钥中的实现细节在 设备 了解设备中的实现细节在 捆绑包 for the implementation detail in Bundles.