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:
=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.
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
=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 siteColumn 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 noteExceeded 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 reportswebsite_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()orRAND()to make it refresh does not work: volatile arguments are not allowed, and the cell showsLoading...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:
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?
| Situation | Use |
|---|---|
| A few sites, and you know the page with the addresses | The IMPORTXML formula |
| A list of domains, with emails, phones and the contact page found for you | WEBSITE_CONTACTS with Pipefetch |
| Hundreds of domains | The Fill contacts menu |
| A site that hides its addresses from scripts | Neither: 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.
APIs used in this guide
More Websites guides
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to calculate an Instagram engagement rate in Python
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
TikTok
- How to get a TikTok video's views and likes in Python
- How to get the comments of a TikTok video in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- How to get Google Trends data in Python
- Why is Wyoming first in Google Trends?
- How to get Google search results in Node.js
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
Threads
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python