跳转到正文

设备

Device 指的是向 Capgo 上报 updater 元数据的单个 App 安装实例。你可以通过该 API 来获取这些元数据,或者设置与特定设备关联的 private-channel 覆盖参数。

每条记录都可以包含设备 ID、平台、updater 和 OS 版本、Native Build、已安装的 bundle、生产环境与模拟器状态、自定义 ID 以及 channel override。

如果可用, country_code 是来自 Cloudflare 处理的设备请求中收到的最新的、有效的两位 ISO 3166-1 国家 code。它不是 GPS 或由您的应用提供的位置值。它可以是 null 若不可用;在需要此字段时,请使用单设备查询。

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

将特定设备的覆盖设置到 私有 channel。若要为特定设备选择 bundle,请将该 bundle 分配给该 channel;暂不支持直接进行单设备 bundle 覆盖。除非再次执行 POST,否则覆盖将在最后一次写入 90 天后过期。

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: 必填,反向域名格式的 App 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/

移除设备的 channel override。设备将重新使用正常的 channel 选择逻辑;此 endpoint 不会删除其元数据记录。

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 错误状态码和包含 error 以及 message 字段的 JSON 响应体。常见错误码包括:

  • invalid_app_id 何时 app_id 不是反向域名标识符。
  • device_not_found 查询未知设备时返回。
  • channel_not_found 当请求的 channel 不存在时。
  • public_channel_override 当尝试将设备覆盖到公共 channel 时。
  • invalid_version_id 当尝试直接覆盖 bundle 时;请改用 channel。
  • cannot_access_app 或 cannot_access_channel 当 API 密钥缺少所需权限时。

常见使用场景

“常见用例”章节
  1. 将测试设备移至私有 Beta 测试频道

    {
    "app_id": "com.example.app",
    "device_id": "device_456",
    "channel": "beta"
    }
  2. 将设备重置为常规频道选择

    使用 DELETE 包含 App ID 和 Device ID 的端点。

如果你正在使用 设备 要规划 Channel 路由和分阶段发布,请将其与 通道 有关 Channels 的实现细节, 通道 有关 Channels 的实现细节, 通道 有关 Channels 的实现细节, Beta 测试解决方案 适用于 Beta Testing Solution 产品工作流的,以及 版本定向解决方案 适用于 Version Targeting Solution 产品工作流的。