How to Use an API in Google Sheets

Three ways to bring API data into a sheet: formulas, Apps Script and an add-on. What each one takes to set up, and when each one breaks.

By Jake Marsh. Updated Nov 29, 2026.

The short answer

There are three ways to get API data into Google Sheets, and they trade setup time for how much they can handle:

  1. A formula such as IMPORTDATA or IMPORTXML. Nothing to install, but it only reads public files at an address you can paste. It can't send a key, can't read JSON and can't follow pages.
  2. Apps Script, Google's scripting for Sheets. Its UrlFetchApp service can call any API with any header, and a time trigger can run it on a schedule. You write and maintain the code.
  3. An add-on that does the Apps Script part for you: you pick the app or paste the request, the add-on sends it, turns the response into rows and refreshes the tab on a schedule.

Most people start with the first, hit a wall the day an API asks for a key, and then choose between writing code and installing something. The rest of this guide shows what each step involves so you can choose with your eyes open.

Way 1: a formula

Google Sheets has four import formulas that read from outside the spreadsheet: IMPORTDATA for CSV and TSV files, IMPORTXML for XML, HTML and feeds, IMPORTHTML for a table or list on a web page, and IMPORTFEED for RSS and Atom. Each takes an address and returns rows:

=IMPORTDATA("https://example.com/exports/orders.csv")

That works when the data is public and already shaped like a table. It stops working the moment an API wants proof of who you are. IMPORTDATA has one argument, the address, so the only place a key can go is inside that address, where everyone the sheet is shared with can read it. And the response has to be CSV or TSV: Sheets has no built-in formula that turns JSON into rows. The IMPORTDATA, IMPORTXML and IMPORTHTML guide covers how often these formulas refresh and the errors people hit with them.

Way 2: Apps Script and UrlFetchApp

Open Extensions > Apps Script in your sheet and you get a JavaScript editor bound to that spreadsheet. UrlFetchApp sends any request: method, headers, body. This is the smallest script that pulls one page of records into a tab called Deals:

function importDeals() {
  const token = PropertiesService.getUserProperties().getProperty('API_TOKEN');
  const res = UrlFetchApp.fetch('https://api.example.com/v1/deals?limit=100', {
    headers: { Authorization: 'Bearer ' + token },
    muteHttpExceptions: true,
  });
  if (res.getResponseCode() !== 200) throw new Error(res.getContentText());
  const deals = JSON.parse(res.getContentText()).data;
  const rows = deals.map((d) => [d.id, d.title, d.value, d.stage]);
  const sh = SpreadsheetApp.getActive().getSheetByName('Deals');
  sh.getRange(2, 1, sh.getMaxRows() - 1, 4).clearContent();
  if (rows.length) sh.getRange(2, 1, rows.length, 4).setValues(rows);
}

Three things in it are easy to get wrong:

To run it on a schedule, add a time-driven trigger (the clock icon in the editor). Apps Script has daily limits on how much of that it does for you: 20,000 URL Fetch calls a day on a personal Google account and 100,000 on Google Workspace, 6 minutes per run, and 90 minutes of trigger time a day on a personal account (6 hours on Workspace). The refresh guide shows how those add up.

What the script still doesn't do: retry when the API says slow down, convert dates and money into real cell values, keep your report formulas pointed at the right columns, or tell you when it stopped working. Each of those is another afternoon.

Way 3: an add-on that sends the request for you

An add-on is the same Apps Script machinery packaged for you. In Cellfetch you either pick an app (Stripe, HubSpot, Notion and the others on the integrations page) and paste its key, or build any request by hand: address, method, headers, body, where the records sit in the response, and which values become columns. You can also paste a cURL command from an API's docs and Cellfetch fills in the request, moving any key it finds into a saved connection.

The parts of an API request

Every API import has the same parts. Here they are for GitHub issues, the way Cellfetch's preset sets them up:

GitHub issues request
PartGitHub
MethodGET
Addresshttps://api.github.com/repos/{{repo}}/issues
Querystate=all
KeyAuthorization: Bearer <your token>
Other headersAccept: application/vnd.github+json; X-GitHub-Api-Version: 2022-11-28
PagesA next-page link in the Link header
ColumnsNumber, Title, Type, State and Author and more

Set up in Cellfetch: GitHub.

Keys stay in your own Google account, never in a cell, and Cellfetch sends each one only to the address it belongs to. Pages are followed for you, the tab refreshes on the schedule you pick, and each run writes a line to a Cellfetch log tab so you can see when it ran and what it got.

Which one to pick

You needFormulaApps ScriptAdd-on
A public CSV, XML or HTML tableYesYesYes
An API that wants a keyNoYesYes
JSON turned into columnsNoYou write itBuilt in
Every page of a long listNoYou write the loopBuilt in
Refresh while the sheet is closedNoWith a triggerYes, up to hourly
Someone else maintains itGoogleYouThe add-on's maker

If the data is a public CSV, use IMPORTDATA and stop there. If you're comfortable keeping a script alive and the API is simple, Apps Script costs nothing but your time. If the sheet feeds a weekly meeting and nobody wants to own code, an add-on is the reasonable choice.

Working with JSON in general, outside any one app? The import JSON into Google Sheets guide walks through paths and nested fields. Before you paste a key anywhere, read API tokens explained for which kind to create and how to scope it. Terms like bearer token, JSONPath and rate limit have short entries in the glossary.

Questions

Does Google Sheets have a built-in way to call an API?

Not one that sends a key. IMPORTDATA, IMPORTXML and IMPORTHTML only take an address, so they work for public CSV, XML and HTML files. Anything that needs an Authorization header, a JSON response turned into rows, or more than one page needs Apps Script or an add-on.

Can I put my API key in the sheet?

Please don't. A key typed into a cell, a formula or a script bound to the sheet can be read by the people the sheet is shared with. Keep it in user properties (Apps Script) or in an add-on that stores it in your own Google account.

Why does my script work when I run it but fail on a schedule?

Usually one of three things: the run took longer than Apps Script's 6 minutes, the account ran out of its daily URL Fetch calls (20,000 on a personal account, 100,000 on Google Workspace) or its daily trigger time (90 minutes on a personal account, 6 hours on Workspace), or the key it reads lives in a different user's properties than the one the trigger runs as.

How do I turn a JSON response into rows?

Find the list of records in the response (for example data, results or items), then pick one value per column. The paths that pick those values are called JSONPath; the glossary entry shows them on a real import.

All guides

Install Cellfetch

From inside a sheet: Extensions > Add-ons > Get add-ons, search Cellfetch, Install. Then Extensions > Cellfetch > Start.