跳转到正文

设备

设备是向 Capgo 报告更新器元数据的单个应用安装实例。使用此 API 可获取该元数据,或设置和移除特定于设备的私有通道覆盖。

每条记录可包含设备 ID、平台、updater 和操作系统版本、Native Build、已安装的 bundle、生产环境与模拟器状态、自定义 ID 以及通道覆盖项。

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

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

将设备专属覆盖设置为 私有 通道。要为设备选择 bundle,请将该 bundle 分配给该通道;不支持直接按设备覆盖 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 包含应用和设备 ID 的 endpoint。

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