跳过内容

设备

设备是单独的应用程序安装,向 Capgo 报告更新器元数据。使用此 API 来检索该元数据或设置和删除设备特定的私有频道重写。

每个记录都可以包含设备 ID、平台、更新器和操作系统版本、原生构建、安装的捆绑包、生产和模拟器状态、自定义 ID 和渠道覆盖。

当可用时 country_code 是最新的有效的两位字母 ISO 3166-1 国家 code,从设备处理的 Cloudflare 请求中接收。它不是 GPS 或您的应用程序提供的位置值。它可以 null 当不可用时;在需要此字段时使用单设备查找。

API端点

Endpoints

POST

POST

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

为设备设置特定的覆盖 私有 频道。要为设备选择一个包,分配该包到频道;不支持直接为设备设置包的覆盖。覆盖在最后一次写入后90天过期,除非您再次POST它。

请求体

请求体
interface DeviceChannelOverride {
app_id: string; // reverse-domain app ID, for example com.example.app
device_id: string;
channel: string; // existing non-public channel name
}

示例请求

示例请求
终端窗口
curl -X POST \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "com.example.app",
"device_id": "device_456",
"channel": "beta"
}' \
https://api.capgo.app/device/

公共频道不能用作设备覆盖

{
"status": "ok"
}

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

获取设备元数据。结果在省略时使用游标分页 device_id.

  • app_id: 必须的反向域应用ID,例如 com.example.app.
  • device_id: 可选设备ID。当存在时,响应是一个单个设备而不是分页列表。
  • customIdMode: 可选布尔值。设置为 true 仅返回非空设备 custom_id.
  • cursor: 上一次列表响应中的游标。
  • limit: 每页设备数量。
终端窗口
# Get the first page
curl -H "authorization: your-api-key" \
"https://api.capgo.app/device/?app_id=com.example.app"
# Get one device, including its request-derived country when available
curl -H "authorization: your-api-key" \
"https://api.capgo.app/device/?app_id=com.example.app&device_id=device_456"
# Get only devices with a custom ID
curl -H "authorization: your-api-key" \
"https://api.capgo.app/device/?app_id=com.example.app&customIdMode=true"
# Get the next page
curl -H "authorization: your-api-key" \
"https://api.capgo.app/device/?app_id=com.example.app&cursor=2024-01-01T00:00:00Z%7Cdevice_456"
interface DeviceListResponse {
data: Device[];
nextCursor?: string;
hasMore: boolean;
}
interface Device {
updated_at: string;
device_id: string;
custom_id: string;
version?: number;
version_name: string | null;
channel?: string;
app_id: string;
platform: "ios" | "android" | "electron";
plugin_version: string;
os_version: string;
version_build: string;
is_prod: boolean;
is_emulator: boolean;
key_id: string | null;
install_source: string | null;
country_code: string | null;
}

country_code 当Capgo存储了一个有效的Cloudflare-派生国家code时,会通过设备特定查找填充此项。没有有效国家的请求不会清除最后一个有效值;列表响应可能返回 null 为此字段。

示例响应(列表)

标题:示例响应(列表)
{
"data": [
{
"device_id": "device_456",
"custom_id": "test-device-1",
"version": 1,
"version_name": "1.0.0",
"app_id": "com.example.app",
"platform": "ios",
"plugin_version": "5.0.0",
"os_version": "17.0",
"version_build": "1",
"is_prod": true,
"is_emulator": false,
"key_id": null,
"install_source": null,
"country_code": null,
"updated_at": "2024-01-01T00:00:00Z"
}
],
"nextCursor": "2024-01-01T00:00:00Z|device_456",
"hasMore": true
}

示例响应(单个设备)

标题:示例响应(单个设备)
{
"device_id": "device_456",
"custom_id": "test-device-1",
"version": 1,
"version_name": "1.0.0",
"app_id": "com.example.app",
"platform": "ios",
"plugin_version": "5.0.0",
"os_version": "17.0",
"version_build": "1",
"is_prod": true,
"is_emulator": false,
"key_id": "MIIB",
"install_source": null,
"country_code": "FR",
"updated_at": "2024-01-01T00:00:00Z",
"channel": "beta"
}

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

删除设备的频道重写。设备将使用其正常的频道选择;此端点不会删除其元数据记录。

请求体或查询参数

标题:请求体或查询参数
interface DeviceOverrideRemoval {
app_id: string;
device_id: string;
}
终端窗口
curl -X DELETE \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "com.example.app",
"device_id": "device_456"
}' \
https://api.capgo.app/device/
{
"status": "ok"
}

错误使用 HTTP 错误状态和一个 JSON 体 errormessage fields. 常见错误代码包括:

  • invalid_app_idapp_id 不是一个逆向域名标识符。
  • device_not_found 用于未知设备查找。
  • channel_not_found 当请求的频道不存在时。
  • public_channel_override 尝试覆盖设备到公共频道时。
  • invalid_version_id 尝试直接覆盖捆绑包时,请使用频道代替。
  • cannot_access_appcannot_access_channel when the API key lacks the required permission.

当__CAPGO_KEEP_0__密钥缺少所需的权限时。

常见用例
  1. 常见用例

    {
    "app_id": "com.example.app",
    "device_id": "device_456",
    "channel": "beta"
    }
  2. 重置设备到正常渠道选择

    使用 DELETE 带有应用程序和设备 ID 的端点。

如果您正在使用 设备 来规划渠道路由和阶段性发布,连接它到 渠道 上下文:Capgo 发布渠道功能名称。页面/区域:Capgo 解决方案营销页面。角色:短 UI 标签或导航项。见于:页面解决方案/白标签.astro。消息键 `solutions_white_label_visual_cell2_value` (解决方案白标签视觉单元2值)。 了解渠道的实现细节在渠道中, 为 Channels 的实现细节 Channels 为 Channels 的实现细节 Beta 测试解决方案 为 Beta 测试解决方案的产品工作流 版本目标解决方案 为版本目标解决方案的产品工作流