Language Translator API
Category: language
Translate plain text with Google Cloud Translation. Requires active Pro and 1 credit per 500 input characters, rounded up; maximum 5,000 characters. MCP clients can call translate_text at /api/mcp with the same API key and billing rules.
Use This ToolEndpoint
https://anythingtext.com/api/tools/language-translate
API Key
This API requires an API key. No login or OAuth is needed. Generate your key from the API Keys section in your dashboard settings.
Include the X-API-Key header in all API requests:
Rate Limiting
API requests are limited to 60 requests per minute per user. If you exceed this limit, the API returns a 429 Too Many Requests response.
Every response includes rate limit headers:
When rate limited, the response body contains:
{ "error": "Rate limit exceeded. Maximum 60 requests per minute.", "retryAfter": 42, "limit": 60 }
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
text
|
String | Required |
Plain text to translate, up to 5,000 Unicode characters
Example: Hello world
|
targetLanguage
|
String | Required |
Supported target language code; GET /api/tools/language-translate/languages lists supported codes
Example: es
|
sourceLanguage
|
String | Optional |
Supported source language code or auto for automatic detection
Example: auto
|
Response
Translated text and server-calculated credit usage. Failed translations return reserved credits.
{
"translatedText": "Hola mundo",
"targetLanguage": "es",
"characters": 11,
"creditsUsed": 1,
"creditsRemaining": 99
}
Error Responses
| Status | Description | Body |
|---|---|---|
401 |
Not authenticated | {"error": "Please log in..."} |
400 |
Bad request / Missing required params | {"error": "... is required"} |
500 |
Internal server error | {"error": "Failed to ..."} |
cURL Example
curl -X POST https://anythingtext.com/api/tools/language-translate -H "Content-Type: application/json" -H "X-API-Key: atk_your_key_here" -d '{"text":"Hello world","targetLanguage":"es","sourceLanguage":"auto"}'
Code Samples
const response = await fetch('https://anythingtext.com/api/tools/language-translate', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': 'atk_your_key_here' }, body: JSON.stringify({ text: 'Hello world', targetLanguage: 'es', sourceLanguage: 'auto' }) });
console.log(await response.json());