Skip to main content

googletrans-curl

PyPI version License: MIT Python Version GitHub Repo

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

Existing applications continue importing googletrans with zero code modifications:

from googletrans import Translator

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 googletrans code.
  • Anti-429 Protection: Uses curl-cffi with Chrome TLS/HTTP2 impersonation.
  • Pluggable Transports: Switch between curl (anti-blocking) and standard httpx.
  • Async First: Native async/await support 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:

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"

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.


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

# 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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for googletrans-curl 4.1.0
File Size Uploaded
googletrans_curl-4.1.0.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for googletrans-curl 4.1.0
File Interpreter ABI Platform
googletrans_curl-4.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.3 kB

Release files / googletrans_curl-4.1.0.tar.gz

Download URL googletrans_curl-4.1.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e04e1204c91ce9481b7e9c0cae871fffa727232b286c555779eed0e1214825d1
BLAKE2b-256 checksum
How to use checksums
6d3fcfec06a244af2c9b10084dd163abde692ede862c18ce09bd2573f73caccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / googletrans_curl-4.1.0-py3-none-any.whl

Download URL googletrans_curl-4.1.0-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c427c747b31e7030d7a86d16e4a5d1d4befdda5e5b264da7d1be49b439c4099a
BLAKE2b-256 checksum
How to use checksums
5e0d86ccc6d9f22bffc942f4356e687eb73439875237423b7704ee861d63ba0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 release files

4.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page