列出权益
列出成员的 Entitlement 实例。鉴权应使用 hasEntitlement() 而非直接查询 Product。此 API 供服务端同步与调试。
GET
/v1/entitlements参数
| 参数 | 类型 | 位置 | 说明 |
|---|---|---|---|
Authorization必填 | string | Header | Bearer {secret_key} |
member_id必填 | string | Query | 成员 ID。 |
identifier可选 | string | Query | 按权益标识符过滤,如 premium。 |
请求示例
HTTP
GET /v1/entitlements?member_id=mem_001 HTTP/1.1
Host: api.subhub.dev
Authorization: Bearer sk_live_neostudio_8f3k2m9x4l0p7q2r5s8u1v响应示例
HTTP
HTTP/1.1 200 OK
Content-Type: application/json
{
"object": "list",
"data": [
{
"id": "ent_001",
"member_id": "mem_001",
"identifier": "premium",
"product_id": "prod_01PROMO",
"is_active": true,
"expires_at": "2026-07-27T18:32:00.000Z",
"granted_at": "2026-06-27T18:32:00.000Z"
},
{
"id": "ent_031",
"member_id": "mem_001",
"identifier": "remove_ads",
"product_id": "prod_13REMOVEIOS",
"is_active": true,
"expires_at": null,
"granted_at": "2026-06-10T12:00:00.000Z"
}
]
}代码示例
// 客户端推荐使用 SDK
let hasPremium = try await SubHub.hasEntitlement("premium")
let all = try await SubHub.entitlements()
// 服务端查询
var components = URLComponents(string: "https://api.subhub.dev/v1/entitlements")!
components.queryItems = [URLQueryItem(name: "member_id", value: "mem_001")]