The `google-translate-api` package provides a free and unlimited programmatic interface to Google Translate services. Unlike Google's official Cloud Translation APIs, this library functions as a wrapper around the public Google Translate website's frontend. It offers features such as automatic language detection, spelling correction, and language correction. The current stable version is 2.3.0, with recent updates focused on bug fixes, like handling `null` responses, and adding support for new languages. The package generally follows a patch and minor release cadence for ongoing maintenance. Its key differentiator is providing translation functionality without requiring API keys or incurring costs associated with Google Cloud Translate, making it suitable for hobby projects or those with budget constraints. However, developers should be aware that its reliance on reverse-engineering the Google Translate website means it can be susceptible to unannounced breaking changes if Google alters its front-end structure.
npm install google-translate-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic text translation with automatic language detection, handling of spelling corrections, and retrieving the raw API response for debugging or advanced parsing.
Be prepared for potential breakage and consider actively monitoring the library's GitHub repository for updates or issues. For production-critical applications, consider using the official Google Cloud Translation API.
Implement robust error handling for `translate` calls and use the `google-translate-api/languages` module (if available) or refer to the `languages.js` file to validate language codes before making a translation request.
Upgrade to `google-translate-api@^2.3.0` or newer to resolve issues with `null` values in Google's responses.
For CommonJS, use `const translate = require('google-translate-api');`. For ESM, use `import translate from 'google-translate-api';`.Update the package to `google-translate-api@^2.3.0` or newer to get the fix for handling `null` responses gracefully.
Ensure that the language codes passed to `from` and `to` options are valid. You can use the `google-translate-api/languages` module to check for supported languages programmatically.
No dependency data recorded yet.