Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/translate

Authentication

HeaderRequiredValue
X-API-KeyYesYour API key (bun_...)
Content-TypeYesapplication/json

Overview

Translate text between 100+ languages with a single API call. Bunny’s Translation API accepts source and target language codes and returns the translated text along with a confidence score.

Use cases

  • Build multilingual UIs without a dedicated i18n backend
  • Translate user-generated content in real time
  • Power customer support tools with automatic message translation
  • Add language detection to content pipelines

Details

Uses ISO 639-1 language codes (e.g. en, pt, es, fr, de). The confidence field (0–1) reflects translation quality. Long texts are supported but response time scales with length.

Request body

FieldTypeRequiredDescription
textstringYesText to translate (max 5,000 characters)
tostringYesTarget language code (ISO 639-1, e.g. pt)
fromstringNoSource language code (ISO 639-1, e.g. en). Defaults to autodetect

Example

{
  "text": "Hello world",
  "to": "pt"
}

Response

200 OK

FieldTypeDescription
originalstringThe original text that was submitted
translatedstringTranslated text
fromstringSource language code used (may be autodetect if not specified)
tostringTarget language code
confidencenumber|nullTranslation confidence score (0–1)
Example
{
  "original": "Hello world",
  "translated": "Olá mundo",
  "from": "autodetect",
  "to": "pt",
  "confidence": 0.82
}

401 Unauthorized

{
  "detail": "Missing API key. Include X-API-Key header."
}

402 Payment Required

{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}

422 Unprocessable Entity

Invalid language code or empty text.
{
  "detail": "Unsupported language code"
}

429 Too Many Requests

{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}

cURL example

curl -X POST https://api.bunny.build/api/v1/translate \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello world", "to": "pt"}'