Text Translator

Text Translator

AI Tools Text Processing Credits / request: 100

Translates the given text into the targeted language.

POST https://api.apikodu.com/api/v1/translator
Documentation
Overview

Translates text to a target language.

Authentication

Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).

Request
POST https://api.apikodu.com/api/v1/translator
JSON body.
Parameters
Name Type Required Default Options Description
text string * Required — — Text to translate (max 500 characters).
target string * Required — — Target language code (tr, en, de ...).
source string Optional — — Source language. Detected automatically if empty.
Response
Name Type Description
sourceLang string Source language ISO code (tr, en, de ...). Detected when source is empty.
targetLang string Target language ISO code. Same as the request target.
translatedText string Translated text. Translation of the input (max 500 characters).
Errors
HTTP code Description
400 -218 target is empty or an unsupported language code.
400 -223 source was sent but is an unsupported language code.
400 -222 source and target are the same language.
400 -219 text is empty or longer than 500 characters.
500 -220 Google API access token could not be obtained.
401 -100 x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API.
429 -221 Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset.
429 — Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field).
500 -1 Unexpected server error. message is a generic error text without technical details.
Notes
  • Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).

Sample response

{
  "data": {
    "sourceLang": "en",
    "targetLang": "tr",
    "translatedText": "Merhaba dünya"
  }
}

Code samples

  
      const response = await fetch('https://api.apikodu.com/api/v1/translator', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
        },
        body: JSON.stringify({
          name: 'example',
          value: 123
        })
      });

      const data = await response.json();
      console.log(data);
  
  
      import requests

      headers = {
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
      }

      payload = {
          'name': 'example',
          'value': 123
      }

      response = requests.post('https://api.apikodu.com/api/v1/translator', headers=headers, json=payload)
      data = response.json()
      print(data)
  
  
      using var client = new HttpClient();
      client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");

      var payload = new { name = "example", value = 123 };
      var json = JsonSerializer.Serialize(payload);
      var content = new StringContent(json, Encoding.UTF8, "application/json");

      var response = await client.PostAsync("https://api.apikodu.com/api/v1/translator", content);
      response.EnsureSuccessStatusCode();

      var data = await response.Content.ReadAsStringAsync();
      Console.WriteLine(data);
  
 
     $data = [
         'name' => 'example',
         'value' => 123
     ];

     $response = file_get_contents('https://api.apikodu.com/api/v1/translator', false, stream_context_create([
         'http' => [
             'header' => "x-api-key: YOUR_API_KEY"
         ],
         'method'  => 'POST',"
         'content' => json_encode($data)
      ]));

      print_r(json_decode($response, true));
 
  
      curl -X POST 'https://api.apikodu.com/api/v1/translator' \
        -H 'Content-Type: application/json' \
        -H 'x-api-key: YOUR_API_KEY' \
        -d '{
          "name": "example",
          "value": 123
        }'
  

Start building in minutes

Create a free account, get your API key and send your first request in minutes.

Get started free