#What Text API solves
The Text API provides 8 specialized endpoints for professional text processing: detect languages automatically, translate with context awareness, fix grammar and spelling, rephrase for clarity, summarize long content, explain complex text in simple terms, and find context-aware synonyms. Perfect for multilingual apps, content platforms, customer support, and educational tools. All powered by config-based languages with zero database dependencies.
#Available endpoints
#POST /v1/text/languages
- Best for: Getting the complete list of 105 supported languages and their variants
- Source: Static config file (fast, no database)
- Use case: Populate language dropdowns, validate language IDs before translation
#POST /v1/text/detect-language
- Best for: Automatically identifying the language(s) in user-submitted text
- Returns: Language codes with confidence scores (0-1)
- Use case: Auto-routing support tickets, content moderation, multilingual search indexing
#POST /v1/text/translate
- Best for: Professional translation with context preservation
- Supports: 105 languages, 23 regional variants (American English, Brazilian Portuguese, etc.)
- Context: Simple text parameter (max 500 chars) for tone/style preferences
- Use case: E-commerce localization, multilingual customer communication, content publishing
#POST /v1/text/rephrase
- Best for: Rewriting text to be clearer, more natural, or more concise
- Keeps: Same language, same meaning, improved readability
- Context support: Apply custom voice/tone (masculine, feminine, formal, casual)
- Use case: Content optimization, email polish, documentation improvement
#POST /v1/text/correct
- Best for: Fixing grammar, spelling, and punctuation errors
- Preserves: Original meaning and voice, corrects only mistakes
- Context support: Maintain specific style/voice during correction
- Use case: User-generated content cleanup, automated proofreading, form validation
#POST /v1/text/summarize
- Best for: Creating concise summaries of long documents or articles
- Control: Set max_sentences (default: 5) for summary length
- Output language: Optional
target_languageto get summary in a different language - Context support: Summary style/audience preferences
- Use case: News digests, document previews, meeting notes, research abstracts
#POST /v1/text/explain
- Best for: Explaining complex text in simple, easy-to-understand terms
- Languages: Explain in any of the 105 supported languages (default: BG)
- Context support: Audience level (for children, academic, etc.)
- Use case: Educational platforms, customer FAQs, technical documentation simplified
#POST /v1/text/synonyms
- Best for: Finding context-aware synonyms for a selected word or phrase
- Returns: Up to 5 synonyms ranked by accuracy (0-100%)
- Context support: Tone, style, and domain preferences for synonym selection
- Use case: Writing assistants, vocabulary builders, content optimization, text editors with word suggestions
#Quick start
# Get all 105 languages
curl -X POST "https://api.yeb.to/v1/text/languages" \
-H "X-API-Key: YOUR_KEY"
# Translate to French (language ID 26)
curl -X POST "https://api.yeb.to/v1/text/translate" \
-H "X-API-Key: YOUR_KEY" \
-d '{
"text": "Hello, how are you?",
"target_language": {"type":"language","id":26}
}'
# Translate with context
curl -X POST "https://api.yeb.to/v1/text/translate" \
-H "X-API-Key: YOUR_KEY" \
-d '{
"text": "The patient has a fever",
"target_language": {"type":"language","id":26},
"context": "Medical doctor, formal terminology"
}'
#Key parameters explained
| Param | Used in | What to pass | Why it matters |
|---|---|---|---|
api_key |
All | Via header (X-API-Key) or body param |
Authentication & rate limiting |
text |
All except languages | Text to process (string) | Primary content for operation |
target_language |
translate, summarize | {"type":"language|variant","id":123} |
Specifies output language. Required for translate, optional for summarize (defaults to same language as input) |
source_languages |
translate, summarize | Array: [{"type":"language","id":76}] |
Hint for multilingual/ambiguous source text |
context |
All text operations | Simple text (max 500 chars) | Apply custom preferences (tone, voice, style, audience) |
max_sentences |
summarize | Integer (default: 5) | Control summary length |
explanation_language |
explain | Any supported language code (default: bg) | Language for simplified explanation |
selected_text |
synonyms | Word or phrase (max 50 chars) | The word/phrase to find synonyms for |
source_text |
synonyms | Full surrounding text (max 50,000 chars) | Provides context for accurate synonym ranking |
#Understanding Languages & Variants
The API supports 105 languages with 23 regional/tonal variants:
- Language ID 21 (English) → Variants: American (ID 1), British (ID 2), Australian (ID 3), Canadian (ID 4)
- Language ID 87 (Spanish) → Variants: Castilian (ID 5), Latin American (ID 6)
- Language ID 73 (Portuguese) → Variants: Brazilian (ID 7), European (ID 8)
- Language ID 26 (French) → Variants: Metropolitan (ID 9), Canadian (ID 10)
- Language ID 30 (German) → Variants: Standard (ID 11), Swiss (ID 12), Austrian (ID 13)
Fetch the complete list with /v1/text/languages. All language/variant IDs are documented and stable.
#Using context parameter
The context parameter accepts simple text (max 500 chars) to guide the AI:
- Voice/Gender: "Masculine", "Feminine", "Neutral gender"
- Tone: "Formal business", "Casual friendly", "Technical documentation"
- Perspective: "Doctor's point of view", "Patient-friendly language"
- Industry: "Legal terminology", "Medical context", "Software development"
- Audience: "For children under 10", "Academic audience", "B2B executives"
{
"text": "The patient presents with fever",
"target_language": {"type":"language","id":26},
"context": "Medical doctor, formal terminology"
}
#Reading & handling responses
#Success responses
// Translation to language
{
"translated_text": "Bonjour, comment allez-vous?",
"target_language": {
"type": "language",
"id": 26,
"code": "fr",
"name": "French",
"label": "French"
},
"response_code": 200,
"response_time_ms": 842
}
// Translation to variant (British English)
{
"translated_text": "Good morning, how are you today?",
"target_language": {
"type": "variant",
"id": 2,
"code": "en",
"name": "English",
"label": "English – British English",
"tone": "regional",
"variant_id": 2
},
"response_code": 200,
"response_time_ms": 765
}
// Language detection
{
"detections": [
{"code": "en", "confidence": 0.95},
{"code": "fr", "confidence": 0.92}
],
"languages": [
{"id": 21, "name": "English", "code": "en"},
{"id": 26, "name": "French", "code": "fr"}
],
"response_code": 200,
"response_time_ms": 523
}
// Synonyms
{
"synonyms": [
{"word": "joyful", "accuracy": 95},
{"word": "cheerful", "accuracy": 90},
{"word": "delighted", "accuracy": 85},
{"word": "pleased", "accuracy": 80},
{"word": "content", "accuracy": 75}
],
"response_code": 200,
"response_time_ms": 892
}
#Error responses
{ "error": "text is required", "code": 422, "response_code": 422 }
{ "error": "Invalid API key", "code": 401, "response_code": 401 }
- 401: Invalid or missing API key
- 422: Missing required parameters or invalid format
- 429: Rate limit exceeded (10 req/s)
- 402: Insufficient credits
- 500: Server error (retry with exponential backoff)
#Real-world use cases
#E-commerce localization
Challenge: Translate product descriptions to 10+ languages
Solution: Use translate with variants for regional preferences
// Translate to Brazilian Portuguese (variant ID 7)
POST /v1/text/translate
{
"text": "Premium leather wallet with RFID protection",
"target_language": {"type":"variant","id":7},
"context": "E-commerce product, professional tone"
}
#Customer support automation
Challenge: Handle multilingual support tickets
Solution: detect-language → translate with source_languages
// 1. Detect languages in ticket
POST /v1/text/detect-language {"text":"Hello! Je voudrais aide..."}
// Returns: languages [21, 26]
// 2. Translate with source hint
POST /v1/text/translate {
"text":"Hello! Je voudrais aide avec mon compte.",
"target_language":{"type":"language","id":21},
"source_languages":[
{"type":"language","id":21},
{"type":"language","id":26}
],
"context":"Customer support, polite"
}
// 3. Summarize for quick triage
POST /v1/text/summarize {
"text":"...",
"max_sentences":2,
"context":"Support ticket summary, highlight urgency"
}
#Content platform with voice preferences
Challenge: User-generated content needs correction while maintaining voice
Solution: Use context to preserve gender/tone
// Correct while maintaining feminine voice
POST /v1/text/correct {
"text":"Their going too the store",
"context":"Feminine voice, casual tone"
}
// → "She's going to the store"
// Rephrase with masculine, formal context
POST /v1/text/rephrase {
"text":"I wanna say that...",
"context":"Masculine, formal business communication"
}
// → "I would like to state that..."
#Best practices
- Cache language lists:
/languagesreturns config data — cache for 24h or longer - Use language IDs consistently: Document which IDs your app uses (e.g., English=21, Spanish=87)
- Leverage variants: Use American English (ID 1) vs British (ID 2) for regional accuracy
- Keep contexts concise: 500 char limit — focus on key preferences like "Formal medical" not lengthy descriptions
- Combine operations: detect → translate → correct for multilingual content pipelines
- Handle rate limits: Implement exponential backoff for 429 responses
- Monitor response times: Use
response_time_msto track API performance
#Technical architecture
Text API uses a config-based architecture with zero database dependencies:
- Languages: Static config file with 105 languages + 23 variants
- Contexts: Simple text parameters (no database storage)
- Logging: Handled by ApiBase (existing
api_requeststables) - Performance: ~5-10ms for
/languages, no database queries for language lookups
#API Changelog
synonyms endpoint — find context-aware synonyms with accuracy scores.
Expanded explain to support all 105 languages (was 6).
Context parameter limit increased from 100 to 500 characters.