ssut/py-googletrans
Developer ToolsA Python library that wraps Google Translate's web API for free translation, language detection and batch translation.
What it does
Googletrans is an unofficial Python library that calls the web API behind translate.google.com. It provides async translation, automatic source-language detection, batch translation of string lists, configurable service URLs, proxy support, and HTTP/2 through httpx. It targets Python 3.8+ and is aimed at developers who want quick translation in scripts without a paid API key.
How it works
Google's web translation endpoint uses a ticket token generated by obfuscated JavaScript. The project reverse-engineered that token generation and reimplemented it in Python; the README notes this could stop working if Google changes its side README lines 31–44.
Quick start
Install the package from PyPI:
pip install googletrans
Translate text with the async API; if src is omitted, the source language is detected automatically:
import asyncio
from googletrans import Translator
async def main():
async with Translator() as translator:
result = await translator.translate('안녕하세요.', dest='ja')
print(result)
asyncio.run(main())
The result object exposes the source language, destination language, translated text and pronunciation. Batch translation accepts a list of strings, and detect() returns the detected language with a confidence value. The package also installs a translate command-line tool:
translate "veritas lux mea" -s la -d en
The full API reference is on the documentation site.
Usage constraints
This wraps an unofficial web endpoint, not a supported product, and is not associated with Google. Translation is capped at 15,000 characters per request, and the README explicitly does not guarantee stable operation. HTTP 5xx errors or certain error codes usually mean Google has blocked the client IP. For production workloads the author recommends Google Cloud Translation. The project is MIT-licensed. Versioning follows Semantic Versioning from v2.0.0, while 0.x.y releases may break compatibility.
HotRepo's take
There is no HotRepo ranking or star-history record for this repository, so no trending claim can be made from site data. The useful facts here are the age (created 2015), the 4,292 stars and 740 forks, and the maintenance risk the README itself states: a reverse-engineered token keeps the library working only until Google changes the web client. Treat it as a convenient tool for scripts and prototypes, and budget for switching to an official API if the token workaround breaks.
Written by AI from the project's README, updated . The project's own docs are the source of truth.