Google translate API free Python

Free Google Translate API using python

google_translate_api

How can we use google translate API ?

You are in the right place for above question because we will explain with example .

Basically everyone know about the Google Translate because if someone doesn't know more than one language then google translate will be required for translate keyword or any language.

Suppose if you want to translate english to hindi with any keyword like Education then result will be शिक्षा in hindi and if you translate Facebook then result will be same as Facebook in hindi so some of translate will be same result. that's why we are using google translate for exact result.

Please follow the below steps for google translate api

1. Generate key

Click on below link for generate api key

Google Translate API Key

Once you entered on Google Translate API page then you will see the complete details of API . please find the below screenshot for your reference .

rapid-api

Here you will see the three highlighted content in red color

1. type of request, 2. Rapid api key, 3. log in or sign up

1. Type of request basically is multiple request type where you can select the request type like I select as python.

2. Rapid api key basically is API key which will be use for Google Translate api and once you sign in or sign up completed successfully then the API KEY will be generated automatically.

3. log in or sign up should be complete for showing api key.

Once you have login successfully then you will see the auto generated api key as you can see in the below screenshot with highlighted. Please copy generated api key for use in later.

google_translate_api_key

Example of Google Translate API

In below example there are three parameters which you need to send with payload.

  • 1. q parameter is basically value where you will send the keyword which you want to translate
  • 2. target parameter is basically translate language short name which you want to translate.
  • 3 source parameter is basically translate language short name where you can send language with value parameters.
  • As you can see in below example we passed math value in q parameter and result is showing गणित so here you can see translate english to hindi and also you can choose any one language .

    import requests url = "https://google-translate1.p.rapidapi.com/language/translate/v2" payload='q=math&target=hi&source=en' headers = { 'Accept-Encoding': ' application/gzip', 'X-RapidAPI-Key': ' 4acd66a0afmsh7ceab6c6ecddc69p1653f8jsn3a5690', 'X-RapidAPI-Host': ' google-translate1.p.rapidapi.com', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)

    Result :

    Response :
    {
    "data": { "translations": [ { "translatedText": "गणित" } ] }
    }

    Also you can see the below Postman request for you reference

    check_google_translate_api

    Hope you like it , please comment if you have any doubt .



    How to setup free Google SMTP server
    How to send email from gmail using python
    Setup django project in pythonanywhere
    How to upload file in S3 bucket in python
    Free live cricket score API for python

    Post a Comment

    0 Comments