POST /translator/translate/html

Translate HTML

Translate HTML content while preserving all markup, tags, and attributes.

Translation API

Translate HTML content while preserving all markup, tags, attributes, and document structure. Only the visible text content is translated, leaving HTML elements and attributes intact.

HTTP Request

1
POST /translator/translate/html

Parameters

ParameterTypeRequiredDefaultDescription
sourcestringNo"auto"Source language code. Use auto for automatic detection
targetstringYesTarget language code

Request Body

Send the HTML content as the raw request body with Content-Type: text/html.

1
2
3
4
5
<div class="hero">
  <h1>Welcome to our platform</h1>
  <p>Build amazing applications with our powerful tools.</p>
  <a href="/signup">Get started for free</a>
</div>

Response

1
2
3
4
5
6
7
8
{
  "status": true,
  "data": {
    "translated_html": "<div class=\"hero\">\n  <h1>Bienvenido a nuestra plataforma</h1>\n  <p>Construye aplicaciones increibles con nuestras poderosas herramientas.</p>\n  <a href=\"/signup\">Comienza gratis</a>\n</div>",
    "source_language": "en",
    "source_language_name": "English"
  }
}

Response Fields

FieldTypeDescription
statusbooleanWhether the request was successful
data.translated_htmlstringThe translated HTML with markup preserved
data.source_languagestringDetected or specified source language code
data.source_language_namestringHuman-readable name of the source language

Code Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests

url = "https://multi-format-ai-translator-the-most-complete.p.rapidapi.com/translator/translate/html"

querystring = {
    "source": "auto",
    "target": "es"
}

payload = """<div class="hero">
  <h1>Welcome to our platform</h1>
  <p>Build amazing applications with our powerful tools.</p>
  <a href="/signup">Get started for free</a>
</div>"""

headers = {
    "Content-Type": "text/html",
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "multi-format-ai-translator-the-most-complete.p.rapidapi.com"
}

response = requests.post(url, headers=headers, params=querystring, data=payload)
data = response.json()

print(data["data"]["translated_html"])
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const url = "https://multi-format-ai-translator-the-most-complete.p.rapidapi.com/translator/translate/html";

const params = new URLSearchParams({
  source: "auto",
  target: "es",
});

const html = `<div class="hero">
  <h1>Welcome to our platform</h1>
  <p>Build amazing applications with our powerful tools.</p>
  <a href="/signup">Get started for free</a>
</div>`;

const response = await fetch(`${url}?${params}`, {
  method: "POST",
  headers: {
    "Content-Type": "text/html",
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "multi-format-ai-translator-the-most-complete.p.rapidapi.com",
  },
  body: html,
});

const data = await response.json();
console.log(data.data.translated_html);
1
2
3
4
5
curl -X POST "https://multi-format-ai-translator-the-most-complete.p.rapidapi.com/translator/translate/html?source=auto&target=es" \
  -H "Content-Type: text/html" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: multi-format-ai-translator-the-most-complete.p.rapidapi.com" \
  -d '<div class="hero"><h1>Welcome to our platform</h1><p>Build amazing applications with our powerful tools.</p></div>'
Start building today

Get your API key and make your first request in under a minute.

Get Your API Key on RapidAPI