Litokomane tsa API
Integrate ho fetolela matla ho likopo tsa hao le rona bonolo REST API.
Ho qala
TranslateAPI e fana ka interface e bonolo ea REST bakeng sa ho fetolela mongolo lipakeng tsa lipuo tse fetang 180. Liphetho tsohle tsa API li khutlisa likarabo tsa JSON.
1. Get Your API Key
Create a free account and generate your API key from the dashboard:
- Sign up at translateapi.ai/signup
- Go to Dashboard → Li-keys tsa API
- Click "Create API Key" and copy your key
API keys start with ta_ followed by 56 hex characters.
https://api.translateapi.ai/api/v1/2. Make Your First Request
Replace YOUR_API_KEY with the key from your dashboard:
curl -X POST https://api.translateapi.ai/api/v1/translate/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "Hello, world!",
"target_language": "es"
}'
import requests
response = requests.post(
"https://api.translateapi.ai/api/v1/translate/",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"text": "Hello, world!",
"target_language": "es"
}
)
result = response.json()
print(result["translated_text"]) # "Hola, mundo!"
const response = await fetch("https://api.translateapi.ai/api/v1/translate/", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
text: "Hello, world!",
target_language: "es"
})
});
const result = await response.json();
console.log(result.translated_text); // "Hola, mundo!"
$ch = curl_init("https://api.translateapi.ai/api/v1/translate/");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode([
"text" => "Hello, world!",
"target_language" => "es"
])
]);
$result = json_decode(curl_exec($ch), true);
echo $result["translated_text"]; // "Hola, mundo!"
payload := strings.NewReader(`{
"text": "Hello, world!",
"target_language": "es"
}`)
req, _ := http.NewRequest("POST", "https://api.translateapi.ai/api/v1/translate/", payload)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["translated_text"]) // "Hola, mundo!"
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var content = new StringContent(
JsonSerializer.Serialize(new {
text = "Hello, world!",
target_language = "es"
}),
Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.translateapi.ai/api/v1/translate/", content);
var result = JsonSerializer.Deserialize<JsonElement>(
await response.Content.ReadAsStringAsync()
);
Console.WriteLine(result.GetProperty("translated_text")); // "Hola, mundo!"
Likarabo
{
"translated_text": "Hola, mundo!",
"source_language": "en",
"target_language": "es",
"translations": {
"es": "Hola, mundo!"
},
"character_count": 13,
"translation_time": 0.45
}
Botšepehi
Ntlafatsa lipotso tsa hau ka ho sebelisa konopo ea API. U ka etsa konopo ea API ho tsoa ho eona dashboard.
Bopaki ba sehlooho (bo khothalletsoang)
Authorization: Bearer ta_your_api_key_here
ApiKey Header
Authorization: ApiKey ta_your_api_key_here
Parameter ea potso
https://api.translateapi.ai/api/v1/translate/?api_key=ta_your_api_key_here
Ho fetolela mongolo
Ho fetolela mongolo ka puo e le 'ngoe.
POST https://api.translateapi.ai/api/v1/translate/
Bophelo ba kopo
| Parameter | Mofuta | E hlokahalang | Tlhaloso |
|---|---|---|---|
text |
string | Ha ho joalo | Text to translate (max 50,000 characters) |
target_language |
string | Yeah* | Target language code (e.g., "es", "fr", "de") |
source_language |
string | Ha ho joalo | Source language code. Default: "auto" (auto-detect) |
engine |
string | Ha ho joalo | Translation engine: "auto" (default), "huggingface", or "madlad". See Translation Models. Litšoantšo tsa ho fetolela. |
* Ho sebelisa target_language (string) bakeng sa puo e le 'ngoe kapa target_languages (array) bakeng sa ho feta. Bona Ho fetolela lihlooho tse ngata.
Likarabo
{
"translated_text": "Hola, mundo!",
"source_language": "en",
"target_language": "es",
"translations": {
"es": "Hola, mundo!"
},
"character_count": 13,
"translation_time": 0.45
}
source_language or set it to "auto" to automatically detect the source language. The detected language is returned in the source_language response field.
Ho fetolela lihlooho tse ngata
Ho fetolela mongolo ka lipuo tse ngata ka kopo e le 'ngoe. E sebelisa sebaka sa ho qetela se tšoanang le ho fetolela ho le' ngoe.
POST https://api.translateapi.ai/api/v1/translate/
Bophelo ba kopo
{
"text": "Hello, world!",
"target_languages": ["es", "fr", "de", "ja"],
"source_language": "en"
}
Ho sebelisa target_languages (array) eseng target_language (string) bakeng sa liphetho tse ngata.
Likarabo
{
"source_language": "en",
"translations": {
"es": "Hola, mundo!",
"fr": "Bonjour, monde!",
"de": "Hallo, Welt!",
"ja": "こんにちは、世界!"
},
"character_count": 52,
"translation_time": 2.31
}
Ho fetolela
Ho fetolela litokomane tse ngata ka nako e le 'ngoe ka ho sebetsana le async. Tlosa batch' me u hlahlobe liphetho.
POST https://api.translateapi.ai/api/v1/translate/batch/
Phapang 1:
curl -X POST https://api.translateapi.ai/api/v1/translate/batch/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"texts": ["Hello", "Goodbye", "Thank you"],
"target_language": "es",
"source_language": "en"
}'
Likarabo (HTTP 202 e amoheloa)
{
"job_id": "67535b2b-c9e3-4f82-9499-e237edbc1dd8",
"status": "pending",
"total_texts": 3,
"queue_position": 1,
"source_language": "en",
"target_languages": ["es"],
"character_count": 22,
"credits_remaining": -1,
"poll_url": "https://api.translateapi.ai/api/v1/jobs/67535b2b-c9e3-4f82-9499-e237edbc1dd8/"
}
Phapang 2: Poll bakeng sa Liphetho
GET https://api.translateapi.ai/api/v1/jobs/{job_id}/
Mohlala oa polling (Python)
import time, requests
job_id = response.json()["job_id"]
total = response.json()["total_texts"]
headers = {"Authorization": "Bearer YOUR_API_KEY"}
print(f"Batch submitted: {total} texts (job {job_id})")
while True:
result = requests.get(f"https://api.translateapi.ai/api/v1/jobs/{job_id}/", headers=headers).json()
status = result["status"]
processed = result.get("processed_texts", 0)
progress = result.get("progress_percentage", 0)
if status == "completed":
print(f"Done: {processed}/{total} in {result.get('processing_time', 0):.1f}s")
translations = result["result_data"]["translations"]
break
elif status == "failed":
raise Exception(result.get("error_message", "Translation failed"))
elif status == "pending":
print(f"Queued (position {result.get('queue_position', '?')})")
else:
print(f"[{status}] {processed}/{total} ({progress:.0f}%)")
time.sleep(3)
Likarabo (li felile)
{
"job_id": "67535b2b-...",
"status": "completed",
"processed_texts": 3,
"total_texts": 3,
"progress_percentage": 100.0,
"processing_time": 10.65,
"result_data": {
"translations": ["Hola", "Adiós", "Gracias"],
"source_language": "en",
"target_language": "es",
"character_count": 22,
"processing_time": 10.65
}
}
Real-Time Progress Tracking
| Field | Tlhaloso |
|---|---|
status |
pending (queued, waiting for a GPU worker), processing (actively translating), completed, failed |
processed_texts |
Number of individual translations completed so far. Updates in real time as each text is translated. |
progress_percentage |
Completion percentage (0-100). Calculated from processed_texts / total_texts. |
queue_position |
Your position in the queue when status is "pending" (1 = next up). Null when processing or completed. Use this to estimate wait time and show queue status to your users. |
processing_time |
Total processing time in seconds (available when completed). |
Multi-Language Batch
Ho fetolela litokomane tse ngata ho lipuo tse ngata ka nako e le 'ngoe:
{
"texts": ["Hello", "Goodbye"],
"target_languages": ["es", "fr"],
"source_language": "en"
}
Result_data e felile
{
"translations": [
{"es": "Hola", "fr": "Bonjour"},
{"es": "Adiós", "fr": "Au revoir"}
],
"source_language": "en",
"target_languages": ["es", "fr"],
"character_count": 24,
"processing_time": 2.45
}
Liparametara tsa kopo
| Parameter | Mofuta | E hlokahalang | Tlhaloso |
|---|---|---|---|
texts |
array | Ha ho joalo | Array ea lihlooho tsa ho fetolela |
target_language |
string | Yeah* | Kode ea puo ea sepheo bakeng sa puo e le 'ngoe |
target_languages |
array | Yeah* | Array ea li-codes tsa puo ea sepheo bakeng sa lipuo tse ngata |
source_language |
string | Ha ho joalo | Source language code. Default: "auto" |
* Fetola e le efe target_language kapa target_languages, eseng ka bobeli.
Best Practices for Large Workloads
- Send 1 target language per batch request. This keeps each batch fast and makes progress easy to track.
- Keep batches at 50-100 texts. Smaller batches complete faster and give you more frequent progress updates.
- Submit as many batch jobs as you need — our GPU cluster auto-scales to handle demand. Jobs are processed in parallel across multiple instances.
- On timeout, re-poll the same job_id instead of submitting a new batch. The original job may still be processing on the GPU.
- Poll every 3-5 seconds. More frequent polling does not speed up processing.
Ho fetolela litokomane
Ho fetolela litokomane ka ho feletseng ka ho boloka ho hlophisoa. E tšehetsa litokomane tse ngata.
POST https://api.translateapi.ai/api/v1/translate/document/
Lipotso (li-multipart/form-data)
| Parameter | Mofuta | E hlokahalang | Tlhaloso |
|---|---|---|---|
file |
file | Ha ho joalo | Tlaleho eo u batlang ho e fetolela (max 10MB) |
target_language |
string | Ha ho joalo | Target language code (e.g., "es", "fr", "de") |
source_language |
string | Ha ho joalo | Source language code. Default: "auto" (auto-detect) |
Likarolo tsa lifaele tse tšehelitsoeng
Documents
.txt- Lifaele tsa mongolo o tloaelehileng.docx- Litokomane tsa Word.pdf- Litokomane tsa PDF (ho akarelletsa le tse scanned)
Data & Localization
.json- Lifaele tsa JSON (li fetolela li-string values).xml- Lifaele tsa XML.srt- Lifaele tsa li-subtitle.po/.pot- Lifaele tsa ho fetolela Gettext
Images (OCR)
.jpg/.jpeg- Litšoantšo tsa JPEG (OCR).png- Litšoantšo PNG (OCR).tiff/.tif- Litšoantšo tsa TIFF (OCR).bmp- Litšoantšo tsa BMP (OCR).webp- Litšoantšo tsa WebP (OCR)
Mohlala (cURL)
# Translate a Word document
curl -X POST https://api.translateapi.ai/api/v1/translate/document/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.docx" \
-F "target_language=es" \
-F "source_language=en"
# Translate text from an image (OCR)
curl -X POST https://api.translateapi.ai/api/v1/translate/document/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@scanned_page.jpg" \
-F "target_language=es" \
-F "source_language=en"
Likarabo
{
"id": 123,
"original_filename": "document.docx",
"file_type": "docx",
"source_language": "en",
"target_language": "es",
"status": "completed",
"character_count": 5420,
"translated_file_url": "/media/translated/document_es.docx",
"created_at": "2024-01-15T10:30:00Z",
"completed_at": "2024-01-15T10:30:05Z"
}
GET https://api.translateapi.ai/api/v1/translate/document/{id}/
Check the status of a document translation or get the download URL.
Matšoao a boemo
pending |
Faele e lokollotsoemetse ho sebetsanoa |
processing |
Ho fetolela ho ntse ho etsoa |
completed |
Ho fetolela ho phethetsoe, ho na le ho kenya |
failed |
Ho fetolela ho sa atlehe (check error_message) |
Li-languages tse tšehelitsoeng
Fumana lethathamo la lipuo tsohle tse tšehelitsoeng.
GET https://api.translateapi.ai/api/v1/translate/languages/
Likarabo
{
"count": 186,
"results": [
{"iso": "en", "name": "English", "en_label": "English"},
{"iso": "es", "name": "Español", "en_label": "Spanish"},
{"iso": "fr", "name": "Français", "en_label": "French"},
...
]
}
Submit Corrections
Suggest a better translation for a given source text. Corrections enter a moderation queue; once approved by our team they surface as "Community Verified" translations for that text.
https://translateapi.ai/api/v1/ (not the api. translation host), and requires an API key.POST https://translateapi.ai/api/v1/suggestions/
Bophelo ba kopo
| Parameter | Mofuta | Tlhaloso |
|---|---|---|
source_text |
string | The original text that was translated. |
source_language |
string | Source language code (e.g. "en"). |
target_language |
string | Target language code (e.g. "es"). |
machine_translation |
string | The machine translation you are correcting. |
suggested_translation |
string | Your improved translation (must differ from machine_translation). |
Example Request
curl -X POST https://translateapi.ai/api/v1/suggestions/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source_text": "Hello, world!",
"source_language": "en",
"target_language": "es",
"machine_translation": "Hola, mundo!",
"suggested_translation": "¡Hola, mundo!"
}'
Likarabo
{
"id": 4213,
"status": "pending",
"created": true,
"message": "Correction submitted for review."
}
Re-submitting the same source/language pair updates your existing suggestion instead of creating a duplicate (returns 200 with "created": false).
Litšoantšo tsa ho fetolela
Re sebelisa li-models tsa ho fetolela li-open source tse sebetsang ka li-infrastructure tsa GPU tsa rona. Li-models tsohle li na le laesense ea khoebo (Apache 2.0).
| Mofuta | Li-languages | E loketseng |
|---|---|---|
| Helsinki-NLP/opus-mt | Lihlopha tsa lipuo tse fetang 50 | Li-language tse tloaelehileng (EN, ES, FR, DE, IT, PT, RU, ZH, JA, jj.) |
| Google MADLAD-400 | 400+ lipuo | Li-languages tse sa tloaelehang, li-coverage tse felletseng |
API e khetha ka boiketsetso mofuta o motle ka ho fetisisa oa puo ea hau. U ka khetha ho bonts'a engine Parameter:
| Enjene | Tlhaloso |
|---|---|
"auto" |
Bofela. E leka HuggingFace pele, e khutlela ho MADLAD-400 |
"huggingface" |
Force HuggingFace/MarianMT (e potlakileng ka ho fetisisa, lipuo tse fetang 50) |
"madlad" |
Force MADLAD-400 (400+ lipuo) |
Ho sebetsana le liphoso
Li-API li sebelisa li-standard HTTP status codes ho bonts'a katleho kapa ho hloleha.
| Kopa | Tlhaloso |
|---|---|
| 200 | Bophelo bo botle |
| 202 | Accepted — Batch job queued successfully |
| 400 | Bad Request — Invalid parameters (missing text, unsupported language, etc.) |
| 401 | Ha e amoheloe - konopo ea API e fosahetse kapa e sa nepahale |
| 402 | Payment Required — Character credits exhausted. Upgrade your plan or purchase a top-up. |
| 403 | Forbidden — API key lacks required scope or IP not in whitelist |
| 503 | Service Not Available - Translation engine temporarily down |
Bophara ba karabo ea bothata
{
"error": "insufficient_credits",
"credits_remaining": 0
}
Usage Limits
TranslateAPI has no request rate limits. All requests are queued and processed by our auto-scaling GPU cluster. Your plan determines your monthly character allowance:
| Likarolo | Litšoantšo/khoeli | Batch API | Documents | Theko | |
|---|---|---|---|---|---|
| Free | 250,000 | — | — | $0 | Ikopanye le rona |
| Motsamaisi | 2,500,000 | $9/mo | Ikopanye | ||
| Pro | 10,000,000 | $29/mo | Ikopanye | ||
| Lichelete | 40,000,000 | $79/mo | Ikopanye | ||
| Litlhaku | 125,000,000 | $199/mo | Ikopanye | ||
| Enterprise | Unlimited | $499/mo | Contact Sales |
Ha u feta tekanyetso ea hau, u tla fumana 402 Payment Required karabo ho fihlela khoeli e tlang kapa u ntlafatsa.
Auto-Scaling Cloud Infrastructure
TranslateAPI runs on dedicated NVIDIA A100 GPU instances with automatic horizontal scaling. When demand increases, additional GPU instances are launched within minutes to maintain fast response times. All requests are queued and processed — send hundreds of concurrent requests and they'll all be handled. Real-time translations get priority, batch jobs process in the background.
Need More Credits?
Run out of characters mid-month? Purchase a one-time credit top-up without changing your plan. View top-up packs