Registry / storage / google-batch

google-batch

JSON →
library0.0.8jsnpmunverified

Sends batch requests to Google REST API by seamlessly integrating with the official googleapis Node.js SDK. Version 0.0.8 is in early development (POC only), with incomplete API support and only JSON request/response types. Not recommended for production. Release cadence is infrequent; last release July 2018. Differentiates by allowing direct use of googleapis methods with batch support, unlike manual batching or alternative libraries like batch-google.

npm install google-batch
INSTALL
IMPORT
SIG · GOOGLE-BATCH
G
google-batch
storagejavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

googleBatch
const googleBatch = require('google-batch')
import googleBatch from 'google-batch'
CommonJS only; no ESM support. Must use require().
google
const google = googleBatch.require('googleapis')
const google = require('googleapis')
Must use googleBatch.require() instead of direct require('googleapis') to enable batch interception.
decodeRawData
googleBatch.decodeRawData(rawBody)
decodeRawData(rawBody)
Static method on the imported googleBatch object, not standalone.

Creates a batch of two Gmail list calls and executes them together.

const googleBatch = require('google-batch'); const batch = new googleBatch(); const google = googleBatch.require('googleapis'); batch.setAuth('YOUR_ACCESS_TOKEN'); const gmail = google.gmail({ version: 'v1' }); batch.add(gmail.users.messages.list({ googleBatch: true, userId: 'me', maxResults: 5 })); batch.add(gmail.users.messages.list({ googleBatch: true, userId: 'me', maxResults: 10 })); batch.exec((error, responses, errorDetails) => { console.log(responses); batch.clear(); });
Debug
Known issues
gotchaMust use googleBatch.require('googleapis') instead of direct require('googleapis')
fix
Always load googleapis via googleBatch.require() to ensure batch interception works.
affects: >=0.0.0
gotchaEach API call object must include googleBatch: true in its parameters to be recognized as a batch call
fix
Add googleBatch: true to the parameters of every function call added to the batch.
affects: >=0.0.0
gotchaDo not pass OAuth2 client in google service constructor; it bypasses batch interception
fix
Use batch.setAuth() for auth instead of passing to constructor.
affects: >=0.0.0
gotchaOnly application/json request/response types supported. Upload/download not supported.
fix
Avoid APIs that require non-JSON payloads (e.g., media uploads).
affects: >=0.0.0
deprecatedPackage is in early development (POC) and may not work for many APIs
fix
For production, use official googleapis batch support or alternative libraries.
affects: 0.0.x
Errors
Common errors & fixes
TypeError: google is not a function
Directly required googleapis instead of using googleBatch.require()
fix
const google = googleBatch.require('googleapis');
Error: No auth provided
Missing batch.setAuth() call
fix
batch.setAuth('YOUR_ACCESS_TOKEN');
Error: Bad Request
Batch parameters missing googleBatch: true
fix
Add googleBatch: true to each API call's parameters object.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies
googleapisrequiredRequired for batch requests; google-batch depends on googleapis' auth and API methods.
Agent activity
25 hits · last 30 days
node
24
Resources
google-batch — npm install google-batch · libregistry