# Translation API with flat per-call pricing

> Flat per-call pricing. Send a tweet or a contract for the same credit.

- Endpoint: `POST https://scrapenest.dev/v1/translate`
- Price: 1 credit
- Category: Utilities
- Reference: https://scrapenest.dev/docs#ep-translate
- Web page: https://scrapenest.dev/catalog/translate
- Updated: 2026-11-04

Translate UGC, support tickets, or scraped pages into any of 28 languages. We don't charge per character: one call, one credit, whether you send a tweet or a contract.

## The hard part

Per-character pricing is fine until your users paste a contract or a long thread, and suddenly one record costs more than a hundred others combined. A flat per-call price means your translation line item scales with usage, not with how long the strings are.

## Translation API: what you get

- 28 source/target languages, `source="auto"` for detection.
- Flat 1 credit per call. Predictable cost on big texts.
- Returns detected source language alongside the translation.
- Each call takes up to 5,000 characters of `text`; split longer documents across calls.
- Region and script tags are normalised for you: `pt-BR`, `es-419`, `zh-TW` and `en_US` all work.

## Translation API use cases

- **Translate scraped pages**: Turn foreign-language text from the Web Scraping API into English before it reaches your pipeline.
- **Support tickets and reviews**: Translate user-generated text at a predictable cost, with `detected_source` telling you what language came in.
- **Short strings at the same price**: Product titles, UI copy and notifications cost the same flat credit as a long paragraph.

## Translation API quickstart

Install an SDK with `pip install scrapenest` or `npm install scrapenest`, or call the HTTP API directly with your key in the `Authorization: Bearer` header. No key yet? Sign up free at https://scrapenest.dev/signup, verify your email, then create a key in your dashboard.

### Python SDK

```python
import os
from scrapenest import Client

client = Client(os.environ["SCRAPENEST_API_KEY"])
res = client.translate("Estoy buscando un buen restaurante de tapas cerca de la Plaza Mayor", "en")
print(res.translated)
print(res.detected_source, "->", res.target, res.credits_charged, "credit")
```

### Node SDK

```javascript
import { ScrapeNest } from "scrapenest";

const client = new ScrapeNest({ apiKey: process.env.SCRAPENEST_API_KEY });
const res = await client.translate({
  text: "Estoy buscando un buen restaurante de tapas cerca de la Plaza Mayor",
  target: "en",
});
console.log(res.translated, res.detected_source, res.credits_charged);
```

### curl

```bash
curl -X POST https://scrapenest.dev/v1/translate \
  -H "Authorization: Bearer sn_••••" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Hello, world", "target": "ja" }'
```

### Python (httpx)

```python
import httpx

r = httpx.post(
    "https://scrapenest.dev/v1/translate",
    headers={"Authorization": "Bearer sn_••••"},
    json={"text": "Hello, world", "target": "ja"},
)
print(r.json()["translated"])
```

### JavaScript (fetch)

```javascript
const r = await fetch("https://scrapenest.dev/v1/translate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sn_••••",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "Hello, world", target: "ja" }),
});
const { translated } = await r.json();
```

### Go

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]string{
        "text": "Hello, world", "target": "ja",
    })
    req, _ := http.NewRequest("POST",
        "https://scrapenest.dev/v1/translate", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer sn_••••")
    req.Header.Set("Content-Type", "application/json")
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    var out struct{ Translated string }
    json.NewDecoder(resp.Body).Decode(&out)
    fmt.Println(out.Translated)
}
```

## Translation API request and response

### Request body

```json
{
  "text": "Estoy buscando un buen restaurante de tapas cerca de la Plaza Mayor",
  "target": "en",
  "source": "auto"
}
```

### Response

```json
{
  "translated": "I am looking for a good tapas restaurant near Plaza Mayor",
  "detected_source": "es",
  "target": "en",
  "credits_charged": 1
}
```

Fields with no value are left out of the JSON rather than sent as `null`, so read optional fields defensively.

## Translation API pricing

1 credit per call regardless of length. No per-character or per-word fee. Each call takes up to 5,000 characters of text, and a call whose source already equals the target returns the text unchanged for 0 credits.

## Translation API limits

- `text`: 1 to 5,000 characters per call.
- Supported codes: ar, cs, da, de, el, en, es, fi, fr, he, hi, hu, id, it, ja, ko, nb, nl, pl, pt, ro, ru, sv, th, tr, uk, vi, zh-hans and zh-hant.
- Region and script subtags are normalised (`pt-BR` becomes `pt`, `zh-TW` becomes `zh-hant`), and underscore forms like `en_US` work.
- Translations are never cached: every call translates fresh.

## Translation API error codes

| HTTP | Code | Meaning |
| --- | --- | --- |
| 422 | `validation_error` | An unsupported `target` or `source`, or `text` over 5,000 characters; `details[]` names the field. |
| 400 | `unsupported_detected_source` | Auto-detection found a language that isn't supported. Pass `source` explicitly. |
| 400 | `translation_rejected` | The language pair or input was rejected. Not billed. |
| 503 | `upstream_failed` | Translation is temporarily unavailable. Not billed; retry. |

Every endpoint can also return `401 unauthorized` (missing or wrong key), `402 insufficient_credits` (balance used up), `403 email_not_verified` (an email signup must verify its address before its key works) and `429 rate_limited` or `concurrency_limit_exceeded`. All errors share one JSON envelope; see the [error reference](https://scrapenest.dev/docs#errors).

## Translation API FAQ

### How much does translation cost?

1 credit per call whatever the length, up to the 5,000-character limit per call. A call whose source already equals the target returns the text unchanged and bills 0.

### Which languages are supported?

28 languages: Arabic, Czech, Danish, German, Greek, English, Spanish, Finnish, French, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Norwegian Bokmål, Dutch, Polish, Portuguese, Romanian, Russian, Swedish, Thai, Turkish, Ukrainian, Vietnamese and Chinese, in both Simplified (`zh-hans`) and Traditional (`zh-hant`) script.

### Does it detect the source language?

Yes. `source` defaults to `auto`, and `detected_source` in the response reports what came in. If the detected language isn't supported, the call returns a 400 `unsupported_detected_source` instead of a wrong translation.

### How long can the text be?

Up to 5,000 characters per call. For longer documents, split on paragraph boundaries and send each part as its own call; each part bills 1 credit.

## Related endpoints

- [Web scraping API for any URL](https://scrapenest.dev/catalog/scrape-url.md): `POST /v1/scrape/url`. Point us at a page. We get past the wall and hand back the rendered HTML and clean text.
- [YouTube & podcast transcript API](https://scrapenest.dev/catalog/audio-transcript.md): `POST /v1/audio/transcript`. Timestamped transcript of any audio URL: YouTube, X Spaces, SoundCloud, Apple Podcasts, direct MP3.
- [SERP API for multi-engine web search](https://scrapenest.dev/catalog/search.md): `POST /v1/search`. Multi-engine web search aggregated and re-ranked into one feed.

## Get 1,000 free credits

Every account starts on the Free plan: 1,000 credits a month, no card. Verify your email, then mint an API key and make this call. Sign up at https://scrapenest.dev/signup.
