googletrans-curl
googletrans-curl is a fast, drop-in replacement fork of googletrans that integrates curl-cffi to eliminate Google Translate HTTP 429 Too Many Requests and rate-limiting blocks via browser TLS fingerprint impersonation.
Drop-in Replacement for googletrans
The PyPI distribution package is named googletrans-curl, but the Python import namespace remains googletrans:
# Uninstall old package if present
pip uninstall googletrans
# Install drop-in replacement
pip install googletrans-curl
1. For Async Codebases (googletrans v4.x)
Existing async applications continue importing googletrans with zero code modifications:
from googletrans import Translator
# Async/await functions exactly as before, with curl-cffi anti-429 protection
async with Translator() as translator:
result = await translator.translate("Hello world", dest="ko")
2. For Synchronous Codebases (googletrans v3.x legacy)
Upstream googletrans v4 broke backwards compatibility by turning Translator.translate() into an async coroutine, which broke thousands of synchronous scripts and legacy applications.
googletrans-curl provides a full synchronous drop-in implementation (SyncTranslator). Legacy v3.x synchronous code requires only a single line change in the import:
# Change this import:
# from googletrans import Translator
# To this:
from googletrans import SyncTranslator as Translator
# Your existing synchronous code continues to function with zero modifications:
translator = Translator()
result = translator.translate("Hello world", dest="ko")
print(result.text) # "안녕하세요."
No async/await refactoring, no event loop management, and no boilerplate required!
Why googletrans-curl?
The upstream googletrans uses httpx for HTTP requests. Google Translate's web endpoints actively monitor client TLS handshakes and HTTP/2 settings, frequently rejecting automated Python HTTP clients with HTTP 429 Too Many Requests or HTTP 403 Forbidden.
googletrans-curl solves this by introducing a flexible HTTP layer backed by curl-cffi. By impersonating real browser fingerprints (default: Chrome), requests match legitimate browser traffic and bypass fingerprint-based rate limiting.
Architecture
Existing Application
│
│ from googletrans import Translator
▼
┌───────────────┐
│ Translator │
│ Python API │
└───────┬───────┘
│
┌───────▼───────┐
│ HTTP Session │
│ Abstraction │
└───┬───────┬───┘
│ │
transport="curl"│ │ transport="httpx"
│ │
▼ ▼
curl-cffi httpx
│
(Chrome impersonation)
│
▼
Google Translate Service
Features
- Drop-in Compatible: 100% compatible with existing
googletranscode. - Anti-429 Protection: Uses
curl-cffiwith Chrome TLS/HTTP2 impersonation. - Pluggable Transports: Switch between
curl(anti-blocking) and standardhttpx. - Async First: Native
async/awaitsupport with async context manager. - Bulk Translation: Efficiently translate batches of text in a single request.
- Auto Language Detection: Automatically detect language and confidence scores.
- CLI Tool Included: Includes the command-line utility
translate. - Complete Type Annotations: Fully typed for modern Python environments.
Installation
pip install googletrans-curl
Requirements: Python 3.8 or newer.
Quickstart
Basic Usage (Async)
import asyncio
from googletrans import Translator
async def main():
async with Translator() as translator:
# Detect and translate to English (default)
result = await translator.translate("안녕하세요.")
print(result.text) # "Hello."
print(result.src) # "ko"
# Translate to Japanese
result = await translator.translate("안녕하세요.", dest="ja")
print(result.text) # "こんにちは。"
# Specify source language
result = await translator.translate("veritas lux mea", src="la", dest="en")
print(result.text) # "truth is my light"
asyncio.run(main())
Synchronous Usage (SyncTranslator)
For synchronous scripts, command-line utilities, or legacy codebases that do not use async/await:
Option A: 1-Line Drop-in for Legacy v3.x Codebases
If migrating an existing script or codebase written for googletrans 3.x, simply alias the import:
from googletrans import SyncTranslator as Translator
# Direct instantiation without context manager or async loop:
translator = Translator()
result = translator.translate("안녕하세요.", dest="en")
print(result.text) # "Hello."
detected = translator.detect("Bonjour tout le monde")
print(detected.lang) # "fr"
Option B: Context Manager (Recommended for Synchronous Workflows)
Using with SyncTranslator() ensures immediate deterministic cleanup of network sessions:
from googletrans import SyncTranslator
with SyncTranslator() as translator:
result = translator.translate("안녕하세요.", dest="en")
print(result.text) # "Hello."
detected = translator.detect("Bonjour tout le monde")
print(detected.lang) # "fr"
Option C: Convenience Synchronous Methods on Translator
If you already have a Translator instance or are calling synchronous logic from within an async codebase:
from googletrans import Translator
translator = Translator()
result = translator.translate_sync("Hello world", dest="es")
print(result.text) # "Hola mundo"
Transport Configuration
By default, Translator() automatically uses curl-cffi with Chrome impersonation. You can customize the transport and browser fingerprint as needed:
from googletrans import Translator
# Default: automatic browser impersonation via curl-cffi
translator = Translator()
# Explicit curl transport with Safari impersonation
translator = Translator(
transport="curl",
impersonate="safari",
)
# Standard httpx transport
translator = Translator(
transport="httpx",
)
Available impersonation presets for curl-cffi include: "chrome", "chrome110", "chrome120", "safari", "safari15_3", "safari15_5", "edge99", "edge101", etc.
Network Resiliency & Forcing IPv4
On some networks, VPNs, or ISP configurations, IPv6 DNS resolution (AAAA records) or IPv6 routing hangs, resulting in:
CurlError: Failed to perform, curl: (28) Resolving timed out after 30004 milliseconds
You can force IPv4 resolution directly with ipv4=True or ip_resolve="v4":
from googletrans import Translator, SyncTranslator
# Async with forced IPv4
async with Translator(ipv4=True) as translator:
result = await translator.translate("안녕하세요.")
print(result.text)
# Synchronous with forced IPv4
translator = SyncTranslator(ipv4=True)
result = translator.translate("안녕하세요.")
# Advanced: custom libcurl options
from googletrans import CurlOpt
translator = Translator(curl_options={CurlOpt.IPRESOLVE: 1})
Supported ip_resolve values: "v4" (or 1), "v6" (or 2), "any" (or 0).
Advanced Usage
Bulk Translation
Translate multiple strings in a single call:
import asyncio
from googletrans import Translator
async def main():
async with Translator() as translator:
phrases = ["The quick brown fox", "jumps over", "the lazy dog"]
translations = await translator.translate(phrases, dest="ko")
for item in translations:
print(f"{item.origin} -> {item.text}")
asyncio.run(main())
Language Detection
Detect the language of text with confidence scores:
import asyncio
from googletrans import Translator
async def main():
async with Translator() as translator:
detection = await translator.detect("이 문장은 한글로 쓰여졌습니다.")
print(detection.lang) # "ko"
print(detection.confidence) # 0.27...
asyncio.run(main())
Custom Service URLs
Use alternate Google Translate service endpoints:
# Rotate across multiple domains
translator = Translator(service_urls=[
"translate.google.com",
"translate.google.co.kr",
])
# Direct client API (no token acquirer needed)
translator = Translator(service_urls=[
"translate.googleapis.com",
])
Command-Line Tool
googletrans-curl includes the translate CLI command:
# Translate text to English (default)
translate "veritas lux mea" -s la -d en
# Translate text to Korean
translate "Hello world" -d ko
# Force IPv4 resolution (prevents 30s DNS timeout on broken IPv6 networks)
translate "Hello world" -d ko -4
# Detect language
translate -c "안녕하세요."
Unofficial API Disclaimer
License
This project is licensed under the MIT License. Upstream copyright (c) 2015 SuHun Han. Modifications copyright (c) 2026 Matthias Kreier and contributors.
Metadata
Release files for googletrans-curl 4.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| googletrans_curl-4.1.1.tar.gz | 21.1 kB | With provenance | Details for googletrans_curl-4.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| googletrans_curl-4.1.1-py3-none-any.whl | Python 3 | none | any | Details for googletrans_curl-4.1.1-py3-none-any.whl |
Total release size: 44.5 kB
Release files / googletrans_curl-4.1.1.tar.gz
| Download URL | googletrans_curl-4.1.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4e36da8dc3537e75b8a152d3ea407cbbb5181bf8d7ca7f09cb2d5e74ed73342
|
|
BLAKE2b-256 checksum How to use checksums |
1f3d7fcd0a0a0aff3c3132a034dc748c442a5741f0adf1e584b7b61f765ae905
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / googletrans_curl-4.1.1-py3-none-any.whl
| Download URL | googletrans_curl-4.1.1-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
094718d22bdf8f282e1fb99a4c21d76567928fc599e0724599f4b4bcf8d3eb12
|
|
BLAKE2b-256 checksum How to use checksums |
bdfb73ad6a40ff36b6d1b15f1a73a148714e6d939d4879cb59afd0f124e652ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for googletrans-curl 4.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for googletrans_curl-4.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.