Multi-Tier Translation Service
https://translate.prodajemauto.rs
All requests must include an api-key header for authentication.
All API requests require an API key in the request header:
api-key: YOUR_ACCESS_TOKEN_SECRET
Translate text from one language to another.
{
"text": "Dobar dan, kako ste?",
"source": "rs",
"target": "en",
"format": "text"
}
text (string, required) - Text to translate (max 50,000 characters)source (string, required) - Source language code (e.g., "rs", "en")target (string, required) - Target language code (e.g., "en", "de")format (string, optional) - Format type: "text" (default) or "html" (preserves HTML structure)The format parameter determines how the text is processed:
"text" (default) - Plain text translation"html" - Preserves HTML structure (<p>, <br> tags) during translationformat: "html", the API strips HTML tags before translation and restores paragraph/line break structure afterward. This ensures clean translations while maintaining document formatting.
{
"success": true,
"translated": "Good day, how are you?",
"source": "rs",
"target": "en",
"dict_hits": 2,
"fallback_hits": 1,
"total_phrases": 3,
"services_used": {
"dictionary": 2,
"lara": 1,
"libretranslate": 0,
"nllb": 0,
"error": 0
},
"tokens_used": 5,
"characters_translated": 19,
"translation_time_ms": 554.23
}
translated - Translated textdict_hits - Phrases served from dictionary cachefallback_hits - Phrases translated by fallback servicesservices_used - Breakdown by service type (dictionary, lara, libretranslate, nllb)tokens_used - Estimated tokens (for Lara API billing)characters_translated - Actual characters sent to paid APIstranslation_time_ms - Translation time in millisecondschunks (optional) - Number of chunks if text was splitCheck if the translation service is running.
{
"success": true,
"status": "Node API running",
"pythonService": {
"name": "Multi-Tier Translation API",
"version": "2.0.0"
}
}
curl -X POST https://translate.prodajemauto.rs/translate \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"text": "Dobar dan, kako ste?",
"source": "rs",
"target": "en",
"format": "text"
}'
const response = await fetch('https://translate.prodajemauto.rs/translate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'Dobar dan, kako ste?',
source: 'rs',
target: 'en',
format: 'text' // or 'html' for HTML content
})
});
const data = await response.json();
console.log(data.translated); // "Good day, how are you?"
import axios from 'axios';
const { data } = await axios.post(
'https://translate.prodajemauto.rs/translate',
{
text: 'Dobar dan, kako ste?',
source: 'rs',
target: 'en',
format: 'text' // or 'html' for HTML content
},
{
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
}
}
);
console.log(data.translated); // "Good day, how are you?"
import axios from 'axios';
const API_KEY = process.env.TRANSLATE_API_KEY;
const API_URL = 'https://translate.prodajemauto.rs/translate';
async function translateText(text, sourceLang, targetLang, format = 'text') {
try {
const { data } = await axios.post(API_URL, {
text,
source: sourceLang,
target: targetLang,
format // 'text' or 'html'
}, {
headers: {
'Content-Type': 'application/json',
'api-key': API_KEY
},
timeout: 30000
});
return data.success ? data.translated : text;
} catch (error) {
console.error('Translation failed:', error.message);
return text;
}
}
// Usage
const translated = await translateText(
'Dobar dan, kako ste?',
'rs',
'en'
);
console.log(translated); // "Good day, how are you?"
import requests
url = 'https://translate.prodajemauto.rs/translate'
headers = {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
}
payload = {
'text': 'Dobar dan, kako ste?',
'source': 'rs',
'target': 'en',
'format': 'text' # or 'html' for HTML content
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
if data['success']:
print(data['translated']) # "Good day, how are you?"
The API uses simple 2-character ISO 639-1 codes for easy integration:
rs - Serbian (also accepts sr)hr - Croatianbs - Bosniansl - Slovenianmk - Macedoniansq - Albanianbg - Bulgarianro - Romanianen - Englishde - Germanfr - Frenchit - Italianes - Spanishpt - Portuguesenl - Dutchca - Catalansv - Swedishda - Danishno - Norwegianis - Icelandicfi - Finnishru - Russianuk - Ukrainianbe - Belarusianpl - Polishcs - Czechsk - Slovakhu - Hungarianlt - Lithuanianlv - Latvianet - Estonianel - Greektr - Turkishzh - Chineseja - Japaneseko - Koreanar - Arabiche - Hebrewth - Thaivi - Vietnameseid - Indonesianms - Malaytl - Tagaloghi - Hindibn - Bengaliur - Urdufa - Persianka - Georgianhy - Armenianaz - Azerbaijanikk - Kazakhuz - Uzbekky - Kyrgyzchunks indicates number of chunks processed400 - Invalid request (missing fields, invalid language codes, text too long)401 - Unauthorized (invalid or missing API key)503 - Translation service unavailable500 - Internal server errorsource must be a 2-3 character language code - You sent full language name instead of codesource 'xyz' is not supported - Invalid or unsupported language codetext exceeds maximum length - Text over 50,000 characters