Google Translate API Usage Guide
If you need to automate translation tasks via API, the Google Translate API is a solid choice. Its translation quality may be slightly behind DeepL, but it offers better value—especially with 500,000 free characters every month.
Product Overview
Everyone has used Google Translate. Here we’re talking about its API service, officially called Google Cloud Translation. With the API you can do bulk translation, build custom models, translate documents, and more.
Pricing
500,000 characters free per month. Beyond that, you pay per character.
Basic vs Advanced
Feature | Basic | Advanced |
---|---|---|
Free Monthly Quota | 500,000 | 500,000 |
Cost per 1 M chars | $20 | $80 |
Document Price | $0.08 / pg | $0.25 / pg |
Custom Models | ✘ | ✔ |
Getting Started
- Enable the API. If billing isn’t set up, you’ll be prompted to add a foreign-currency credit card.
$cred = gcloud auth print-access-token
$project_id = "example"
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://cloudresourcemanager.googleapis.com/v3/projects/${project_id}" | Select-Object -Expand Content
- Quick test
$cred = gcloud auth print-access-token
$project_id = "example"
$body = @{
"sourceLanguageCode" = "en"
"targetLanguageCode" = "zh"
"contents" = @("Hello, world!")
"mimeType" = "text/plain"
}
$body = $body | ConvertTo-Json
$headers = @{
"Authorization" = "Bearer $cred"
"Content-Type" = "application/json; charset=utf-8"
"x-goog-user-project" = $project_id
}
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://translation.googleapis.com/v3/projects/${project_id}:translateText" `
-Body $body | Select-Object -Expand Content
On Linux, use curl:
export CRED=$(gcloud auth print-access-token)
export PROJECT_ID="example"
export SOURCE_LANGUAGE_CODE="en"
export TARGET_LANGUAGE_CODE="zh"
export CONTENTS="Hello, world!"
export MIME_TYPE="text/plain"
curl -X POST -H "Authorization: Bearer $CRED" -H "Content-Type: application/json; charset=utf-8" -H "x-goog-user-project: $PROJECT_ID" -d "{
\"sourceLanguageCode\": \"$SOURCE_LANGUAGE_CODE\",
\"targetLanguageCode\": \"$TARGET_LANGUAGE_CODE\",
\"contents\": [\"$CONTENTS\"],
\"mimeType\": \"$MIME_TYPE\"
}" "https://translation.googleapis.com/v3/projects/$PROJECT_ID:translateText"
You now have everything you need to run bulk translations via the Google Translate API.
Common Use Cases
- Translate websites or apps
- Train custom translation models
- Add multilingual subtitles to videos
- Provide multilingual voiceovers
- Translate richly formatted documents
- Translate customer interactions in real time
Further Reading
- Cloud Translation Docs
- Authenticate with Cloud Translation
- Authenticate with API Keys
- Source and target languages use ISO-639 codes
- Custom Translation Overview
Closing Notes
Google’s official documentation can be verbose; there are often several ways to achieve the same goal. This guide picks the simplest and most recommended flow for typical users.
- We used local authentication (gcloud CLI)
- We relied on the REST API with Curl/Invoke-WebRequest
- And we opted for the Advanced tier
Originally published at blog.jqknono.dev, reproduction without permission is prohibited.
Get Alibaba Cloud Edge Security Acceleration (ESA) for Free
Alibaba Cloud Edge Security Acceleration (ESA) is a comprehensive service that integrates CDN, edge security protection, and dynamic acceleration. It significantly boosts the speed and security of websites and applications.
This article briefly explains how to claim an ESA package at no cost through official channels.
The campaign is open to all Alibaba Cloud users who have completed account verification. Free service credits are awarded in exchange for sharing your experience.
- Promotion period: Starts on July 7, 2025, and runs for the long term (check official announcements for the final end date).
- Participation rules:
- Create Content: Publish a post or video recommending Alibaba Cloud ESA on any social platform or tech forum (e.g., Linux.do, V2EX, X.com (Twitter), Bilibili, personal blog, etc.).
- Content Requirements: The post/video must be positive and include at least one ESA-related image (e.g., ESA console screenshot, speed-test comparison, official product promo graphic).
- Mandatory Link: The exclusive ESA free-claim URL (http://s.tb.cn/e6.0DENEf) must appear in the content.
- Claim Your Reward: After publishing, submit the link to your post/video and your Alibaba Cloud account ID to the reward-assistant via direct message or by joining the official group chat.
- Review & Distribution: Once approved, you’ll receive a voucher for 1-month ESA Basic.
- Create Content: Publish a post or video recommending Alibaba Cloud ESA on any social platform or tech forum (e.g., Linux.do, V2EX, X.com (Twitter), Bilibili, personal blog, etc.).
Tips:
- Each social-media account can claim the voucher only once per week.
- There’s no limit to total redemptions; just change platforms or create new content weekly.
- High-quality, high-readership posts (e.g., in-depth reviews or usage reports) may earn upgraded vouchers as extra rewards.
Important Notes
Please read the following to ensure a smooth redemption and usage of your free service:
- Voucher Usage: The voucher can cover traffic exceeding the Basic plan quota or be applied toward purchasing or upgrading to higher-tier plans.
- Finding Your Account ID: Log in to the Alibaba Cloud console, click your avatar in the upper-right corner, and find your account ID in the pop-up menu.
- Voucher Validity: The vouchers issued are normally valid for 365 days.
- Event End: The ESA team will decide the final end date based on overall participation and will announce it in advance in the official documentation.
Real-World Results
The ESA international edition offers global coverage. Actual tests show promising speeds—almost everything is green.