API Documentation
Welcome to the FlexiTranslate API documentation. Our API provides powerful, context-aware translation capabilities for your applications with enterprise-grade reliability.
Introduction
FlexiTranslate API offers blazing-fast, neural machine translation across 140+ languages. With our simple RESTful interface, you can integrate translation capabilities into any application in minutes.
Sign up for a free account and get 10,000 monthly requests at no cost. No credit card required.
Base URL
https://api.flexitranslate.org/v1
Quick Start
Here's a simple example to get you started with translation:
curl -X POST https://api.flexitranslate.org/v1/translate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"target_lang": "es"
}'
Authentication
All API requests require authentication using an API key. You can obtain your API key from the dashboard after signing up.
Never expose your API key in client-side code. Always use server-side integration for production applications.
Authentication Header
Include your API key in the Authorization header:
Authorization: Bearer ft_live_xxxxxxxxxxxxx
Rate Limits
Rate limits vary by plan. Free tier: 60 requests per minute.
Translate Text
Translates text from one language to another using our advanced neural machine translation engine.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to translate (max 5000 characters) |
target_lang | string | Yes | Target language code (e.g., "es", "fr", "ja") |
source_lang | string | No | Source language code (auto-detected if omitted) |
formality | string | No | "formal" or "informal" (default: "formal") |
Response
{
"success": true,
"data": {
"translated_text": "¡Hola, mundo!",
"detected_source_lang": "en",
"target_lang": "es",
"character_count": 13,
"usage": {
"remaining_requests": 9987,
"remaining_chars": 987654
}
}
}
curl -X POST https://api.flexitranslate.org/v1/translate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Welcome to FlexiTranslate!",
"target_lang": "zh"
}'
const response = await fetch('https://api.flexitranslate.org/v1/translate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Welcome to FlexiTranslate!',
target_lang: 'zh'
})
});
const data = await response.json();
console.log(data.data.translated_text);
import requests
url = "https://api.flexitranslate.org/v1/translate"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"text": "Welcome to FlexiTranslate!",
"target_lang": "zh"
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print(result["data"]["translated_text"])
Detect Language
Detects the language of the provided text.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to analyze |
Response
{
"success": true,
"data": {
"language": "English",
"language_code": "en",
"confidence": 0.98
}
}
Supported Languages
FlexiTranslate supports over 140 languages. Here are the most commonly used ones:
| Language | Code |
|---|---|
| English | en |
| Spanish | es |
| French | fr |
| German | de |
| Chinese (Simplified) | zh |
| Japanese | ja |
| Korean | ko |
| Arabic | ar |
| Russian | ru |
| Portuguese | pt |
/v1/languagesWebsite Widget
Add instant translation to your website with our easy-to-use widget. No coding required!
Our widget automatically detects your website's language and offers translation to your visitors with a single click.
Quick Installation
Copy and paste this code snippet just before the closing </body> tag of your website:
<script src="https://flexitranslateapi-dweeikl6jq-uc.a.run.app/api/v1/widget.js?key=YOUR_API_KEY" defer></script>
Advanced Configuration
You can customize the widget behavior with additional parameters:
| Parameter | Description | Example |
|---|---|---|
position | Widget position on screen | bottom-right, bottom-left |
theme | Color theme | light, dark, auto |
languages | Comma-separated language codes | en,es,fr,de,zh |
auto_detect | Auto-detect visitor language | true or false |
Customized Example
<script src="https://flexitranslateapi-dweeikl6jq-uc.a.run.app/api/v1/widget.js?key=YOUR_API_KEY&position=bottom-left&theme=dark&languages=en,es,fr,de,it,pt,zh,ja,ko&auto_detect=true" defer></script>
window.FlexiTranslateWidget = {
key: 'YOUR_API_KEY',
position: 'bottom-right',
theme: 'auto',
languages: ['en', 'es', 'fr', 'de'],
onTranslate: function(lang) {
console.log('Translated to:', lang);
}
};
Widget Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
position | string | bottom-right | Widget position on the page |
theme | string | light | Color scheme (light, dark, auto) |
languages | array | ['en','es','fr','de','zh','ja','ar'] | Available languages for translation |
auto_detect | boolean | true | Automatically detect visitor's language |
show_powered_by | boolean | true | Show "Powered by FlexiTranslate" |
animation | string | slide | Animation style (slide, fade, none) |
primary_color | string | #2b5f6b | Custom primary color (hex) |
Live Examples
YOUR_API_KEY with your actual API key.
<!DOCTYPE html>
<html>
<head>
<title>My Translated Website</title>
<style>
body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
h1 { color: #2b5f6b; }
</style>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This content will be automatically translated when visitors use the widget.</p>
<script src="https://flexitranslateapi-dweeikl6jq-uc.a.run.app/api/v1/widget.js?key=YOUR_API_KEY" defer></script>
</body>
</html>
Error Handling
The API uses conventional HTTP response codes to indicate success or failure of requests.
| Code | Meaning | Description |
|---|---|---|
200 | Success | Request was successful |
400 | Bad Request | Invalid parameters or missing required fields |
401 | Unauthorized | Invalid or missing API key |
429 | Rate Limited | Too many requests, slow down |
500 | Server Error | Internal server error, try again later |
Error Response Format
{
"success": false,
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please wait before making more requests.",
"retry_after": 60
}
}
JavaScript SDK
Install our official JavaScript SDK for seamless integration:
npm install flexitranslate-sdk
import FlexiTranslate from 'flexitranslate-sdk';
const ft = new FlexiTranslate({
apiKey: 'YOUR_API_KEY'
});
// Translate text
const result = await ft.translate({
text: 'Hello, world!',
targetLang: 'es'
});
console.log(result.translatedText); // ¡Hola, mundo!
Python SDK
pip install flexitranslate
from flexitranslate import Client
client = Client(api_key='YOUR_API_KEY')
# Translate text
result = client.translate(
text='Hello, world!',
target_lang='fr'
)
print(result.translated_text) # Bonjour, le monde !
cURL Examples
Batch Translation
curl -X POST https://api.flexitranslate.org/v1/translate/batch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"texts": ["Hello", "Good morning", "Good night"],
"target_lang": "es"
}'
Get Usage Statistics
curl -X GET https://api.flexitranslate.org/v1/usage \
-H "Authorization: Bearer YOUR_API_KEY"
Usage Statistics
Monitor your API usage with the stats endpoint:
Response
{
"success": true,
"data": {
"current_month": {
"requests": 1234,
"characters": 45678,
"limit": 10000
},
"lifetime": {
"total_requests": 56789,
"total_characters": 1234567
},
"rate_limit": {
"remaining": 57,
"reset_in": 45
}
}
}