In this article:

How to Use an API in Google Sheets [2024 Update]

April 1, 2024

How to Use an API to Import Data in Google Sheets

1. Get the API URL and API Key

The data in many eCommerce and marketing platforms such as Salesforce and MySQL databases can be accessed via their own API. Others may require additional information such as database name, username, password, and such. 

As the data in these platforms can only be accessed by authorized users, accessing the data through the API of these platforms requires API keys. 

2. Insert Script to Access API in Google Sheets

The data that can be accessed via a platform’s API is usually in JSON format. We can process it by using the ImportJSON code below:

api to google sheets

Access ImportJSON here.

After copying the code, go back to Google Sheets. Click Extensions then select Apps Script. 

how to use api in google sheets

A new tab will load for Google Apps Script with a code area.

Apps script blank code area

Clear the code area then paste the code in it. 

Code added to apps script 

Save the script by clicking Save project.

Save project on google apps script

3. Use the Formula =ImportJSONBasicAuth("database_URL","api_key","password")

Go back to the tab where Google Sheets is loaded. To use the script to import data to Google Sheets via API, use the following formula: 

=ImportJSONBasicAuth("database_URL","api_key","password")

Where:

database_URL has the following format: https://{hostname}/admin/api/{version}/{resource}.json

Api_key is the API key to access the data

And Password is the password to access the data. 

Add it to the cell where you want to insert the data.

Pretty straightforward? Well it depends. Not all platforms work the same way! But we got you covered. Here is an alternative: Lido.app. Yep, this website you are browsing right now has its own spreadsheet. It has a built-in import data function that can help you integrate data from different platforms in just a few clicks. Scroll right to the next section to see how Lido.app works!

How to Import Data from API Using Lido.app

It will be much better if a spreadsheet has built-in import functions from different eCommerce and marketing platforms. Fortunately you don’t have to look far! We present to you Lido.app. How easy is it to use? Here are the steps:

1. Click Connect Data then Select Source

Click the Connect Data button on the upper-left corner of Lido sheet.

Lido, connect data to API

A box labeled Add Data will appear, listing the platforms you can integrate with Lido. Select the platform you want to integrate.

Add data options

2. Input Information to Connect Platform to Lido via API

The information needed to connect the platform to Lido depends on the platforms themselves, so make sure you prepare them in advance. They usually include one or more of the following: 

  • API URL
  • API Key
  • Username
  • Password

After selecting the platform, you will be asked to input such information. Add them, then click Connect with Platform.

Connect lido to platform via API

A new tab will load, where you authorize Lido to access the data in the platform you selected. Approve the request.

Allow lido access to data in your platform via API

You will be returned to the Lido tab, showing the connection success.

Lido successfully connected to platform via API

3. Select the Data to Import

You then select the data to import next. Lido automatically detects the data in the platform you connected. First, select the object and the table to import. Next, select the specific columns to import. 

Select data to add

Once done, click Add Data. The data is now imported to Lido.app!

Data added to Lido.app

…Interested in Trying Something New?

Having seen how to import data to Google Sheets via API, do you still want to use it as your main spreadsheet platform? Or do you want to try something new, something that allows you to easily import data from different platforms in just a few clicks?

Well, try Lido now!

Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.
Get your copy of our free Google Sheets automation guide!
  • 27 pages of Google Sheets tips and tricks to save time
  • Covers pivot tables and other advanced topics
  • 100% free

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->