# NLP Translation API quickstart and reference

> NLP Translation is a REST API for neural machine translation: send plain text, HTML or a JSON document and get the translation back as simple JSON, in more than 100 languages. Base URL: `https://nlp-translation.p.rapidapi.com`. Authenticate with your RapidAPI key.

Last updated: 2026-11-30. Try every endpoint in the RapidAPI playground: https://rapidapi.com/gofitech/api/nlp-translation/playground

## Authentication

Every request sends two headers. Your key comes from RapidAPI after you subscribe to a plan (Basic is free). Call the API from your own backend so the key stays private.

| Header | Where | Required | Value |
| --- | --- | --- | --- |
| `x-rapidapi-key` | header | Yes | Your RapidAPI application key, shown on the RapidAPI listing once you subscribe. |
| `x-rapidapi-host` | header | Yes | Always `nlp-translation.p.rapidapi.com`. |

## Translate text or HTML: `/v1/translate`

`GET /v1/translate` takes the parameters in the query string. `POST /v1/translate` takes them in the body as JSON, form-urlencoded or multipart.

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | string | Yes | Plain text or HTML to translate. Up to 1,000 characters per request on Basic, 5,000 on paid plans. |
| `to` | string | Yes | Target language code, or several separated by `;` (for example `fr;pt`). Codes are case-sensitive. |
| `from` | string | No | Source language code. Omit it for automatic source language detection. |
| `protected_words` | string | No | Words to leave untranslated, separated by `;` (for example `Acme;CloudSync`). Case-sensitive. |

### Request

**cURL**

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/translate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"text":"Nice to meet you","to":"fr","from":"en"}'
```

**JavaScript**

```js
const response = await fetch("https://nlp-translation.p.rapidapi.com/v1/translate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-rapidapi-host": "nlp-translation.p.rapidapi.com",
    "x-rapidapi-key": process.env.RAPIDAPI_KEY,
  },
  body: JSON.stringify({
    text: "Nice to meet you",
    to: "fr",
    from: "en",
  }),
});
const data = await response.json();
if (data.status !== 200) throw new Error(data.Error);
console.log(data.translated_text["fr"]);
```

**Python**

```python
import os
import requests

response = requests.post(
    "https://nlp-translation.p.rapidapi.com/v1/translate",
    headers={
        "x-rapidapi-host": "nlp-translation.p.rapidapi.com",
        "x-rapidapi-key": os.environ["RAPIDAPI_KEY"],
    },
    json={
        "text": "Nice to meet you",
        "to": "fr",
        "from": "en",
    },
    timeout=30,
)
data = response.json()
print(data["translated_text"]["fr"])
```

**PHP**

```php
<?php
$ch = curl_init("https://nlp-translation.p.rapidapi.com/v1/translate");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "x-rapidapi-host: nlp-translation.p.rapidapi.com",
        "x-rapidapi-key: " . getenv("RAPIDAPI_KEY"),
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'text' => 'Nice to meet you',
        'to' => 'fr',
        'from' => 'en',
    ]),
]);
$data = json_decode(curl_exec($ch), true);
echo $data["translated_text"]['fr'];
```

### Response

```json
{
  "status": 200,
  "from": "en",
  "to": "fr",
  "original_text": "Nice to meet you",
  "translated_text": {
    "fr": "Ravi de vous rencontrer"
  },
  "translated_characters": 16
}
```

| Field | Type | Present | Description |
| --- | --- | --- | --- |
| `status` | number | Always | `200` on success, otherwise the error code. Always check this field. |
| `from` | string | On success | Source language code (detected when you omitted `from`). |
| `to` | string | On success | Target codes that were translated, separated by `;`. |
| `original_text` | string | On success | The text you sent. |
| `translated_text` | object | On success | One entry per target code: `{ "fr": "…" }`. |
| `translated_characters` | number | On success | Characters counted for this request: text length × number of target languages. |
| `message` | string | Sometimes | Notes a plan limit, for example when extra target languages were dropped. |
| `Error` | string | On error | What went wrong, in plain English. |

### GET request

```bash
curl --request GET \
  --url 'https://nlp-translation.p.rapidapi.com/v1/translate?text=Nice%20to%20meet%20you&to=fr' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY'
```

## Several target languages

Separate target codes with `;` to get every translation in one response. Your plan sets how many codes one request may list (Basic 1, Pro 2, Ultra 3, Mega 4); extra codes are dropped and `message` says so.

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/translate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"text":"Nice to meet you","to":"fr;pt","from":"en"}'
```

```json
{
  "status": 200,
  "from": "en",
  "to": "fr;pt",
  "original_text": "Nice to meet you",
  "translated_text": {
    "fr": "Ravi de vous rencontrer",
    "pt": "Prazer em conhecê-lo"
  },
  "translated_characters": 32
}
```

When `to` lists more codes than your plan allows:

```json
{
  "status": 200,
  "from": "en",
  "to": "fr;pt",
  "original_text": "Nice to meet you",
  "translated_text": {
    "fr": "Ravi de vous rencontrer",
    "pt": "Prazer em conhecê-lo"
  },
  "translated_characters": 32,
  "message": "Translated. Maximum Multiple target languages simultaneously in your current plan is 2"
}
```

## HTML

Send HTML in `text`: tags and attributes are preserved and only the text is translated. Markup counts toward the characters of the request.

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/translate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"text":"<p>Free shipping on <strong>all orders</strong></p>","to":"es","from":"en"}'
```

```json
{
  "status": 200,
  "from": "en",
  "to": "es",
  "original_text": "<p>Free shipping on <strong>all orders</strong></p>",
  "translated_text": {
    "es": "<p>Envío gratis en <strong>todos los pedidos</strong></p>"
  },
  "translated_characters": 51
}
```

## Protected words

`protected_words` lists words to keep exactly as written (brand names, product terms), separated by `;`. Matching is case-sensitive.

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/translate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"text":"Acme Cloud keeps your files safe","to":"de","from":"en","protected_words":"Acme Cloud"}'
```

## Translate JSON: `POST /v1/jsontranslate`

`/v1/jsontranslate` translates the string values of a JSON object and keeps keys, numbers and structure. Send the document as a string in `json`; `from` is required on this endpoint.

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `json` | string | Yes | The JSON document to translate, as a string. It must be an object (`{…}`). A JSON object instead of a string also works. |
| `to` | string | Yes | Target language code, or several separated by `;`. Codes are case-sensitive. |
| `from` | string | Yes | Source language code. Required on this endpoint (no automatic detection). |
| `protected_keys` | string | No | Keys whose values are left as they are, separated by `;`. Use dot paths for nested keys, for example `id;meta.sku`. |
| `protected_words` | string | No | Words to leave untranslated inside the values, separated by `;`. Case-sensitive. |

**cURL**

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/jsontranslate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"from":"en","to":"de","json":"{\"title\":\"Welcome home\"}"}'
```

**JavaScript**

```js
const response = await fetch("https://nlp-translation.p.rapidapi.com/v1/jsontranslate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-rapidapi-host": "nlp-translation.p.rapidapi.com",
    "x-rapidapi-key": process.env.RAPIDAPI_KEY,
  },
  body: JSON.stringify({
    from: "en",
    to: "de",
    json: "{\"title\":\"Welcome home\"}",
  }),
});
const data = await response.json();
if (data.status !== 200) throw new Error(data.Error);
console.log(data.translated_json["de"]);
```

**Python**

```python
import os
import requests

response = requests.post(
    "https://nlp-translation.p.rapidapi.com/v1/jsontranslate",
    headers={
        "x-rapidapi-host": "nlp-translation.p.rapidapi.com",
        "x-rapidapi-key": os.environ["RAPIDAPI_KEY"],
    },
    json={
        "from": "en",
        "to": "de",
        "json": "{\"title\":\"Welcome home\"}",
    },
    timeout=30,
)
data = response.json()
print(data["translated_json"]["de"])
```

**PHP**

```php
<?php
$ch = curl_init("https://nlp-translation.p.rapidapi.com/v1/jsontranslate");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "x-rapidapi-host: nlp-translation.p.rapidapi.com",
        "x-rapidapi-key: " . getenv("RAPIDAPI_KEY"),
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'from' => 'en',
        'to' => 'de',
        'json' => '{"title":"Welcome home"}',
    ]),
]);
$data = json_decode(curl_exec($ch), true);
echo $data["translated_json"]['de'];
```

```json
{
  "status": 200,
  "from": "en",
  "to": "de",
  "original_json": "{\"title\":\"Welcome home\"}",
  "protected_keys": "",
  "protected_words": "",
  "translated_json": {
    "de": "{\"title\":\"Willkommen zu Hause\"}"
  },
  "translated_characters": 24
}
```

| Field | Type | Present | Description |
| --- | --- | --- | --- |
| `status` | number | Always | `200` on success, otherwise the error code. |
| `from` | string | On success | Source language code. |
| `to` | string | On success | Target codes that were translated. |
| `original_json` | string | On success | The JSON document you sent. |
| `translated_json` | object | On success | One translated JSON string per target code. |
| `translated_characters` | number | On success | Characters counted: JSON length × number of target languages. |
| `Error` | string | On error | What went wrong. |

### Protected keys

`protected_keys` lists keys whose values are returned unchanged, separated by `;`, with dot paths for nested keys (`meta.sku`).

```bash
curl --request POST \
  --url https://nlp-translation.p.rapidapi.com/v1/jsontranslate \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: nlp-translation.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --data '{"from":"en","to":"fr","json":"{\"sku\":\"TSHIRT-01\",\"name\":\"Blue T-shirt\"}","protected_keys":"sku"}'
```

## Errors

Errors use the format `{"status": <code>, "Error": "<message>"}`. The HTTP status is often 200 even when the request failed, so always check the `status` field of the body.

```json
{
  "status": 412,
  "Error": "Invalid Target Language Code: fra"
}
```

| When | HTTP | Body |
| --- | --- | --- |
| `to` is missing or empty | 200 | `{"status":412,"Error":"Target Language Code Needed"}` |
| A target code is not in the language list (codes are case-sensitive) | 200 | `{"status":412,"Error":"Invalid Target Language Code: fra"}` |
| `text` is longer than your plan allows (1,000 on Basic, 5,000 on paid plans) | 200 | `{"status":412,"Error":"Text with More than 1000 characters or less than one Character is not allowed"}` |
| More requests in progress than your plan's concurrent limit | 200 | `{"status":429,"Error":"Your are currently have 1 translating job, Your Max thread: 1"}` |
| `/v1/jsontranslate` without `from` | 412 | `{"status":412,"Error":"From Language Code Needed in JSON Data Translation"}` |
| `/v1/jsontranslate` without `to` | 200 | `{"status":412,"Error":"Target Language Code Needed in JSON Data Translation"}` |
| `json` is not a JSON object | 200 | `{"status":412,"Error":"JSON must be start with { && end with }"}` |
| A temporary problem on our side | 500 | `{"status":500,"Error":"Server Error"}` |

Errors about your key, subscription or monthly quota come from RapidAPI in RapidAPI's own format, for example `{"message": "You are not subscribed to this API."}`.

## Language codes

Codes are case-sensitive: use `zh-CN`, not `zh-cn`. Some codes differ from ISO 639-1: Hebrew is `iw`, Javanese is `jw`. All 110 codes: https://nlptranslation.com/languages
