title: Node.js client library batch requests to Gmail API
body: <p>I have an Node.js app which retrieves e-mail threads for a large number of users (200.000+). I am using the <code>Node.js client library</code>.</p>
  
  <p>I authenticate each user separately using JWT and a Service account with domain wide delegation on the users' side, then call the <code>threads.list</code> endpoint as follows:</p>
  
  <pre><code>const { google } = require('googleapis');
  
  const jwt = new google.auth.JWT(
    SERVICE_ACCOUNT.client_email,
    null,
    SERVICE_ACCOUNT.private_key,
    ['https://www.googleapis.com/auth/gmail.readonly'],
    user,
  );
  
  const auth = await authorize(jwt);
  const gmail = google.gmail({ version: 'v1', auth });
  const response = await gmail.users.threads.list({ userId: user, maxResults: 50 })
  </code></pre>
  
  <p>Considering the large number of users, I've been thinking about implementing batch requests to group more users per request instead of going one by one, but I'm unable to find information on how to do that using the <code>Node.js client library</code>. Also, considering that each user has to be authorized for me to be able to retrieve their data, how would I handle that in a batch request ?</p>
  
  <p>Thanks for any suggestions</p>