用于获取邮件的Gmail API限制 [英] Gmail API limitations for getting mails
问题描述
numberOfMails / 10
秒更好? 我正在从客户端JavaScript应用程序访问API我正在考虑通过一些机器/应用程序为同一用户分发API调用,但是仍然不清楚其限制是否适用于Gmail用户或注册的应用程序。
无论如何,希望得到一些想法如何处理,目前的配额完全不可用。
可以使用批处理请求一起发送多个请求。我本周花了整整一个礼拜了。 java代码如下所示:
BatchRequest b = service.batch();
//回调函数。 (也可以根据需要为每个请求定义不同的回调)
JsonBatchCallback< Thread> bc = new JsonBatchCallback< Thread>(){
@Override
public void onSuccess(Thread t,HttpHeaders responseHeaders)
throws IOException {
System.out.println (t.getMessages()得到(0).getPayload()getBody()的getData()。);
}
@Override
public void onFailure(GoogleJsonError e,HttpHeaders responseHeaders)
throws IOException {
}
} ;
//批处理请求的排队请求
(线程线程:线程){
service.users()。threads()。get(me,threads。 getId())。queue(b,bc);
}
b.execute();
由问题作者添加:对于那些也有这个问题的人:一个href =https://developers.google.com/gmail/api/guides/batch =nofollow> https://developers.google.com/gmail/api/guides/batch 和 https://developers.google.com/api-client-library/javascript /特征/ rpcbatch 。虽然RpcBatch已被弃用,但它现在正在工作,并且限制每批次1000个请求。
As I understand currently google's API provides 10 requests per second to its API (from their docs), and it looks to be far from enough for comfortable work with mail. I need to get all emails' headers (or at least senders and recipients). Is there anything better than waiting numberOfMails / 10
seconds?
I'm currently accessing API from client side JavaScript application, I'm thinking of distributing API calls for the same user over a number of machines/applications, but's still unclear if their limits apply to gmail user or registered application.
Anyway, hope to get some ideas what to do with it, with current quota it's completely not usable.
You can use batch requests to send multiple requests together. I spent a whole day this week figuring this out. The java code goes like this:
BatchRequest b = service.batch();
//callback function. (Can also define different callbacks for each request, as required)
JsonBatchCallback<Thread> bc = new JsonBatchCallback<Thread>() {
@Override
public void onSuccess(Thread t, HttpHeaders responseHeaders)
throws IOException {
System.out.println(t.getMessages().get(0).getPayload().getBody().getData());
}
@Override
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders)
throws IOException {
}
};
// queuing requests on the batch request
for (Thread thread : threads) {
service.users().threads().get("me", threads.getId()).queue(b, bc);
}
b.execute();
Added by question's author: for those who also have this problem: https://developers.google.com/gmail/api/guides/batch and https://developers.google.com/api-client-library/javascript/features/rpcbatch. Although RpcBatch is deprecated it's working now and with limitation of 1000 request per batch.
这篇关于用于获取邮件的Gmail API限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!