我们正在更新 Data API,以便与 YouTube 统计 Shorts 短视频观看次数的方式保持一致。
了解详情
MembershipsLevels: list
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
注意:只有个人创作者可以使用此端点为自己已启用频道会员功能的 YouTube 频道提出请求。如需申请访问权限,请与您的 Google 或 YouTube 代表联系。
列出授权了请求的频道的会员级别。关卡按隐式显示顺序返回。向此方法发出的 API 请求会产生以下响应之一:
对配额的影响:调用此方法的配额费用为 1 个单位。
请求
HTTP 请求
GET https://www.googleapis.com/youtube/v3/membershipsLevels
此请求需要获得以下范围的授权:
范围 |
https://www.googleapis.com/auth/youtube.channel-memberships.creator |
参数
下表列出了此查询支持的参数。列出的所有参数都是查询参数。
参数 |
必需参数 |
part |
string
part 参数指定 API 响应将包含的 membershipsLevel 资源属性。参数值是以英文逗号分隔的资源部分列表。以下列表显示了可检索的部分:
|
响应
如果成功,此方法将返回采用以下结构的响应正文:
{
"kind": "youtube#membershipsLevelListResponse",
"etag": etag,
"items": [
membershipsLevel Resource
]
}
属性
下表定义了此资源中显示的属性:
属性 |
kind |
string 标识 API 资源的类型。其值为 youtube#membershipsLevelListResponse 。 |
etag |
etag
此资源的 Etag。 |
items[] |
list
授权 API 请求的频道所拥有的 membershipsLevel 资源的列表。 |
错误
下表列出了 API 在响应对此方法的调用时可能会返回的错误消息。如需了解详情,请参阅错误消息文档。
错误类型 |
错误详情 |
说明 |
badRequest (400) |
channelMembershipsNotEnabled |
批准该请求的创作者频道未启用频道会员功能。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-04-26。
[null,null,["最后更新时间 (UTC):2024-04-26。"],[[["\u003cp\u003eThis API endpoint allows individual YouTube creators with channel memberships enabled to retrieve a list of their channel's membership levels.\u003c/p\u003e\n"],["\u003cp\u003eThe API response will either include a list of membership levels, an empty list if memberships are enabled but no levels are set, or an error if memberships are not enabled.\u003c/p\u003e\n"],["\u003cp\u003eA successful request returns a JSON response containing the resource type, Etag, and a list of \u003ccode\u003emembershipsLevel\u003c/code\u003e resources.\u003c/p\u003e\n"],["\u003cp\u003eRequests to this method have a quota cost of 1 unit and require authorization with the scope \u003ccode\u003ehttps://www.googleapis.com/auth/youtube.channel-memberships.creator\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe request requires the \u003ccode\u003epart\u003c/code\u003e parameter with a string value that can contain either \u003ccode\u003eid\u003c/code\u003e, \u003ccode\u003esnippet\u003c/code\u003e, or both, as comma separated values.\u003c/p\u003e\n"]]],["This API endpoint allows individual creators to retrieve channel membership levels for their YouTube channel. A `GET` request requires authorization with the `youtube.channel-memberships.creator` scope and the `part` parameter to specify the properties. The response, in JSON format, lists membership levels or an empty list if levels are undefined. If channel memberships aren't enabled, the API returns a `channelMembershipsNotEnabled` error. This method has a quota cost of 1 unit per call.\n"],null,["# MembershipsLevels: list\n\nNote: This endpoint can only be used by individual creators to make requests for their own, channel-memberships-enabled YouTube channel. Reach out to your Google or YouTube representative to request access.\n\nLists membership levels for the channel that authorized the request. Levels are returned in\nimplicit display order. API requests to this method yield one of the following responses:\n\n- If the creator has enabled channel memberships and has pricing levels, then the API response contains the list of levels.\n- If the creator has enabled channel memberships but has not defined pricing levels, then the API response contains an empty list.\n- If the creator has not enabled channel memberships, the API returns a [channelMembershipsNotEnabled](#errors) error.\n\n**Quota impact:** A call to this method has a\n[quota cost](/youtube/v3/getting-started#quota) of 1 unit.\n\nRequest\n-------\n\n### HTTP request\n\n```\nGET https://www.googleapis.com/youtube/v3/membershipsLevels\n```\nThis request requires authorization with the following scope:\n\n| Scope |\n|-----------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/youtube.channel-memberships.creator` |\n\n### Parameters\n\nThe following table lists the parameters that this query supports. All of the parameters listed are query parameters.\n\n| Parameters ||\n|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| **Required parameters** |||\n| `part` | `string` The **part** parameter specifies the `membershipsLevel` resource properties that the API response will include. The parameter value is a comma-separated list of resource parts. The following list shows the parts that can be retrieved: - `id` - `snippet` |\n\n### Request body\n\nDo not provide a request body when calling this method.\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure: \n\n```objective-c\n{\n \"kind\": \"youtube#membershipsLevelListResponse\",\n \"etag\": etag,\n \"items\": [\n membershipsLevel Resource\n ]\n}\n```\n\n### Properties\n\nThe following table defines the properties that appear in this resource:\n\n| Properties ||\n|-----------|--------------------------------------------------------------------------------------------------------|\n| `kind` | `string` Identifies the API resource's type. The value will be `youtube#membershipsLevelListResponse`. |\n| `etag` | `etag` The Etag of this resource. |\n| `items[]` | `list` A list of `membershipsLevel` resources owned by the channel that authorized the API request. |\n\nErrors\n------\n\nThe following table identifies error messages that the API could return in response to a call to this method. Please see the [error message](/youtube/v3/docs/errors) documentation for more detail.\n\n| Error type | Error detail | Description |\n|--------------------|--------------------------------|----------------------------------------------------------------------------------------|\n| `badRequest (400)` | `channelMembershipsNotEnabled` | The creator channel authorizing the request does not have channel memberships enabled. |"]]