Method: users.threads.list
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
HTTP 请求
GET https://gmail.googleapis.com/gmail/v1/users/{userId}/threads
网址采用 gRPC 转码语法。
路径参数
参数 |
userId |
string
用户的电子邮件地址。特殊值 me 可用于指示经过身份验证的用户。
|
查询参数
参数 |
maxResults |
integer (uint32 format)
要返回的最大线程数。此字段的默认值为 100。此字段的允许最大值为 500。
|
pageToken |
string
用于检索列表中特定页面结果的页面令牌。
|
q |
string
仅返回与指定查询匹配的会话。支持与 Gmail 搜索框相同的查询格式。例如,"from:someuser@example.com rfc822msgid:<somemsgid@example.com>
is:unread" 。使用 gmail.metadata 范围访问 API 时,无法使用此参数。
|
labelIds[] |
string
仅返回标签与所有指定标签 ID 匹配的会话。
|
includeSpamTrash |
boolean
在结果中包含 SPAM 和 TRASH 中的线程。
|
响应正文
JSON 表示法 |
{
"threads": [
{
object (Thread )
}
],
"nextPageToken": string,
"resultSizeEstimate": integer
} |
字段 |
threads[] |
object (Thread )
线程列表。请注意,每个线程资源都不包含 messages 列表。您可以使用 threads.get 方法提取给定线程的 messages 列表。
|
nextPageToken |
string
获取列表中下一页结果的网页令牌。
|
resultSizeEstimate |
integer (uint32 format)
估算的结果总数。
|
授权范围
需要以下 OAuth 范围之一:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.metadata
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: users.threads.list\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ListThreadsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nLists the threads in the user's mailbox.\n\n### HTTP request\n\n`GET https://gmail.googleapis.com/gmail/v1/users/{userId}/threads`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------|\n| `userId` | `string` The user's email address. The special value `me` can be used to indicate the authenticated user. |\n\n### Query parameters\n\n| Parameters ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `maxResults` | `integer (`[uint32](https://developers.google.com/discovery/v1/type-format)` format)` Maximum number of threads to return. This field defaults to 100. The maximum allowed value for this field is 500. |\n| `pageToken` | `string` Page token to retrieve a specific page of results in the list. |\n| `q` | `string` Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, `\"from:someuser@example.com rfc822msgid:\u003csomemsgid@example.com\u003e is:unread\"`. Parameter cannot be used when accessing the api using the gmail.metadata scope. |\n| `labelIds[]` | `string` Only return threads with labels that match all of the specified label IDs. |\n| `includeSpamTrash` | `boolean` Include threads from `SPAM` and `TRASH` in the results. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"threads\": [ { object (/workspace/gmail/api/reference/rest/v1/users.threads#Thread) } ], \"nextPageToken\": string, \"resultSizeEstimate\": integer } ``` |\n\n| Fields ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `threads[]` | `object (`[Thread](/workspace/gmail/api/reference/rest/v1/users.threads#Thread)`)` List of threads. Note that each thread resource does not contain a list of `messages`. The list of `messages` for a given thread can be fetched using the [`threads.get`](https://developers.google.com/workspace/gmail/api/v1/reference/users/threads/get) method. |\n| `nextPageToken` | `string` Page token to retrieve the next page of results in the list. |\n| `resultSizeEstimate` | `integer (`[uint32](https://developers.google.com/discovery/v1/type-format)` format)` Estimated total number of results. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://mail.google.com/`\n- `\n https://www.googleapis.com/auth/gmail.modify`\n- `\n https://www.googleapis.com/auth/gmail.readonly`\n- `\n https://www.googleapis.com/auth/gmail.metadata`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]