Translation (Batch Mode)
Translate Batch
Section titled “Translate Batch”Translate multiple texts in a single batch request.
Endpoint: POST /translation/translate-batch
Request Body
Section titled “Request Body”{ "sourceLanguage": "en", "targetLanguage": "de", "texts": [ "Hello, World!", "How are you?", "Thank you very much" ]}Parameters:
sourceLanguage: Source language code (use “auto” for automatic detection)targetLanguage: Target language codetexts: Array of strings to translate
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": [ "Hallo, Welt!", "Wie geht es dir?", "Vielen Dank" ]}Example Request
Section titled “Example Request”curl -X POST "https://platform.algebras.ai/api/v1/translation/translate-batch" \ -H "X-Api-Key: your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "sourceLanguage": "en", "targetLanguage": "de", "texts": [ "Hello, World!", "How are you?", "Thank you very much" ] }'import requests
url = "https://platform.algebras.ai/api/v1/translation/translate-batch"headers = { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json"}data = { "sourceLanguage": "en", "targetLanguage": "de", "texts": [ "Hello, World!", "How are you?", "Thank you very much" ]}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200: result = response.json() translated_texts = result["data"] for i, text in enumerate(translated_texts): print(f"Translation {i+1}: {text}")else: print(f"Error: {response.status_code}") print(response.json())const url = "https://platform.algebras.ai/api/v1/translation/translate-batch";
const response = await fetch(url, { method: "POST", headers: { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json", }, body: JSON.stringify({ sourceLanguage: "en", targetLanguage: "de", texts: [ "Hello, World!", "How are you?", "Thank you very much", ], }),});
if (response.ok) { const result = await response.json(); result.data.forEach((text, index) => { console.log(`Translation ${index + 1}:`, text); });} else { const error = await response.json(); console.error("Error:", response.status, error);package main
import ( "bytes" "encoding/json" "fmt" "io" "net/http")
func main() { url := "https://platform.algebras.ai/api/v1/translation/translate-batch"
payload := map[string]interface{}{ "sourceLanguage": "en", "targetLanguage": "de", "texts": []string{ "Hello, World!", "How are you?", "Thank you very much", }, }
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", "your_api_key_here") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 { var result map[string]interface{} json.Unmarshal(body, &result) translations := result["data"].([]interface{}) for i, text := range translations { fmt.Printf("Translation %d: %s\n", i+1, text) } } else { fmt.Printf("Error: %d\n", resp.StatusCode) fmt.Println(string(body)) }}Start Agentic Translation Task
Section titled “Start Agentic Translation Task”Start an asynchronous agentic translation task.
Endpoint: POST /translation/agentic-translate
Request Body
Section titled “Request Body”{ "sourceLanguage": "en", "targetLanguage": "de", "text": "Hello, World!", "options": { "uiSafe": false, "glossaryId": "glossary-123" }}Parameters:
sourceLanguage: Source language codetargetLanguage: Target language codetext: Text to translateoptions: Optional configuration objectuiSafe: Whether to ensure UI-safe translations (optional)glossaryId: Glossary ID to use for translation (optional)
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "id": "task-123456", "status": "pending" }}Example Request
Section titled “Example Request”curl -X POST "https://platform.algebras.ai/api/v1/translation/agentic-translate" \ -H "X-Api-Key: your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "sourceLanguage": "en", "targetLanguage": "de", "text": "Hello, World!", "options": { "uiSafe": false, "glossaryId": "glossary-123" } }'import requests
url = "https://platform.algebras.ai/api/v1/translation/agentic-translate"headers = { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json"}data = { "sourceLanguage": "en", "targetLanguage": "de", "text": "Hello, World!", "options": { "uiSafe": False, "glossaryId": "glossary-123" }}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200: result = response.json() task_id = result["data"]["id"] task_status = result["data"]["status"] print(f"Task ID: {task_id}, Status: {task_status}")else: print(f"Error: {response.status_code}") print(response.json())const url = "https://platform.algebras.ai/api/v1/translation/agentic-translate";
const response = await fetch(url, { method: "POST", headers: { "X-Api-Key": "your_api_key_here", "Content-Type": "application/json", }, body: JSON.stringify({ sourceLanguage: "en", targetLanguage: "de", text: "Hello, World!", options: { uiSafe: false, glossaryId: "glossary-123", }, }),});
if (response.ok) { const result = await response.json(); console.log("Task ID:", result.data.id); console.log("Status:", result.data.status);} else { const error = await response.json(); console.error("Error:", response.status, error);}package main
import ( "bytes" "encoding/json" "fmt" "io" "net/http")
func main() { url := "https://platform.algebras.ai/api/v1/translation/agentic-translate"
payload := map[string]interface{}{ "sourceLanguage": "en", "targetLanguage": "de", "text": "Hello, World!", "options": map[string]interface{}{ "uiSafe": false, "glossaryId": "glossary-123", }, }
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", "your_api_key_here") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 { var result map[string]interface{} json.Unmarshal(body, &result) data := result["data"].(map[string]interface{}) fmt.Printf("Task ID: %v, Status: %v\n", data["id"], data["status"]) } else { fmt.Printf("Error: %d\n", resp.StatusCode) fmt.Println(string(body)) }}Get Agentic Translation Task Status
Section titled “Get Agentic Translation Task Status”Get the status of an agentic translation task by ID.
Endpoint: GET /translation/agentic-translate/{id}
Path Parameters
Section titled “Path Parameters”id: Task ID returned from the agentic-translate endpoint
Response
Section titled “Response”Success Response (200)
{ "status": "ok", "timestamp": "2025-01-12T22:31:48.856Z", "data": { "id": "task-123456", "status": "completed", "result": "Hallo, Welt!", "progress": 100 }}Example Request
Section titled “Example Request”curl -X GET "https://platform.algebras.ai/api/v1/translation/agentic-translate/task-123456" \ -H "X-Api-Key: your_api_key_here"import requests
task_id = "task-123456"url = f"https://platform.algebras.ai/api/v1/translation/agentic-translate/{task_id}"headers = { "X-Api-Key": "your_api_key_here"}
response = requests.get(url, headers=headers)
if response.status_code == 200: result = response.json() task_data = result["data"] print(f"Task ID: {task_data['id']}") print(f"Status: {task_data['status']}") if task_data.get("result"): print(f"Result: {task_data['result']}")else: print(f"Error: {response.status_code}") print(response.json())const taskId = "task-123456";const url = `https://platform.algebras.ai/api/v1/translation/agentic-translate/${taskId}`;
const response = await fetch(url, { method: "GET", headers: { "X-Api-Key": "your_api_key_here", },});
if (response.ok) { const result = await response.json(); console.log("Task ID:", result.data.id); console.log("Status:", result.data.status); if (result.data.result) { console.log("Result:", result.data.result); }} else { const error = await response.json(); console.error("Error:", response.status, error);}package main
import ( "encoding/json" "fmt" "io" "net/http")
func main() { taskID := "task-123456" url := fmt.Sprintf("https://platform.algebras.ai/api/v1/translation/agentic-translate/%s", taskID)
req, _ := http.NewRequest("GET", url, nil) req.Header.Set("X-Api-Key", "your_api_key_here")
client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 { var result map[string]interface{} json.Unmarshal(body, &result) data := result["data"].(map[string]interface{}) fmt.Printf("Task ID: %v\n", data["id"]) fmt.Printf("Status: %v\n", data["status"]) if result, ok := data["result"].(string); ok { fmt.Printf("Result: %s\n", result) } } else { fmt.Printf("Error: %d\n", resp.StatusCode) fmt.Println(string(body)) }}