ScrapeField
A list of businesses goes stale while you use it. Some close for good. Some close for a refit or for the season. A call to a closed business wastes a rep’s time, and mail to one comes back. This guide checks each business on a list against its Google Maps listing and splits the list in three.
What a listing says
GET /v1/google-maps/place returns a business_status for every place: OPERATIONAL, CLOSED_TEMPORARILY or CLOSED_PERMANENTLY, as Google’s Places API names them. A place that closed a long time ago can disappear from Maps. Then the call answers 404 with place_not_found, and is not charged. Count that as closed too. A place costs 3 credits.
Check a list
const leads = [
{ name: 'Example Bakery', placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4' },
// the rest of your list, each with the place_id you saved when you found it
];
const headers = { Authorization: `Bearer ${process.env.SCRAPEFIELD_KEY}` };
const open = [], closedForNow = [], closed = [];
for (const lead of leads) {
const res = await fetch(`https://api.scrapefield.com/v1/google-maps/place?place_id=${encodeURIComponent(lead.placeId)}`, { headers });
const body = await res.json();
if (res.status === 404 && body.error.code === 'place_not_found') { closed.push(lead); continue; } // gone from Maps
if (!res.ok) { console.error(lead.name, body.error.code); continue; } // try it again later; a failed call is not charged
const { business_status, formatted_phone_number, website } = body.data;
if (business_status === 'CLOSED_PERMANENTLY') closed.push(lead);
else if (business_status === 'CLOSED_TEMPORARILY') closedForNow.push(lead);
else open.push({ ...lead, phone: formatted_phone_number, website });
}
console.log(`${open.length} open, ${closedForNow.length} closed for now, ${closed.length} closed for good`);The open ones come back with the phone number and the website the listing shows today, which may not be the ones on your list.
Closed for now is not closed
CLOSED_TEMPORARILY is a refit, a season or a long holiday. Keep those businesses, and check them again in a month. Only CLOSED_PERMANENTLY and place_not_found mean the business is gone.
A list without place ids
If your list has names and addresses but no place_id, search for each one with GET /v1/google-maps/places. A search costs 3 credits and returns the same listing, business_status included, so one call is enough. A search returns the closest match, which for a closed business can be the shop next door, so compare the name first.
const unmatched = [{ name: 'Example Bakery', address: '12 Example Street, Springfield' }];
for (const lead of unmatched) {
const query = encodeURIComponent(`${lead.name}, ${lead.address}`);
const res = await fetch(`https://api.scrapefield.com/v1/google-maps/places?query=${query}&limit=1`, { headers });
const body = await res.json();
if (!res.ok) { console.error(lead.name, body.error.code); continue; }
const [found] = body.data;
if (!found) { console.log(lead.name, 'is not on Maps'); continue; }
if (found.name.toLowerCase() !== lead.name.toLowerCase()) { console.log(lead.name, 'matched', found.name, '- check it by hand'); continue; }
lead.placeId = found.place_id; // keep it: next time, one place call is enough
console.log(lead.name, found.business_status);
}How often, and what it costs
Once a quarter suits most lists. 1,000 businesses cost 3,000 credits a check, about $2.34 on the smallest pack. A place is cached for a day at most, so the status is never more than a day old. For thousands of places, run several calls side by side, up to your limit of calls at once. To build a list in the first place, see Google Maps leads for a whole city.