Connecting the Google Translate API to Google Sheets

Google Translate is a multilingual neural machine translation service developed by Google, to translate text, documents and websites from one language into another. We can use the Google Translate API to import data from Google Translate into Google Sheets. In this tutorial, we’ll show you how to connect the Google Translate API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose a Google Translate API Endpoint
  4. Enter your Google Translate API request into Apipheny
  5. Run the API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Obtain an API key

For this example, we are using the Google Translate API offered on RapidAPI.com. To access this API, first log in to RapidAPI using your Google account:

Log in on Rakuten Rapid API
Log in on Rakuten Rapid API

Next, go to this page: https://rapidapi.com/googlecloud/api/google-translate1

Then scroll down until you see the X-RapidAPI-Key field:

Google Translate API documentation
Google Translate API documentation
X-RapidAPI-Key section
X-RapidAPI-Key section

Copy and paste the value of your API key to a safe location because you’ll need this key in the next steps.

After you copy the value of your API Key, click the “Subscribe to Test” button and on the next page, choose a subscription plan. The free plan is fine to start with:

Subscription plans section
Subscription plans section

Step 3.) Choose a Google Translate API Endpoint

In this section, we’ll show you how to browse the Google Translate API documentation to find the Google Translate API URL that retrieves the information you need from your Google Translate account. If you already know your API URL and endpoint, or you want to use the same example URL as us, just skip to Step 4.

First, open the Google Translate API documentation page: https://english.api.rakuten.net/googlecloud/api/google-translate1/endpoints

The menu on the left contains a list of three endpoints:

Google Translate API documentation page
Google Translate API documentation page

An example endpoint is Detect, which detects the language of the text within a request. This is the URL for this endpoint:

https://google-translate1.p.rapidapi.com/language/translate/v2/detect

The documentation for each endpoint contains a short description of the endpoint’s purpose, its HTTP method (GET), a table with the accepted parameters’ names, types and descriptions and an example request made using various technologies, including cURL:

Google Translate endpoint documentation
Google Translate endpoint documentation

All API calls to the Google Translate API should be made to the https://google-translate1.p.rapidapi.com/language/translate/v2/ base domain. All endpoints should be appended to this base URL.

Step 4.) Enter your Google Translate API request into Apipheny

Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method. The documentation specifies what method is required for each endpoint.

API URL: In Step 3, we explained how you can find the Google Translate REST API endpoint that you need. Now copy and paste your complete Google Translate API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).

For this example, we are using the Languages endpoint, which returns a list of supported languages for translation. This is what the whole URL looks like:

https://google-translate1.p.rapidapi.com/language/translate/v2/languages

Headers: In the Headers section of Apipheny, add three row with the following keys and values:

Header 1
Key:
x-rapidapi-host
Value:
google-translate1.p.rapidapi.com

Header 2
Key:
x-rapidapi-key
Value:
API_key

Header 3
Key:
accept-encoding
Value:
application/json

In the second header value, you should replace API_key with the key that you previously obtained in Step 2. This is what our Google Translate API request looked like when entered into Apipheny:

Google Translate API request entered into Apipheny

Step 5.) Run the Google Translate API request in your Google Sheet

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Google Translate API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

Google Translate data imported into Google Sheets

That’s it! You’ve successfully connected your Google Translate account to Google Sheets using the Google Translate API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the Google Translate API, try querying a different Google Translate API endpoint, or try using one of the more advanced features in the Apipheny add-on.


Crypto API tutorials and more:


API Tutorials



API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?


Sponsored by Zink Virtual Tip Jar & Rewording.io Paraphrasing Tool

Accept donations on Twitch | Accept donations on Discord | Accept donations on YouTube | Accept donations on Telegram | Accept donations on Twitter | Accept donations on TikTok | Accept donations on Instagram | Accept donations on LinkedIn | Accept donations on Facebook | Accept donations on your Website