Glasser Team5 min read
Build a Google Maps Data Workflow with Python
Run a bounded Places Text Search request, understand field masks and keep place identity separate from storage and export permissions.

Choose the data path before writing the scraper
A Google Maps research workflow starts with a query, a geographic scope and the fields you need. For a maintained Python integration, Google's Places Text Search API provides a documented path to place records without depending on the visual Maps interface.
For agent-led business research, the Google Maps Scraper prepares a task that uses Glasser's available place-data sources. Your agent inspects the selected source, requests a bounded sample and organizes the returned fields.
These paths have different authentication, billing and usage conditions. The Python example below calls Google directly. The Glasser alternative uses source discovery and inspection inside your agent; it does not require pretending that Google parameters are Glasser parameters.
Define the target before either workflow. “Coffee shops in Portland, Oregon” is more inspectable than “all coffee shops.” Keep the query and area beside the results so later comparisons use the same scope.
Configure a small Places Text Search request
Google's Text Search documentation requires a textQuery and a field mask. Requested fields affect the response and billing tier. The example asks for place IDs, display names, formatted addresses and a next-page token.
You need a Google Cloud project with Places API access, billing configured and an appropriately restricted API key. Set the key in GOOGLE_MAPS_API_KEY. Do not embed it in a public script or commit it with your project.
The code requests up to ten results per page and at most two pages. Keep the request fields narrow while validating the workflow.
import json
import os
from urllib.error import HTTPError
from urllib.request import Request, urlopen
def search_places(api_key, query, max_pages=2):
places = {}
page_token = None
for page_number in range(max_pages):
body = {"textQuery": query, "pageSize": 10}
if page_token:
body["pageToken"] = page_token
request = Request(
"https://places.googleapis.com/v1/places:searchText",
data=json.dumps(body).encode("utf-8"),
headers={
"Content-Type": "application/json",
"X-Goog-Api-Key": api_key,
"X-Goog-FieldMask":
"places.id,places.displayName,"
"places.formattedAddress,nextPageToken",
},
method="POST",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.load(response)
except HTTPError as error:
raise RuntimeError(
f"Places returned HTTP {error.code}; inspect access and quota."
) from None
for place in payload.get("places", []):
places[place["id"]] = place
page_token = payload.get("nextPageToken")
if not page_token:
break
return list(places.values()), bool(page_token)
if __name__ == "__main__":
places, has_more = search_places(
os.environ["GOOGLE_MAPS_API_KEY"],
"coffee shops in Portland, Oregon",
)
print({"returned": len(places), "more_pages_available": has_more})
print(json.dumps([place["id"] for place in places], indent=2))
Save the example as search_places.py and run it with Python 3. It uses the standard library and prints counts and place IDs. The place records remain available to your program during the call for uses permitted by your API agreement.
Treat pagination and data use as explicit constraints
The next-page token continues the same search. Keep the query consistent while paginating. The example deduplicates by place ID and returns a flag when its page cap leaves another token available.
A completed pagination loop does not establish every business in an area. Search coverage, relevance and API limits constrain the results. Google documents a maximum of 60 results across Text Search pages, subject to change; the example's own limit is smaller.
Review Google's Places API policies before storing, exporting or displaying returned content. Those policies restrict prefetching, caching and storage, with exceptions including place IDs, and specify attribution requirements. This example deliberately does not write names and addresses into a persistent CSV.
If your project needs a retained business-data export, inspect the selected provider's usage terms and your permitted use. Access through a data provider does not by itself establish unrestricted reuse rights.
Use an agent when the task needs custom list rules
For a research workflow with several areas or custom fields, connect Glasser and give your agent a bounded brief:
Find businesses matching my category and target area through Glasser.
Inspect the chosen Maps or places source, available fields,
collection limits, usage conditions and current price.
Agree on the maximum number of records and data budget first.
Preserve returned place IDs, business names, addresses and source URLs.
Keep websites and phone fields only when supplied.
Deduplicate place IDs while retaining separate branches.
Prepare the permitted output format and record the actual sample size.
The local-business data guide explains which fields belong at business and location level. Use the local business list workflow when the end goal is a geographically defined research list.
A file-capable agent can organize the selected source's permitted output. Your brief should specify how to handle missing websites, duplicate locations and businesses outside the target area.
Validate the workflow before expanding it
Inspect a few place matches manually and verify that the query area is correct. Confirm that branches remain distinct and that an unavailable phone or website is left missing.
If a request fails, check the enabled API, key restrictions, field mask and quota before repeating it. Preserve the error separately from a successful empty response.
This guide uses Google's official documentation checked November 20, 2026 and the Glasser catalog checked November 19, 2026. The Python example passed offline tests for pagination, deduplication, page caps and errors; no live Google or paid Glasser request was performed.
Does this export my saved Google Maps lists?
No. Places search retrieves a bounded set of place records for a query. Personal saved lists are a separate account-data task.
Does the Python example return every business?
It returns at most two pages of the selected search. Keep the actual count and remaining-page flag, and avoid describing the sample as a complete directory.
Related posts
View more
8 min read
Local Business Data: How to Build a List by City and Category
Build a list of local businesses for a chosen city and category. Compare data sources, follow a geographic query, and handle duplicate locations.

9 min read
Google Places API Pricing: How Much Will Your App Cost?
Estimate your Google Places API bill with worked examples for search, place details, photos, and Autocomplete. See how selected fields change the cost.

4 min read
How to Find a Business Owner and Check the Evidence
Match the right business, inspect public role evidence and distinguish owners from founders, executives and registered agents.
Make your agent
work with real data.
Search, inspect, and run data APIs through one Glasser key. Turn your next question into a result you can use.
Get started with Glasser