Skip to content
ScrapeField

Blog · Guides ·

Opening hours of every place on a list

Which of your stores, or your leads, are open on Sunday, and which stay open late? One call a place reads its opening hours as data, not as text to parse.

ScrapeField

Opening hours answer practical questions: which branches open on Sunday, which leads can take a call at 8 in the morning, which shops stay open late. Google Maps has them for most businesses. This guide reads them for a list of places and answers two of those questions.

Hours as data

GET /v1/google-maps/place returns opening_hours, or null when the listing has none. It holds the hours twice. weekday_text is seven lines, Monday first, as the listing prints them. periods is the same as data: each has an open and a close, each with a day (0 is Sunday) and a 24-hour time such as “2130”. A place open around the clock has one period with no close. A place costs 3 credits.

const places = ['ChIJN1t_tDeuEmsRUsoyG83frY4']; // your place_ids
const headers = { Authorization: `Bearer ${process.env.SCRAPEFIELD_KEY}` };

for (const placeId of places) {
  const res = await fetch(`https://api.scrapefield.com/v1/google-maps/place?place_id=${encodeURIComponent(placeId)}`, { headers });
  const body = await res.json();
  if (!res.ok) { console.error(placeId, body.error.code); continue; } // a failed call is not charged
  const { name, opening_hours } = body.data;
  if (!opening_hours) { console.log(`${name}: no hours on the listing`); continue; }

  const sunday = opening_hours.periods.some((p) => p.open.day === 0);
  // open past 9 pm: it closes later than 21:00, after midnight, or never
  const late = opening_hours.periods.some((p) => !p.close || p.close.day !== p.open.day || p.close.time > '2100');
  console.log(`${name}: ${sunday ? 'open' : 'closed'} on Sunday${late ? ', open after 9 pm' : ''}. Sunday: ${opening_hours.weekday_text[6] ?? 'not listed'}`);
}

Use periods for any question you answer in code, and weekday_text to show the hours to a person. The text is in the listing’s language and format, which is right for reading and wrong for parsing.

Hours change

Owners change their hours for holidays and seasons, and Google shows the change when they do. A place is cached for a day at most, so a weekly check is never more than a day behind. A place that is closed for a while has a business_status of CLOSED_TEMPORARILY, whatever its hours say: check that first, as Take the closed businesses out of a lead list does.

What it costs

3 credits a place. 500 places are 1,500 credits, about $1.17 on the smallest pack. For a long list, run several calls side by side, up to your limit of calls at once.

More articles