我们正在更新 Data API,以便与 YouTube 统计 Shorts 短视频观看次数的方式保持一致。
了解详情
Comments: list
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回与 API 请求参数匹配的注释列表。
对配额的影响:调用此方法的配额费用为 1 个单位。
常见使用场景
请求
HTTP 请求
GET https://www.googleapis.com/youtube/v3/comments
参数
下表列出了此查询支持的参数。列出的所有参数都是查询参数。
参数 |
必需参数 |
part |
string
part 参数指定一个逗号分隔列表,其中包含 API 响应将包含的一个或多个 comment 资源属性。
以下列表包含您可以包含在参数值中的 part 名称:
|
过滤条件(请仅指定以下参数之一) |
id |
string
id 参数指定要检索的资源的评论 ID 列表(以英文逗号分隔)。在 comment 资源中,id 属性用于指定评论的 ID。 |
parentId |
string
parentId 参数指定应检索其回复的评论的 ID。
注意:YouTube 目前仅支持回复顶级评论。不过,我们以后可能会支持回复回复功能。 |
可选参数 |
maxResults |
unsigned integer
maxResults 参数指定结果集中应返回的最大项数。
注意:此参数不能与 id 参数结合使用。可接受的值包括1 到100 (含 0 和 10000)。默认值为 20 。 |
pageToken |
string
pageToken 参数用于标识结果集中应返回的特定网页。在 API 响应中,nextPageToken 属性用于标识可检索到的结果的下一页。
注意:不支持将此参数与 id 参数结合使用。 |
textFormat |
string
此参数指示 API 应返回 HTML 格式的注释还是纯文本格式的注释。默认值为 html 。
可接受的值包括:
html - 以 HTML 格式返回注释。这是默认值。
plainText - 以纯文本格式返回注释。
|
响应
如果成功,此方法将返回采用以下结构的响应正文:
{
"kind": "youtube#commentListResponse",
"etag": etag,
"nextPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
comment Resource
]
}
属性
下表定义了此资源中显示的属性:
属性 |
kind |
string 标识 API 资源的类型。其值为 youtube#commentListResponse 。 |
etag |
etag
此资源的 Etag。 |
nextPageToken |
string
可用作 pageToken 参数值的令牌,用于检索结果集中的下一页。 |
pageInfo |
object
pageInfo 对象可封装结果集的分页信息。 |
pageInfo.totalResults |
integer
结果集中的结果总数。 |
pageInfo.resultsPerPage |
integer
API 响应中包含的结果数量。 |
items[] |
list
符合请求条件的评论列表。 |
错误
下表列出了 API 在响应对此方法的调用时可能会返回的错误消息。如需了解详情,请参阅错误消息文档。
试试看!
使用 APIs Explorer 调用此 API 并查看 API 请求和响应。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-04-26。
[null,null,["最后更新时间 (UTC):2024-04-26。"],[],[],null,["# Comments: list\n\nReturns a list of comments that match the API request parameters.\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of 1 unit.\n\nCommon use cases\n----------------\n\nThe list below shows common use cases for this method. Hover over a use case to see its description, or click on a use case to load sample parameter values in the APIs Explorer. You can open the [fullscreen APIs Explorer](#) to see code samples that dynamically update to reflect the parameter values entered in the Explorer.\n\nThe table below shows common use cases for this method. You can click on a use case name to load sample parameter values in the APIs Explorer. Or you can see code samples for a use case in the fullscreen APIs Explorer by clicking on the code icon below a use case name. In the fullscreen UI, you can update parameter and property values and the code samples will dynamically update to reflect the values you enter. \nThis method has one common use case, which is described below. The buttons below the description populate the APIs Explorer with sample values or open the fullscreen APIs Explorer to show code samples that use those values. The code samples also dynamically update if you change the values.\n\n\u003cbr /\u003e\n\nRequest\n-------\n\n### HTTP request\n\n```\nGET https://www.googleapis.com/youtube/v3/comments\n```\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 a comma-separated list of one or more `comment` resource properties that the API response will include. The following list contains the `part` names that you can include in the parameter value: - `id` - `snippet` |\n| **Filters (specify exactly one of the following parameters)** |||\n| `id` | `string` The **id** parameter specifies a comma-separated list of comment IDs for the resources that are being retrieved. In a `comment` resource, the `id` property specifies the comment's ID. |\n| `parentId` | `string` The **parentId** parameter specifies the ID of the comment for which replies should be retrieved. **Note:** YouTube currently supports replies only for top-level comments. However, replies to replies may be supported in the future. |\n| **Optional parameters** |||\n| `maxResults` | `unsigned integer` The **maxResults** parameter specifies the maximum number of items that should be returned in the result set. **Note:** This parameter is not supported for use in conjunction with the [id](#id) parameter. Acceptable values are `1` to `100`, inclusive. The default value is `20`. |\n| `pageToken` | `string` The **pageToken** parameter identifies a specific page in the result set that should be returned. In an API response, the `nextPageToken` property identifies the next page of the result that can be retrieved. **Note:** This parameter is not supported for use in conjunction with the [id](#id) parameter. |\n| `textFormat` | `string` This parameter indicates whether the API should return comments formatted as HTML or as plain text. The default value is `html`. Acceptable values are: - **html** -- Returns the comments in HTML format. This is the default value. - **plainText** -- Returns the comments in plain text format. |\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#commentListResponse\",\n \"etag\": etag,\n \"nextPageToken\": string,\n \"pageInfo\": {\n \"totalResults\": integer,\n \"resultsPerPage\": integer\n },\n \"items\": [\n comment 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#commentListResponse`. |\n| `etag` | `etag` The Etag of this resource. |\n| `nextPageToken` | `string` The token that can be used as the value of the `pageToken` parameter to retrieve the next page in the result set. |\n| `pageInfo` | `object` The `pageInfo` object encapsulates paging information for the result set. |\n| pageInfo.`totalResults` | `integer` The total number of results in the result set. |\n| pageInfo.`resultsPerPage` | `integer` The number of results included in the API response. |\n| `items[]` | `list` A list of comments that match the request criteria. |\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)` | `operationNotSupported` | The id filter is only compatible with comments based on Google+. |\n| `forbidden (403)` | `forbidden` | One or more of the requested comments cannot be retrieved due to insufficient permissions. The request might not be properly authorized. |\n| `notFound (404)` | `commentNotFound` | One or more of the specified comments cannot be found. Check the values of the request's [id](/youtube/v3/docs/comments/list#id) and [parentId](/youtube/v3/docs/comments/list#parentId) parameters to ensure that they are correct. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]