Translation API Documentation

Welcome to the Translation API service. This API allows you to translate text between multiple languages.

API Endpoints

1. Translate Plain Text

POST /translate

Translate plain text from one language to another.

Request Example:

{
    "text": "Hello World",
    "from_code": "en",
    "to_code": "es"
}

Response Example:

{
    "status": "success",
    "original_text": "Hello World",
    "translated_text": "Hola Mundo",
    "from_language": "en",
    "to_language": "es"
}

2. Translate HTML Content

POST /translate_html

Translate HTML content while preserving the structure.

Request Example:

{
    "html": "<div><p>Hello World</p></div>",
    "from_code": "en",
    "to_code": "es"
}

Response Example:

{
    "status": "success",
    "original_html": "<div><p>Hello World</p></div>",
    "translated_html": "<div><p>Hola Mundo</p></div>",
    "from_language": "en",
    "to_language": "es"
}

3. List Supported Languages

GET /languages

Get a list of supported language codes.

Response Example:

{
    "supported_languages": [
        {"code": "en", "name": "English"},
        {"code": "es", "name": "Spanish"},
        {"code": "pt", "name": "Portogese"}
    ]
}

4. Health Check

GET /health

Check if the service is running.

Response Example:

{
    "status": "healthy"
}

Language Codes

Code Language
en English
es Spanish
pt Portogese

Usage Examples

cURL Example for Text Translation:

curl -X POST   https://translate.codeflamme.com/translate   -H 'Content-Type: application/json'   -d '{
    "text": "I want to hire a developer",
    "from_code": "en",
    "to_code": "es"
}'

Python Example:

import requests

url = "https://translate.codeflamme.com/translate"
data = {
    "text": "Hello World",
    "from_code": "en",
    "to_code": "es"
}

response = requests.post(url, json=data)
print(response.json())

Rate Limits

Currently no rate limits are enforced, but please use the API responsibly.

Error Responses

All error responses will include an "error" field with a description of the issue.

Common HTTP status codes: