The `googleapis` package is Google's officially supported Node.js client library for interacting with a wide range of Google APIs. It provides a unified interface for over 200 Google services, including non-GCP APIs like YouTube, Gmail, and Google Drive, as well as some Google Cloud Platform (GCP) services. The library currently stands at version 171.4.0 and sees frequent updates, typically driven by automated API definition generators for individual service modules, leading to regular minor and patch releases. Major version bumps often aggregate breaking changes across various underlying API modules. A key differentiator is its comprehensive coverage of all Google APIs, contrasting with the `@google-cloud/*` libraries which are purpose-built and idiomatic Node.js clients specifically for Google Cloud Platform services. While `googleapis` provides authentication support for OAuth 2.0, API Keys, and JWT tokens, it is explicitly in maintenance mode, meaning new features will not be added, and development prioritizes critical bug fixes and security issues. For new projects utilizing GCP services, Google strongly recommends using the actively developed `@google-cloud/*` client libraries, which often offer gRPC support for improved performance.
npm install googleapisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Google APIs client library, instantiate the Blogger API client for version v3, and authenticate with an API key to retrieve blog details using `async/await`.
When interacting with GCP services, consider installing and using the corresponding `@google-cloud/*` package (e.g., `npm install @google-cloud/storage`) instead of `googleapis`.
Upgrade your Node.js environment to version 18 or a later actively supported LTS release. Use `nvm install 18` and `nvm use 18` or update your system's Node.js installation.
Implement Application Default Credentials for local development and Google Cloud deployments, or utilize OAuth 2.0 flows for user-centric applications, and Service Accounts for server-to-server interactions. Avoid embedding API keys directly in source code; use environment variables or secret management services.
Instead of `npm install googleapis`, consider `npm install @googleapis/<api-name>` for the specific Google API clients your application needs, replacing `<api-name>` with the desired API name (e.g., `docs`, `drive`, `youtube`).
Pin your `googleapis` dependency to a specific major version in `package.json` to control when updates are applied (e.g., `"googleapis": "^171.0.0"`). Thoroughly test your application against new major versions before deploying to production.
Verify the API name and version against the Google APIs Explorer. Ensure the API is enabled in your Google Cloud Project's API Library. Check for any required scopes or specific access permissions.
For OAuth2, ensure your refresh token is valid or re-authorize the user. For service accounts, verify the JSON key file is correct, not expired, and the service account has the necessary IAM roles. For Application Default Credentials (ADC), ensure `gcloud auth application-default login` has been run or `GOOGLE_APPLICATION_CREDENTIALS` is correctly set and points to a valid service account key.
Check the exact API name and required version on the Google APIs Explorer. Ensure your `googleapis` package is up-to-date, or install the specific `@googleapis/<api-name>` submodule if using granular installations. If TypeScript, ensure your import statements and type definitions are correct.
Update your code to use `import` statements: `import { google } from 'googleapis';`. Ensure your `package.json` has `"type": "module"` if you intend to write ESM, or configure a transpiler like Babel or TypeScript to output CommonJS if you must use `require()` with an ESM-only dependency.No dependency data recorded yet.