NLLB-200 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": "<p>Hello world</p>",
"source": "eng_Latn",
"target": "srp_Cyrl"
}
{
"success": true,
"translated": "Zdravo svete",
"source": "eng_Latn",
"target": "srp_Cyrl"
}
Check if the translation service is running.
{
"success": true,
"status": "Node API running",
"pythonService": {
"status": "translator running"
}
}
curl -X POST https://translate.prodajemauto.rs/translate \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"text": "<p>Hello world</p>",
"source": "eng_Latn",
"target": "srp_Cyrl"
}'
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: '<p>Hello world</p>',
source: 'eng_Latn',
target: 'srp_Cyrl'
})
});
const data = await response.json();
console.log(data.translated);
import axios from 'axios';
const { data } = await axios.post(
'https://translate.prodajemauto.rs/translate',
{
text: '<p>Hello world</p>',
source: 'eng_Latn',
target: 'srp_Cyrl'
},
{
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
}
}
);
console.log(data.translated);
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) {
try {
const { data } = await axios.post(API_URL, {
text,
source: sourceLang,
target: targetLang
}, {
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(
'<p>Hello world</p>',
'eng_Latn',
'srp_Cyrl'
);
import requests
url = 'https://translate.prodajemauto.rs/translate'
headers = {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
}
payload = {
'text': '<p>Hello world</p>',
'source': 'eng_Latn',
'target': 'srp_Cyrl'
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
if data['success']:
print(data['translated'])
The API supports 204 languages from the NLLB-200 model. Language codes follow the format:
language_Script
Examples:
eng_Latn - English (Latin script)srp_Cyrl - Serbian (Cyrillic script)deu_Latn - German (Latin script)fra_Latn - French (Latin script)spa_Latn - Spanish (Latin script)400 - Missing required fields (text, source, target)401 - Unauthorized (invalid or missing API key)503 - Translation service unavailable500 - Internal server error