How to get the contact emails and phone numbers of websites in Google Sheets

Checked on 2026-11-24.

For a column of company websites there are two routes. A free IMPORTXML formula pulls the mailto: and tel: links off the one page you point it at. A custom function that calls an API reads the home page and the likely contact pages for you, and puts emails, phone numbers and the contact page in separate cells.

1. IMPORTXML: the email and phone links of one page

Google's own example for IMPORTXML, IMPORTXML("https://en.wikipedia.org/wiki/Moon_landing", "//a/@href"), lists the address of every link on a page. Email and phone links are links too, with addresses that begin with mailto: and tel:. With a website in A2, this formula keeps those and joins them into one cell, so the formula in the next row has room:

Terminal
=IFERROR(TEXTJOIN(", ", TRUE, LET(links, IMPORTXML("https://" & A2, "//a/@href"), FILTER(links, REGEXMATCH(links, "^(mailto|tel):")))), "none found")

LET names the list of links, FILTER keeps the ones REGEXMATCH matches, and TEXTJOIN joins them. IMPORTXML wants the address "including protocol", hence "https://" & A2 for bare domains; use plain A2 for full addresses. IFERROR turns FILTER's #N/A for no match, and any failed fetch, into "none found"; remove it to see Google's own error.

Google's page on Import functions adds the rules. The first import in a sheet waits until an editor clicks Allow access, since "the sheet will be able to send and receive data to external parties". Imports "automatically check for updates every hour while the document is open". And too many give "Error Loading data may take a while because of the large number of requests".

Where it stops: at the page you name. A home page without an email link gives nothing, and every site names its contact page differently, so for a long list you look up pages by hand first. Addresses written as plain text, not as links, are missed. Google does not document whether IMPORTXML runs a page's JavaScript, so details a page adds with a script may be missing. And some sites keep addresses from scripts on purpose: Cloudflare "enables email address obfuscation automatically when you sign up", putting placeholder links in the HTML that a script in the visitor's browser restores. That is the owner saying no, and this guide does not show how to undo it. For one page you have open, the free email extractor reads the addresses from its HTML source.

2. A custom function that reads the contact pages

The Pipefetch website contacts endpoint reads the home page first, then the pages most likely to hold contact details (contact, imprint, about, team), up to 5 pages by default and 10 at most. In your sheet open Extensions, then Apps Script, delete what is in the editor, paste this and click Save.

JavaScript
const API = "https://pipefetch.com";

// One request to the API. A 404 means nothing was found, which costs nothing.
function pipefetch_(path, params) {
  const key = PropertiesService.getScriptProperties().getProperty("PIPEFETCH_API_KEY");
  if (!key) throw new Error("Add PIPEFETCH_API_KEY under Project Settings, Script properties.");
  const query = Object.keys(params).map((name) => name + "=" + encodeURIComponent(params[name])).join("&");
  const res = UrlFetchApp.fetch(API + path + "?" + query, {
    headers: { "x-api-key": key },
    muteHttpExceptions: true,
  });
  const body = JSON.parse(res.getContentText());
  if (res.getResponseCode() === 404) return { notFound: body.error.code };
  if (res.getResponseCode() !== 200) throw new Error(body.error.message);
  return body.data;
}

/**
 * Main email, all emails, main phone, all phones and contact page of a website, across five cells.
 * @customfunction
 */
function WEBSITE_CONTACTS(site, pages) {
  if (!site) return "";
  const data = pipefetch_("/v1/web/contacts", { url: site, pages: pages || 5 });
  if (data.notFound) return data.notFound;  // no_contacts, website_unreachable or website_blocked
  return [[
    data.primaryEmail || "",
    data.emails.map((e) => e.email).join(", "),
    data.primaryPhone || "",
    data.phones.map((p) => p.phone).join(", "),
    data.contactPageUrl || "",
  ]];
}

Store your API key

Keep the key out of the script and out of the cells. In the Apps Script editor click Project Settings, and under Script Properties click Add script property: the name is PIPEFETCH_API_KEY, the value your key. You get a key, with 100 free credits and no card, in the dashboard. Editors of the sheet "can view, edit, and run its bound script", in the words of Google's page on bound scripts, so they can read the key too; share results with anyone else as values in a sheet without the script.

Use it in the sheet

Terminal
=WEBSITE_CONTACTS(A2)       main email, all emails, main phone, all phones, contact page
=WEBSITE_CONTACTS(A2, 10)   the same, reading up to 10 pages of the site

Column A can hold bare domains such as apify.com or full addresses; a path is ignored. The four cells to the right of the formula have to be empty. For apify.com, read on 18 November 2026, the endpoint returned support@apify.com as the main address, three more from the contact and legal pages, no phone, and the contact page. When a site has nothing, the cell shows why: no_contacts (nothing on the pages read), website_unreachable (no such site, or no answer within about 20 seconds) or website_blocked (it refuses automated requests). Those cost nothing; a site with contacts costs 1 credit. The answer also has social profiles, the contact form and the postal address when the site shows one, all named in the reference.

Where it stops: it reads pages as plain HTML, so contact details that only appear after a page runs JavaScript are not seen. Only what the website itself publishes is returned: nothing is guessed, and no other source is asked. It is not an official API of the sites it reads, and Pipefetch is not affiliated with them.

The limits that bite

  • 30 seconds per cell. Google's custom functions guide: "A custom function call must return within 30 seconds." Otherwise the cell shows #ERROR! with the note Exceeded maximum execution time (line 0). Most requests take 2 to 9 seconds. A site that does not answer is the exception: the API waits about 20 seconds before it reports website_unreachable, so such a cell can show the timeout error instead. A request the cell gave up on can still finish on our side, and if it returns data it is charged although the cell never shows it; one that returns nothing costs nothing.
  • Recalculation is a new request. A custom function runs again when you edit its formula or change a cell it points to, and each run that returns data is charged. To be sure a filled column is never fetched again, paste it over itself with Paste special, Values only. Passing NOW() or RAND() to make it refresh does not work: volatile arguments are not allowed, and the cell shows Loading... indefinitely.
  • Google's daily quota. The quotas page allows 20,000 URL Fetch calls a day for a personal Google account and 100,000 for Google Workspace, reset 24 hours after the first request. Custom functions run as an anonymous user, but the calls count against whoever is at the keyboard.
  • Pipefetch's limits. 120 requests a minute per account; above that the cell shows "Too many requests. Slow down and retry in a moment." Requests that find nothing are free, up to 100 a day plus one for every request that returned data, reset at 00:00 UTC. Dead and empty sites count towards that allowance, which matters for an old list.

Hundreds of rows

A long column of formulas runs into Google's limits. "Each time a custom function is used in a spreadsheet, Sheets makes a separate call to the Apps Script server", says its guide, and by the hundred "this process can be slow". The quotas page allows 30 simultaneous executions per user and names two errors that "most commonly" come from custom functions called repeatedly in one spreadsheet: Script invoked too many times per second for this Google user account. and There are too many scripts running simultaneously for this Google user account. Re-entering a failed cell's formula tries again.

Google's remedy, one function over a whole range, does not fit here: that one call still has 30 seconds, and each lookup takes seconds. Its guide names the other way: "To edit arbitrary cells, use a custom menu to run a function instead." A run started from a menu may take 6 minutes. Add this to the same script, save, and reload the sheet:

JavaScript
function onOpen() {
  SpreadsheetApp.getUi().createMenu("Pipefetch")
    .addItem("Fill contacts", "fillContacts")
    .addToUi();
}

function fillContacts() {
  fillColumn_((site) => {
    const data = pipefetch_("/v1/web/contacts", { url: site, pages: 5 });
    if (data.notFound) return [data.notFound];
    return [
      data.primaryEmail || "",
      data.emails.map((e) => e.email).join(", "),
      data.primaryPhone || "",
      data.phones.map((p) => p.phone).join(", "),
      data.contactPageUrl || "",
    ];
  });
}

// Column A holds what to look up, from row 2 down; results go into column B and the columns after it.
// Rows that already have something in column B are skipped, so a second run carries on from there.
function fillColumn_(lookup) {
  const sheet = SpreadsheetApp.getActiveSheet();
  const rows = sheet.getLastRow() - 1;
  if (rows < 1) return;
  const values = sheet.getRange(2, 1, rows, 2).getValues();
  const stopAt = Date.now() + 4 * 60 * 1000;  // Google ends a run after 6 minutes
  for (let i = 0; i < rows && Date.now() < stopAt; i++) {
    const [input, filled] = values[i];
    if (input === "" || filled !== "") continue;
    const row = lookup(input);
    sheet.getRange(i + 2, 2, 1, row.length).setValues([row]);
    SpreadsheetApp.flush();  // write each row at once, so a later failure loses nothing
  }
}

Choose Pipefetch, then Fill contacts, on the tab with websites in column A. The first run asks you to authorize the script, which now edits the sheet and calls an outside address. It sends one request at a time and writes values, so nothing is fetched again later. It skips rows whose column B is filled and starts nothing new after 4 minutes: choose the item again to carry on. If a request fails, the run stops with the API's message and keeps what it wrote.

A menu run is not held to the 30 seconds, so slow sites end up as website_unreachable rather than as an error.

What you may do with the addresses

That an address is published does not settle what you may do with it. The guide on extracting emails in Python quotes what the European Commission counts as personal data and what the FTC says about harvesting addresses. Prefer the shared mailboxes a company publishes, and keep only what you need. None of this is legal advice.

Which one should you use?

SituationUse
A few sites, and you know the page with the addressesThe IMPORTXML formula
A list of domains, with emails, phones and the contact page found for youWEBSITE_CONTACTS with Pipefetch
Hundreds of domainsThe Fill contacts menu
A site that hides its addresses from scriptsNeither: use its contact form

Try it with 100 free credits. No card needed. No scraper to build or maintain. Get an API key or read the docs.

Every source

YouTube

Instagram

TikTok

Facebook

Google

Threads

LinkedIn

App stores

Steam

X

Pinterest

Airbnb

Real estate

Keywords

Job boards

Eventbrite

Shopify stores

Public tenders

All guides