▫️Translate

This API endpoint allows you to translate text from one language to another using the MyMemory Translation API.

/translate

This endpoint translates text from one language to another based on the provided parameters. It accepts a GET request with query parameters including the text, fromLang, and toLang. If any of these parameters are missing, it returns a custom HTML page indicating missing parameters. If the translation is successful, it returns the original text along with its translation. If the translation fails or an error occurs, it returns a corresponding error message with a status code of 500.

Query Parameters

ParameterTypeDescription

text

string

The text to be translated.

fromLang

string

The language code of the text to be translated from.

toLang

string

The language code of the text to be translated to.

Example Usage

Translate "Hello, how are you?" from English to Spanish:

GET /translate?text=Hello how are you&fromLang=en&toLang=es

Example Response

{
  "originalText": "Hello, how are you?",
  "translatedText": "¡Hola, ¿cómo estás?"
}

Languages Supported

Go find all the language codes and their corresponding ISO 639-1 or RFC3066 codes online or in language code standards documentation.

Last updated