如何使用Gmail API获取INBOX中未读线程的数量?

yuk*_*lai 3 gmail-api

我试着使用list thread方法:

GET https://www.googleapis.com/gmail/v1/users/{MyEmailAddress}/threads?labelIds=INBOX&labelIds=UNREAD&key={YOUR_API_KEY}
Run Code Online (Sandbox Code Playgroud)

resultSizeEstimate与Gmail网络应用中我的收件箱旁边的数字不匹配.

还有另外一种方法吗?

Eri*_*c D 7

Gmail API现在使用Labels.Get()方法为每个Label上的消息和线程提供总计和未读计数.请参阅:https: //developers.google.com/gmail/api/release-noteshttps://developers.google.com/gmail/api/v1/reference/users/labels


Jay*_*Lee 5

在 Gmail 用户界面中关闭对话视图,以便获得收件箱中邮件(而非线程)的准确计数。

您还可以使用:

在:收件箱是:未读

作为 UI 和 API 中的查询。删除 labelId 参数。