# Translator API

> Translate text between 46 languages.

Machine translation between any two supported languages. Send the text, the source language and the target language; the translated text comes back in `data.text`.

- **Endpoint:** `POST https://api.zactonz.com/translator/`
- **Category:** Text
- **Version:** 1
- **Status:** stable
- **Authentication:** `Authorization: Bearer YOUR_API_KEY`
- **Reference page:** https://developers.zactonz.com/apis/translator/

## Parameters

Send parameters as `application/x-www-form-urlencoded` form fields in the request body.

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `key` | string | yes |  | Your API key, repeated as a form field. Kept for existing integrations; the `Authorization: Bearer` header is the supported way to authenticate. |
| `text` | string | yes |  | The text to translate. |
| `from` | string | no | `en` | Source language code. |
| `to` | string | yes |  | Target language code. |

## Example request

```bash
curl -X POST "https://api.zactonz.com/translator/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "key=YOUR_API_KEY" \
  --data-urlencode "text=Good morning, how are you?" \
  --data-urlencode "from=en" \
  --data-urlencode "to=es"
```

## Response

The translation.

| Field | Type | Description |
|---|---|---|
| `status` | integer | `200` on success, `400` on any failure. |
| `data` | object |  |
| `data.from` | string | Source language code that was used. |
| `data.to` | string | Target language code. |
| `data.text` | string | The translated text. |
| `errors` | array of string | Present on failure only. Human-readable reasons. |

```json
{
    "status": 200,
    "data": {
        "from": "en",
        "to": "es",
        "text": "Buenos días, ¿cómo estás?"
    }
}
```

## Status codes

The outcome is reported in the JSON `status` field. General rules: https://developers.zactonz.com/apis/errors.md

| status | Meaning | Description |
|---|---|---|
| `200` | OK | Translated. |
| `400` | Rejected | Invalid key, a missing `text` or `to`, an unsupported language code, or the translation engine being unavailable. `errors` lists the reason. |

## Notes

Language codes are two-letter ISO 639-1 codes. Supported: `en` `vi` `sq` `ar` `az` `bn` `bg` `ca` `zh` `zt` `cs` `da` `nl` `eo` `et` `fi` `fr` `de` `el` `he` `hi` `hu` `id` `ga` `it` `ja` `ko` `lv` `lt` `ms` `nb` `fa` `pl` `pt` `ro` `ru` `sk` `sl` `es` `sv` `tl` `th` `tr` `uk`. `zt` is Traditional Chinese.

On failure the reply has status `400` and an `errors` array instead of `data`.
