| # Sema Translation API - Complete Capabilities | |
| ## π **What Our API Can Do** | |
| Your Sema Translation API is now a comprehensive, enterprise-grade translation service with extensive language support and developer-friendly features. | |
| ## π **Core Translation Features** | |
| ### **1. Text Translation** | |
| - **200+ Languages**: Full FLORES-200 language support | |
| - **Automatic Language Detection**: Smart source language detection | |
| - **High-Quality Translation**: CTranslate2 optimized neural translation | |
| - **Bidirectional Translation**: Translate between any supported language pair | |
| - **Character Limit**: Up to 5000 characters per request | |
| - **Performance**: ~0.2-0.5 seconds inference time | |
| ### **2. Language Detection** | |
| - **Automatic Detection**: Identifies source language when not specified | |
| - **High Accuracy**: FastText-based language identification | |
| - **200+ Language Support**: Detects all supported languages | |
| - **Confidence Scoring**: Internal confidence metrics | |
| ## π£οΈ **Language Support System** | |
| ### **Complete Language Information** | |
| Your API now knows everything about its supported languages: | |
| #### **Language Metadata** | |
| - **English Names**: "Swahili", "French", "Chinese" | |
| - **Native Names**: "Kiswahili", "FranΓ§ais", "δΈζ" | |
| - **Geographic Regions**: Africa, Europe, Asia, Middle East, Americas | |
| - **Writing Scripts**: Latin, Arabic, Cyrillic, Han, Devanagari, etc. | |
| - **Language Codes**: FLORES-200 standard codes | |
| #### **Regional Coverage** | |
| - **African Languages** (25+): Swahili, Hausa, Yoruba, Kikuyu, Zulu, Xhosa, Amharic, Somali | |
| - **European Languages** (40+): English, French, German, Spanish, Italian, Russian, Polish | |
| - **Asian Languages** (80+): Chinese, Japanese, Korean, Hindi, Bengali, Thai, Vietnamese | |
| - **Middle Eastern** (15+): Arabic, Hebrew, Persian, Turkish | |
| - **Americas** (30+): Spanish, Portuguese, English, French, Indigenous languages | |
| ## π‘ **API Endpoints** | |
| ### **Translation Endpoints** | |
| ``` | |
| POST /translate # Main translation endpoint | |
| POST /api/v1/translate # Versioned endpoint | |
| ``` | |
| ### **Language Information Endpoints** | |
| ``` | |
| GET /languages # All supported languages | |
| GET /languages/popular # Most commonly used languages | |
| GET /languages/african # African languages specifically | |
| GET /languages/region/{region} # Languages by geographic region | |
| GET /languages/search?q={query} # Search languages by name/code | |
| GET /languages/stats # Language statistics and coverage | |
| GET /languages/{code} # Specific language information | |
| ``` | |
| ### **Monitoring & Health** | |
| ``` | |
| GET / # Basic health check | |
| GET /health # Detailed health monitoring | |
| GET /metrics # Prometheus metrics | |
| GET /docs # Interactive API documentation | |
| GET /redoc # Alternative documentation | |
| ``` | |
| ## π― **Developer Experience Features** | |
| ### **1. Language Discovery** | |
| - **Complete Language List**: Get all 200+ supported languages | |
| - **Popular Languages**: Quick access to commonly used languages | |
| - **Regional Filtering**: Filter by geographic region | |
| - **Search Functionality**: Find languages by name, native name, or code | |
| - **Language Validation**: Check if a language code is supported | |
| ### **2. Frontend Integration Ready** | |
| ```javascript | |
| // Get all languages for dropdown | |
| const languages = await fetch('/languages').then(r => r.json()); | |
| // Get popular languages for quick selection | |
| const popular = await fetch('/languages/popular').then(r => r.json()); | |
| // Search languages for autocomplete | |
| const results = await fetch('/languages/search?q=Swah').then(r => r.json()); | |
| // Validate language code | |
| const langInfo = await fetch('/languages/swh_Latn').then(r => r.json()); | |
| ``` | |
| ### **3. Rich Metadata** | |
| Each language includes: | |
| ```json | |
| { | |
| "swh_Latn": { | |
| "name": "Swahili", | |
| "native_name": "Kiswahili", | |
| "region": "Africa", | |
| "script": "Latin" | |
| } | |
| } | |
| ``` | |
| ## π **Analytics & Monitoring** | |
| ### **Usage Tracking** | |
| - **Request Counting**: Total API requests by endpoint | |
| - **Translation Metrics**: Translations by language pair | |
| - **Character Counting**: Total characters translated | |
| - **Performance Metrics**: Request duration and inference time | |
| - **Error Tracking**: Error rates by type | |
| ### **Language Statistics** | |
| - **Coverage Stats**: Languages by region and script | |
| - **Usage Patterns**: Most translated language pairs | |
| - **Performance Data**: Translation speed by language | |
| - **Regional Analytics**: Usage by geographic region | |
| ## π **Enterprise Features** | |
| ### **Rate Limiting** | |
| - **60 requests/minute** per IP address | |
| - **5000 characters** maximum per request | |
| - **Graceful degradation** with clear error messages | |
| ### **Request Tracking** | |
| - **Unique Request IDs**: For debugging and support | |
| - **Structured Logging**: JSON logs for analysis | |
| - **Request/Response Logging**: Complete audit trail | |
| - **Performance Monitoring**: Response time tracking | |
| ### **Error Handling** | |
| - **Comprehensive Validation**: Input validation with clear messages | |
| - **HTTP Status Codes**: Standard REST API responses | |
| - **Error Details**: Specific error information | |
| - **Graceful Failures**: Service continues despite individual failures | |
| ## π¨ **Frontend Integration Examples** | |
| ### **Language Selector Component** | |
| ```javascript | |
| // React component example | |
| function LanguageSelector({ onSelect }) { | |
| const [languages, setLanguages] = useState([]); | |
| const [popular, setPopular] = useState([]); | |
| useEffect(() => { | |
| // Load popular languages first | |
| fetch('/languages/popular') | |
| .then(r => r.json()) | |
| .then(data => setPopular(Object.entries(data.languages))); | |
| // Load all languages for search | |
| fetch('/languages') | |
| .then(r => r.json()) | |
| .then(data => setLanguages(Object.entries(data.languages))); | |
| }, []); | |
| return ( | |
| <select onChange={e => onSelect(e.target.value)}> | |
| <optgroup label="Popular Languages"> | |
| {popular.map(([code, info]) => ( | |
| <option key={code} value={code}> | |
| {info.name} ({info.native_name}) | |
| </option> | |
| ))} | |
| </optgroup> | |
| <optgroup label="All Languages"> | |
| {languages.map(([code, info]) => ( | |
| <option key={code} value={code}> | |
| {info.name} - {info.region} | |
| </option> | |
| ))} | |
| </optgroup> | |
| </select> | |
| ); | |
| } | |
| ``` | |
| ### **Translation Interface** | |
| ```javascript | |
| // Translation function with language validation | |
| async function translateText(text, targetLang, sourceLang = null) { | |
| // Validate target language | |
| const langInfo = await fetch(`/languages/${targetLang}`); | |
| if (!langInfo.ok) { | |
| throw new Error(`Unsupported language: ${targetLang}`); | |
| } | |
| // Perform translation | |
| const response = await fetch('/translate', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| text, | |
| target_language: targetLang, | |
| source_language: sourceLang | |
| }) | |
| }); | |
| return response.json(); | |
| } | |
| ``` | |
| ## π― **Perfect For** | |
| ### **Web Applications** | |
| - **Language Selectors**: Rich dropdowns with native names | |
| - **Translation Interfaces**: Real-time translation with validation | |
| - **Multi-language Support**: Dynamic language switching | |
| - **Search & Autocomplete**: Find languages quickly | |
| ### **Mobile Applications** | |
| - **Offline Language Lists**: Cache language data locally | |
| - **Quick Selection**: Popular languages for faster UX | |
| - **Regional Filtering**: Show relevant languages by location | |
| - **Voice Input**: Validate detected languages | |
| ### **Business Intelligence** | |
| - **Usage Analytics**: Track translation patterns | |
| - **Language Coverage**: Monitor supported languages | |
| - **Performance Metrics**: API response times and success rates | |
| - **Regional Insights**: Usage by geographic region | |
| ## π **Ready for Production** | |
| Your API now provides: | |
| - β **Complete Language Awareness**: Knows all its capabilities | |
| - β **Developer-Friendly**: Easy integration with comprehensive docs | |
| - β **Frontend-Ready**: Perfect for building user interfaces | |
| - β **Enterprise-Grade**: Monitoring, logging, and analytics | |
| - β **Scalable**: Clean architecture for future enhancements | |
| The API is now a complete translation platform that developers will love to work with! π | |