{"id":18396,"library":"google-translate-api-x","title":"Google Translate API X","description":"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.","status":"active","version":"10.7.2","language":"javascript","source_language":"en","source_url":"https://github.com/AidanWelch/google-translate-api","tags":["javascript","translate","translator","google","api","free","language","crossplatform","fetch","typescript"],"install":[{"cmd":"npm install google-translate-api-x","lang":"bash","label":"npm"},{"cmd":"yarn add google-translate-api-x","lang":"bash","label":"yarn"},{"cmd":"pnpm add google-translate-api-x","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; ESM and CJS both supported. Use named imports for other symbols.","wrong":"const translate = require('google-translate-api-x')","symbol":"translate","correct":"import translate from 'google-translate-api-x'"},{"note":"Named export for class-based translation with persistent options.","wrong":"const { Translator } = require('google-translate-api-x')","symbol":"Translator","correct":"import { Translator } from 'google-translate-api-x'"},{"note":"Named export for text-to-speech; returns base64 MP3 string.","wrong":"import speak from 'google-translate-api-x'","symbol":"speak","correct":"import { speak } from 'google-translate-api-x'"},{"note":"Named export providing supported language codes and names.","wrong":"const languages = require('google-translate-api-x/languages')","symbol":"languages","correct":"import { languages } from 'google-translate-api-x'"}],"quickstart":{"code":"import translate, { Translator, speak, languages, isSupported } from 'google-translate-api-x';\n\nconst single = await translate('Ik spreek Engels', { to: 'en' });\nconsole.log(single.text); // 'I speak English'\n\nconst batch = await translate(['Hello', 'World'], { to: 'es' });\nconsole.log(batch.map(r => r.text)); // ['Hola', 'Mundo']\n\nconst tts = await speak('Hello', { to: 'es' });\n// tts is base64 MP3 string\n\nconst translator = new Translator({ to: 'fr', client: 'gtx' });\nconst res2 = await translator.translate('How are you?');\nconsole.log(res2.text); // 'Comment allez-vous?'\n\nconsole.log(isSupported('en')); // true\nconsole.log(Object.keys(languages).length); // > 100","lang":"typescript","description":"Demonstrates default and named imports, single and batch translation, text-to-speech, Translator class, and language utilities."},"warnings":[{"fix":"Split text into chunks of 5000 chars or less before translating.","message":"Maximum text length for single translation is 5000 characters; longer text must be split into chunks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set { client: 'gtx' } in options when calling translate() or use Translator with client option.","message":"Response code 403 (Forbidden) can occur; use client=gtx option to mitigate.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid relying on autoCorrect results; use with caution.","message":"The autoCorrect option may be deprecated or unreliable; reported values often inaccurate.","severity":"deprecated","affected_versions":">=10.0.0"},{"fix":"Use singleTranslate for accuracy, batchTranslate for performance when accuracy is less critical.","message":"Batch endpoint may be less accurate than single endpoint; choose based on needs.","severity":"gotcha","affected_versions":">=10.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Set { client: 'gtx' } in options: await translate('text', { to: 'en', client: 'gtx' })","cause":"Google Translate API blocking requests due to rate limiting or missing client parameter.","error":"Response code 403 (Forbidden)"},{"fix":"Run: npm install google-translate-api-x","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'google-translate-api-x'"},{"fix":"Use: import translate from 'google-translate-api-x' or const translate = require('google-translate-api-x').default","cause":"Using default import as function with wrong syntax (e.g., require() style with default export).","error":"TypeError: translate is not a function"},{"fix":"Avoid translating results of translate() repeatedly; ensure termination condition.","cause":"Recursive or circular translations without base case.","error":"Maximum call stack size exceeded"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}