Registry / http-networking / google-translate-api-x

google-translate-api-x

JSON →
library10.7.2jsnpmunverified

A free and unlimited API for Google Translate (v10.7.2) that uses the same servers as translate.google.com. Cross-platform (Node.js, browsers) via Fetch API, ships TypeScript types. Supports automatic language detection, spelling/language correction, batch translation (arrays/objects), and text-to-speech. Differentiators: supports both single and batch translate endpoints for reliability, provides a Translator class for option persistence, and includes over 100 languages. Actively maintained with weekly releases.

npm install google-translate-api-x
INSTALL
IMPORT
SIG · GOOGLE-TRANSLATE-A
G
google-translate-api-x
http-networkingjavascriptv10.7.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

translate
import translate from 'google-translate-api-x'
const translate = require('google-translate-api-x')
Default export; ESM and CJS both supported. Use named imports for other symbols.
Translator
import { Translator } from 'google-translate-api-x'
const { Translator } = require('google-translate-api-x')
Named export for class-based translation with persistent options.
speak
import { speak } from 'google-translate-api-x'
import speak from 'google-translate-api-x'
Named export for text-to-speech; returns base64 MP3 string.
languages
import { languages } from 'google-translate-api-x'
const languages = require('google-translate-api-x/languages')
Named export providing supported language codes and names.

Demonstrates default and named imports, single and batch translation, text-to-speech, Translator class, and language utilities.

import translate, { Translator, speak, languages, isSupported } from 'google-translate-api-x'; const single = await translate('Ik spreek Engels', { to: 'en' }); console.log(single.text); // 'I speak English' const batch = await translate(['Hello', 'World'], { to: 'es' }); console.log(batch.map(r => r.text)); // ['Hola', 'Mundo'] const tts = await speak('Hello', { to: 'es' }); // tts is base64 MP3 string const translator = new Translator({ to: 'fr', client: 'gtx' }); const res2 = await translator.translate('How are you?'); console.log(res2.text); // 'Comment allez-vous?' console.log(isSupported('en')); // true console.log(Object.keys(languages).length); // > 100
Debug
Known issues
gotchaMaximum text length for single translation is 5000 characters; longer text must be split into chunks.
fix
Split text into chunks of 5000 chars or less before translating.
affects: >=1.0.0
gotchaResponse code 403 (Forbidden) can occur; use client=gtx option to mitigate.
fix
Set { client: 'gtx' } in options when calling translate() or use Translator with client option.
affects: >=1.0.0
deprecatedThe autoCorrect option may be deprecated or unreliable; reported values often inaccurate.
fix
Avoid relying on autoCorrect results; use with caution.
affects: >=10.0.0
gotchaBatch endpoint may be less accurate than single endpoint; choose based on needs.
fix
Use singleTranslate for accuracy, batchTranslate for performance when accuracy is less critical.
affects: >=10.0.0
Errors
Common errors & fixes
Response code 403 (Forbidden)
Google Translate API blocking requests due to rate limiting or missing client parameter.
fix
Set { client: 'gtx' } in options: await translate('text', { to: 'en', client: 'gtx' })
Cannot find module 'google-translate-api-x'
Package not installed or incorrect import path.
fix
Run: npm install google-translate-api-x
TypeError: translate is not a function
Using default import as function with wrong syntax (e.g., require() style with default export).
fix
Use: import translate from 'google-translate-api-x' or const translate = require('google-translate-api-x').default
Maximum call stack size exceeded
Recursive or circular translations without base case.
fix
Avoid translating results of translate() repeatedly; ensure termination condition.
Upgrade
Version history
10.7.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
google-translate-api-x — npm install google-translate-api-x · libregistry