> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drain.lat/llms.txt
> Use this file to discover all available pages before exploring further.

# Translate

> Translate text into any language using Google Translate.

# Translate

**Base URL:** `https://drain.lat/api/v1/translate`

<AccordionGroup>
  <Accordion title="GET /" icon="language">
    Translate text into any supported language.

    ```
    GET /api/v1/translate
    ```

    <ParamField query="text" type="string" required>
      The text to translate. Max 5000 characters.
    </ParamField>

    <ParamField query="to" type="string" required>
      Target language code (BCP-47 / ISO 639-1, e.g. `es`, `fr`, `ja`, `zh`).
    </ParamField>

    <ParamField query="from" type="string">
      Source language code. Defaults to `auto` for automatic detection.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/translate?text=Hello&to=es&from=auto" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch(
        "https://drain.lat/api/v1/translate?text=Hello&to=es",
        { headers: { "x-api-key": "YOUR_API_KEY" } }
      );
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/translate",
          params={"text": "Hello", "to": "es"},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="original" type="string">The original input text.</ResponseField>
    <ResponseField name="translated" type="string">The translated text.</ResponseField>
    <ResponseField name="sourceLang" type="string">Detected or specified source language code.</ResponseField>
    <ResponseField name="targetLang" type="string">Target language code.</ResponseField>

    ```json Response theme={null}
    {
      "original": "Hello",
      "translated": "Hola",
      "sourceLang": "en",
      "targetLang": "es",
      "scrapedAt": "2026-05-12T10:00:00.000Z"
    }
    ```

    <Note>
      Supports all languages available in Google Translate. Use ISO 639-1 codes for `to` and `from` (e.g. `es` for Spanish, `fr` for French, `ja` for Japanese, `zh` for Chinese).
    </Note>
  </Accordion>
</AccordionGroup>
