title: Quick Start description: Get started with TranslatePlus API in minutes
Quick Start
Get up and running with TranslatePlus API in just a few minutes. This guide will walk you through making your first translation request and show you common use cases.
Prerequisites
- A TranslatePlus account (Sign up if you don't have one)
- An API key from your Dashboard
- Basic knowledge of HTTP requests
Step 1: Get Your API Key
- Sign up for a TranslatePlus account (or log in if you already have one)
- Navigate to the API Keys section in your dashboard
- Generate a new API key or copy your existing one
- Keep your API key secure - you'll need it for all API requests
Tip: Store your API key in an environment variable for security. Never commit it to version control.
Step 2: Make Your First Translation Request
Let's translate "Hello, world!" from English to French. Choose your preferred language:
curl https://api.translateplus.io/v2/translate \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"source": "en",
"target": "fr"
}'
import requests
url = "https://api.translateplus.io/v2/translate"
headers = {
"X-API-KEY": "your_api_key",
"Content-Type": "application/json"
}
data = {
"text": "Hello, world!",
"source": "en",
"target": "fr"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(f"Translation: {result['translations']['translation']}")
# Output: Translation: Bonjour le monde!
fetch('https://api.translateplus.io/v2/translate', {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hello, world!',
source: 'en',
target: 'fr'
})
})
.then(response => response.json())
.then(data => {
console.log('Translation:', data.translations.translation);
// Output: Translation: Bonjour le monde!
})
.catch(error => console.error('Error:', error));
const https = require('https');
const data = JSON.stringify({
text: 'Hello, world!',
source: 'en',
target: 'fr'
});
const options = {
hostname: new URL('https://api.translateplus.io').hostname,
path: '/v2/translate',
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
const result = JSON.parse(responseData);
console.log('Translation:', result.translations.translation);
// Output: Translation: Bonjour le monde!
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.write(data);
req.end();
<?php
$url = 'https://api.translateplus.io/v2/translate';
$apiKey = 'your_api_key';
$data = [
'text' => 'Hello, world!',
'source' => 'en',
'target' => 'fr'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-KEY: ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$result = json_decode($response, true);
echo 'Translation: ' . $result['translations']['translation'] . PHP_EOL;
// Output: Translation: Bonjour le monde!
} else {
echo 'Error: ' . $response;
}
Step 3: Understanding the Response
A successful response looks like this:
{
"translations": {
"text": "Hello, world!",
"translation": "Bonjour le monde!",
"source": "en",
"target": "fr"
},
"details": {}
}
Response Fields:
translations.text- The original text you senttranslations.translation- The translated texttranslations.source- Detected or specified source languagetranslations.target- Target languagedetails- Additional metadata (empty for basic requests)
Step 4: Common Use Cases
Auto-Detect Source Language
You can let the API detect the source language automatically:
curl https://api.translateplus.io/v2/translate \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"text": "Hola, mundo!",
"source": "auto",
"target": "en"
}'
import requests
response = requests.post(
"https://api.translateplus.io/v2/translate",
headers={"X-API-KEY": "your_api_key", "Content-Type": "application/json"},
json={
"text": "Hola, mundo!",
"source": "auto",
"target": "en"
}
)
result = response.json()
print(f"Detected: {result['translations']['source']}")
print(f"Translation: {result['translations']['translation']}")
fetch('https://api.translateplus.io/v2/translate', {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hola, mundo!',
source: 'auto',
target: 'en'
})
})
.then(response => response.json())
.then(data => {
console.log('Detected:', data.translations.source);
console.log('Translation:', data.translations.translation);
});
Batch Translation
Translate multiple texts in a single request:
curl https://api.translateplus.io/v2/translate/batch \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"Hello, world!",
"How are you?",
"Thank you very much"
],
"source": "en",
"target": "fr"
}'
import requests
response = requests.post(
"https://api.translateplus.io/v2/translate/batch",
headers={"X-API-KEY": "your_api_key", "Content-Type": "application/json"},
json={
"texts": [
"Hello, world!",
"How are you?",
"Thank you very much"
],
"source": "en",
"target": "fr"
}
)
result = response.json()
for translation in result['translations']:
print(f"{translation['text']} → {translation['translation']}")
fetch('https://api.translateplus.io/v2/translate/batch', {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
texts: [
'Hello, world!',
'How are you?',
'Thank you very much'
],
source: 'en',
target: 'fr'
})
})
.then(response => response.json())
.then(data => {
data.translations.forEach(t => {
console.log(`${t.text} → ${t.translation}`);
});
});
Detect Language
Detect the language of a text:
curl https://api.translateplus.io/v2/detect_language \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"text": "Bonjour le monde!"
}'
import requests
response = requests.post(
"https://api.translateplus.io/v2/detect_language",
headers={"X-API-KEY": "your_api_key", "Content-Type": "application/json"},
json={"text": "Bonjour le monde!"}
)
result = response.json()
print(f"Detected language: {result['language']}")
print(f"Confidence: {result['confidence']}")
fetch('https://api.translateplus.io/v2/detect_language', {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Bonjour le monde!'
})
})
.then(response => response.json())
.then(data => {
console.log('Detected language:', data.language);
console.log('Confidence:', data.confidence);
});
Step 5: Error Handling
Always handle errors in your code. Common error responses:
401 Unauthorized - Invalid API key:
{
"detail": "API key is required. Please provide X-API-KEY header."
}
400 Bad Request - Invalid parameters:
{
"detail": "Invalid source language code: 'invalid'"
}
402 Payment Required - Insufficient credits:
{
"detail": "Insufficient credits. You have 0 credit(s) remaining."
}
429 Too Many Requests - Rate limit exceeded:
{
"detail": "Rate limit exceeded. Please try again later."
}
import requests
try:
response = requests.post(
"https://api.translateplus.io/v2/translate",
headers={"X-API-KEY": "your_api_key", "Content-Type": "application/json"},
json={"text": "Hello", "source": "en", "target": "fr"}
)
response.raise_for_status() # Raises exception for 4xx/5xx
result = response.json()
print(f"Translation: {result['translations']['translation']}")
except requests.exceptions.HTTPError as e:
error_data = e.response.json() if e.response else {}
print(f"Error {e.response.status_code}: {error_data.get('detail', 'Unknown error')}")
except Exception as e:
print(f"Error: {e}")
async function translateText(text, source, target) {
try {
const response = await fetch('https://api.translateplus.io/v2/translate', {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text, source, target })
});
if (!response.ok) {
const error = await response.json();
throw new Error(`Error ${response.status}: ${error.detail || 'Unknown error'}`);
}
const data = await response.json();
return data.translations.translation;
} catch (error) {
console.error('Translation error:', error.message);
throw error;
}
}
Next Steps
Now that you've made your first request, explore more:
- Authentication Guide - Learn about API keys, security, and best practices
- API Reference - Complete endpoint documentation
- Code Examples - More examples in different languages
- Error Handling - Comprehensive error handling guide
- Supported Languages - List of all supported languages
- Rate Limits - Understand API rate limits and quotas