title: Batch Translate description: Translate multiple texts in a single request

Batch Translate

Translate multiple texts in a single request (up to 100 texts). All texts will be translated from the same source language to the same target language.

Endpoint

POST /v2/translate/batch

Request Parameters

Body Parameters

texts array (required) : Array of texts to translate (1-100 texts)

source string (required) : Source language code (e.g., "en", "fr") or "auto" for auto-detection

target string (required) : Target language code (e.g., "en", "fr")

Headers

X-API-KEY string (required) : Your API key for authentication

Content-Type string (required) : Must be application/json

Example Request

curl https://api.translateplus.io/v2/translate/batch \
  -H "X-API-KEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "texts": [
      "Hello, how are you?",
      "What is your name?",
      "Thank you very much"
    ],
    "source": "en",
    "target": "fr"
  }'
import requests

url = "https://api.translateplus.io/v2/translate/batch"
headers = {
    "X-API-KEY": "your_api_key",
    "Content-Type": "application/json"
}
data = {
    "texts": [
        "Hello, how are you?",
        "What is your name?",
        "Thank you very much"
    ],
    "source": "en",
    "target": "fr"
}

response = requests.post(url, json=data, headers=headers)
result = response.json()

for translation in result["translations"]:
    print(f"{translation['text']} → {translation['translation']}")
fetch('https://api.translateplus.io/v2/translate/batch', {
  method: 'POST',
  headers: {
    'X-API-KEY': 'your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    texts: [
      'Hello, how are you?',
      'What is your name?',
      'Thank you very much'
    ],
    source: 'en',
    target: 'fr'
  })
})
.then(response => response.json())
.then(data => {
  data.translations.forEach(t => {
    console.log(`${t.text} → ${t.translation}`);
  });
})
.catch(error => console.error('Error:', error));
const https = require('https');

const data = JSON.stringify({
  texts: [
    'Hello, how are you?',
    'What is your name?',
    'Thank you very much'
  ],
  source: 'en',
  target: 'fr'
});

const options = {
  hostname: new URL('https://api.translateplus.io').hostname,
  path: '/v2/translate/batch',
  method: 'POST',
  headers: {
    'X-API-KEY': 'your_api_key',
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    const result = JSON.parse(responseData);
    result.translations.forEach(t => {
      console.log(`${t.text} → ${t.translation}`);
    });
  });
});

req.on('error', (error) => {
  console.error('Error:', error);
});

req.write(data);
req.end();
<?php

$url = 'https://api.translateplus.io/v2/translate/batch';
$apiKey = 'your_api_key';

$data = [
    'texts' => [
        'Hello, how are you?',
        'What is your name?',
        'Thank you very much'
    ],
    'source' => 'en',
    'target' => 'fr'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-KEY: ' . $apiKey,
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $result = json_decode($response, true);
    foreach ($result['translations'] as $translation) {
        echo $translation['text'] . ' → ' . $translation['translation'] . "\n";
    }
} else {
    echo 'Error: ' . $response;
}

Response

Success Response (200 OK)

{
  "translations": [
    {
      "text": "Hello, how are you?",
      "translation": "Bonjour, comment allez-vous ?",
      "source": "en",
      "target": "fr",
      "success": true
    },
    {
      "text": "What is your name?",
      "translation": "Quel est votre nom ?",
      "source": "en",
      "target": "fr",
      "success": true
    },
    {
      "text": "Thank you very much",
      "translation": "Merci beaucoup",
      "source": "en",
      "target": "fr",
      "success": true
    }
  ],
  "total": 3,
  "successful": 3,
  "failed": 0
}

Response Fields

| Field | Type | Description | |-------|------|-------------| | translations | array | Array of translation results | | translations[].text | string | Original text that was translated | | translations[].translation | string | The translated text | | translations[].source | string | Source language code | | translations[].target | string | Target language code | | translations[].success | boolean | Whether the translation was successful | | total | integer | Total number of texts in the request | | successful | integer | Number of successful translations | | failed | integer | Number of failed translations |

Error Responses

400 Bad Request

Invalid request parameters:

{
  "detail": "Invalid language code 'xx'. Supported codes: en, fr, es..."
}

402 Payment Required

Insufficient credits:

{
  "detail": "Insufficient credits. You have 0 credit(s) remaining, but this request requires 3 credit(s). Please upgrade your plan to continue using the API."
}

403 Forbidden

Invalid or missing API key:

{
  "detail": "API key is required. Please provide X-API-KEY header."
}

429 Too Many Requests

Rate limit exceeded:

{
  "detail": "Rate limit exceeded. You have made 60 requests. Maximum allowed: 60 requests per minute. Please try again after 45 seconds."
}

Credits

This endpoint requires 1 credit per text in the batch. For example, a batch of 10 texts requires 10 credits.