RapidAPI logo

GoogleTranslate

FREE
By dimashirokov
Updated 6 months ago
Translation
8.4/10
Popularity Score
251ms
Latency
-
Success Rate

GoogleTranslate API Overview

Google Translate API translates a string in any language into another language dynamically. Google Translate API can be used for language detection as well. Test an API call in your browser and export the code snippet.

The Google Translate API is priced monthly based on usage as of 3/1/2017. Read more here: https://cloud.google.com/translate/pricing

Contact API Provider
star-blueRate

GoogleTranslate

Google Translate Package

This package allows you to translates a string of text from one language to another.

How to get apiKey:

  1. Go to the projects page

  2. Select or create a Cloud Platform Console project.

  3. Enable billing for your project.

  4. Click Continue to enable the Translate API and any related services.

  5. On the Credentials page, get an API key (select Browser key when prompted). Note: If you have an existing API key, you can use that key.

  6. Go to the translate api overview and press the "Enable" button.

GoogleTranslate.translate

Translate string from sourceLanguage to targetLanguage

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.
targetLanguage string Required: The ISO 639-1 language code to translate the input to. All supported languages
sourceLanguage string The ISO 639-1 language code the source input is written in. All supported languages

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
    "sourceLanguage": "en",
    "targetLanguage": "es"
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "Hola"
        }
    }
}

GoogleTranslate.translateAutomatic

Translate string from sourceLanguage to target language automatically

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.
targetLanguage string Required: The ISO 639-1 language code to translate the input to. All supported languages

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
    "targetLanguage": "es"
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "Hola"
        }
    }
}

GoogleTranslate.detectLanguage

Detect language of string

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "en"
        }
    }
}

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.post("https://GoogleTranslatedimashirokovV1.p.rapidapi.com/detectLanguage")
.header("X-RapidAPI-Host", "GoogleTranslatedimashirokovV1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.header("Content-Type", "application/x-www-form-urlencoded")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication