Scrape data in seconds

No proxies needed

Start Free
Web Scraping

How to Get a Google Maps API Key and Restrict It

Create a Google Maps Platform API key, pick the right restriction for websites, servers and apps, test it with a Places call and fix the usual errors, plus a no-key option for business listings.

VK
Varun Kumar
··10 min read
How to Get a Google Maps API Key and Restrict It: Pulldata blog cover

A Google Maps API key is the string that lets your app or script call Google Maps Platform, and getting one takes a Google Cloud project, a billing account and a few settings. The hard part is the restrictions, because an unrestricted key works everywhere, including for anyone who copies it.

The right key keeps your map bill sane.

Pulldata is a no-code web data platform that collects live, structured data from the public web. If you need business listings rather than a map on a page, the Pulldata Google Maps API returns them as JSON with one Pulldata key, and you pay only for results that come back, free to start.

How do you get a Google Maps API key?

To get a Google Maps API key, create or pick a Google Cloud project, link a billing account, enable the Maps APIs you need, then create a key on the Credentials page and restrict it. Google says you must have a billing-enabled Cloud project and the right APIs enabled before you can use Google Maps Platform (Google Maps Platform, Get started).

The key itself is simple. Google describes it as a unique identifier that authenticates requests associated with your project for usage and billing, so every call made with it lands on your project's bill.

One API key used for map loads, Places searches and geocoding calls, with every request flowing into the same project bill

That billing link is why the restriction step matters more than the creation step. A key pasted into a public web page can be read by anyone who views the page source.

What You Need Before You Start

You need a Google account, a payment method for the billing account and a clear idea of where the key will be used. Five minutes of planning here saves you from rebuilding keys later.

  • A Google account that can create projects in the Google Cloud console.
  • A credit card or other payment method for a billing account.
  • The list of Maps APIs you'll call, such as Maps JavaScript API for a web map or Places API for business search.
  • Where the key runs: a website, a server, an Android app or an iOS app.
  • For websites, the exact domains that will load the map, including staging.
  • For servers, the public IP addresses your requests come from.

Google Maps Platform bills per request, with prices and free usage set per product. The costs are laid out in our guide to Google Maps API cost, and Google's own numbers are on its pricing page.

Step-by-Step: Create and Restrict a Google Maps API Key

These steps follow Google's documented flow in the Cloud console. Menu names can shift a little over time, so if a label differs, look for the closest match.

Step #1: Create or pick a Google Cloud project

Open the Google Cloud console and use the project picker at the top to create a new project or select an existing one. Give it a name you'll recognise later, since keys, billing and usage reports all live under the project.

One project per app is the tidy choice. It keeps usage, quotas and bills separate when you have more than one site or product.

Stacked bill bar split into website, mobile app and data script usage, each project with its own API key, example values

Go to Billing in the console and link the project to a billing account, creating one if you don't have it. Without billing, Google's error documentation says maps can load darkened with a "for development purposes only" watermark (Maps JavaScript API error messages).

Set a budget alert while you're on the billing page. Google Cloud's budgets and alerts send an email when spend passes a threshold you choose.

Example spend curve where a budget alert emails you at the threshold but spend keeps rising, while a quota caps usage
Worth knowing

A budget alert warns you but doesn't stop spending. To hard-limit usage, also set quotas on each API in the console, so a leaked key or a runaway loop can only make a set number of calls per day.

Step #3: Enable the APIs you'll call

Open the Maps API Library in the console and enable each API or SDK your app uses, such as Maps JavaScript API, Places API or Geocoding API. Google's get-started page also shows the gcloud services enable command for doing this from a terminal.

Only enable what you need. Every enabled API is one more thing a leaked key could be used for, unless you restrict it in Step #5.

A leaked API key can reach every enabled Maps API, such as Maps JavaScript, Places and Geocoding, but not the APIs left off

Step #4: Create the API key

Go to APIs & Services, then Credentials, click "Create credentials" and choose API key. The console shows the new key in a dialog, and the Credentials list gives it a generic name you can change.

Rename it to something that says where it's used, such as "website map, production". Six months from now, that name tells you which key you can safely delete.

Step #5: Restrict the key

Open the key's settings and add one application restriction and one or more API restrictions. Google's security guidance recommends always restricting keys this way, with application restrictions for websites, IP addresses, Android apps or iOS apps (Google Maps Platform security guidance).

Application restrictions decide who can use the key. API restrictions decide what the key can call, so a key meant for a web map can't be used against Places or Geocoding.

A key passes an application restriction for who (domain, IP or app ID) and an API restriction for what before a call runs

Step #6: Test the key

Test a server-side key with a small request before you build on it. This Places API (New) Text Search call follows the pattern in Google's Text Search docs:

curl
curl -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-Goog-Api-Key: YOUR_API_KEY' \
  -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress' \
  -d '{"textQuery": "coffee shops in Austin, TX"}' \
  'https://places.googleapis.com/v1/places:searchText'

The X-Goog-FieldMask header is required for Places API (New), and Google's field mask docs say the call returns an error without it. Ask only for the fields you use, because the fields you request decide the price tier of the call.

A field mask picks displayName and formattedAddress from a full Places record, so the response holds only those two fields

For a website key, load a page with the Maps JavaScript API on an allowed domain and open the browser console. Google's docs say that if you only see warnings and no errors, the API works on that page.

Which restriction fits where the key runs?

The right application restriction depends on where the key is used: websites use referrer restrictions, servers use IP addresses, and mobile apps use their package or bundle IDs. Google advises a separate key for each application, so each one can carry the restriction that fits it.

Where the key runs

Application restriction

Typical APIs

Website (browser)

Websites, listing each allowed domain

Maps JavaScript API, Places in the browser

Your server or script

IP addresses of your servers

Places API, Geocoding API, Routes

Android app

Android apps, with package name and certificate fingerprint

Maps SDK for Android

iOS app

iOS apps, with bundle identifier

Maps SDK for iOS

Server keys are the ones people get wrong most often, because a referrer restriction does nothing for a request sent from a script. Google's guidance notes that server-side keys may need IP address restrictions to be properly restricted.

Browser requests carry a Referer header the referrer check can use, while server script requests have none and need IP checks

If your script runs from a laptop or a service with changing IPs, an IP restriction is hard to keep up to date. In that case, lean on API restrictions and quotas, and keep the key out of any code you share.

Variations: Web, Server and No-Key Options

Most people need one of three setups. The steps above cover all of them; what changes is the restriction, the APIs and whether you need a Google key at all.

A key for a map on your website

Restrict the key to your domains, with a wildcard if you use subdomains, and restrict it to Maps JavaScript API plus any browser-side APIs you load. Add your staging domain too, or the map will fail there with a referrer error.

The key will be visible in your page source, and that's expected for browser keys. The restriction is what makes a visible key safe enough to publish.

A browser key visible in page source loads the map on yoursite.com but is blocked when someone copies it to another site

A key for a server or script

Use a separate key, restricted by IP address and to the web service APIs you call, such as Places API (New) or Geocoding API. Store it in an environment variable or a secret manager, never in the repository.

If the script collects business listings in bulk, check the Places API caps and terms first. Our guide to Google Maps scraper limits covers the caps that shape bulk pulls.

Business listings without a Google key: the Pulldata API

If what you need is lists of businesses, such as names, phones, websites and ratings, the Pulldata Google Maps API returns them without a Cloud project or Places billing. You create a free account on the public sign-up page, with Google or an email and password, then copy an API key from the dashboard.

This request is copied from Pulldata's API page:

curl
curl -X POST https://pdb.pulldata.io/v1/google-maps/search/results \
  -H "Authorization: Bearer pd_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "categories": ["plumbers", "electricians"],
    "locations": ["Austin, TX", "Dallas, TX"],
    "max_leads_per_query": 50,
    "scrape_emails": true
  }'

The API page lists max_leads_per_query as the most leads per query and location pair, up to 1,000. You pay only for rows that come back, and Pulldata pricing shows the current rate.

Google Places needs five setup steps on a winding path to rows, while the Pulldata API reaches the same rows after two steps

Prefer no code at all? The same data comes from the Google Maps leads tool in the dashboard, and our guide on how to scrape Google Maps walks through it step by step.

Keep in mind

Google's key is for Google's APIs and Pulldata's key is for Pulldata's, so they never swap. If a project uses both, name them clearly in your environment variables, such as GOOGLE_MAPS_KEY and PULLDATA_API_KEY.

Troubleshooting Google Maps API Key Errors

Most key errors come from four causes: the API isn't enabled, billing isn't set up, the restriction doesn't match, or the key is wrong. Google's Maps JavaScript API error page names each one, so start with the exact error text in your browser console.

  • ApiNotActivatedMapError: the API isn't enabled for the project. Enable it in the API Library and reload.
  • BillingNotEnabledMapError: the project has no active billing. Link a billing account and check the payment method is valid.
  • RefererNotAllowedMapError: the page's URL isn't on the key's allowed list. Add the exact domain, including any subdomain or staging host.
  • InvalidKeyMapError: the key is missing or wrong. Copy it again from the Credentials page and check for spaces.
  • "For development purposes only" watermark: usually billing or key trouble. Fix billing first, then clear your cache, since old tiles can linger.
  • Server call returns a permission error: the key may have a website restriction. Server keys need an IP restriction or none, plus the right API restriction.

Restrictions can take a few minutes to apply after you save them. Wait before deciding a change didn't work, then test again.

Browser console showing four Maps JavaScript API errors, each linked by a curve to the setting that fixes it
Quick check

Before adding restrictions to a key that's already live, open its usage graph in the console. Google recommends checking usage first, because a restriction that blocks a forgotten app will break it the moment you save.

How do you keep a Google Maps API key safe?

Keep a Google Maps API key safe by restricting it, giving each app its own key, keeping server keys out of code and rotating any key that may have leaked. A restricted key that leaks is a nuisance; an unrestricted one is a bill.

Watch for keys in places people forget: public repositories, mobile app bundles, screenshots in support tickets and shared spreadsheets. If a key shows up somewhere it shouldn't, create a replacement, update your apps, then delete the old one.

Collecting Maps data has rules beyond the key, from Google's terms to privacy law. Our post on whether you can scrape Google Maps covers that side, and the Google Maps MCP guide shows how keys are handled when an AI agent makes the calls.

Good habit

Keep a short list of every key, what it's restricted to and which app uses it. When something breaks or leaks, that list turns an afternoon of guessing into a five-minute fix.

Google Maps API Key FAQ

Is a Google Maps API key free?

Creating the key is free, but using it needs a billing account. Google bills per request, with free usage set per product, so check Google's pricing page for the current numbers.

Can I use a Google Maps API key without a credit card?

Not for normal use. Google requires a billing-enabled Cloud project before Google Maps Platform APIs work, and billing needs a payment method.

How many API keys can I create?

You can create several keys in one project, and Google recommends a separate key for each app. That way one leaked or restricted key doesn't affect the others.

Is it safe to put my Maps API key in website code?

Browser keys are always visible in page source. That's acceptable only when the key is restricted to your domains and to the browser APIs you use.

Why does my map say "for development purposes only"?

Usually billing isn't enabled, the payment method failed, or the key is wrong or blocked by its restriction. Check billing first, then the key's restrictions and enabled APIs.

Disclaimer: This article is general information about creating and securing Google Maps Platform API keys. Google's console, pricing and terms can change, so follow Google's current documentation, and make sure your use of any Maps data follows Google's terms and the laws that apply to you.

Share this article
V

Written by

Varun Kumar

Varun Kumar is co-founder of Pulldata, where he leads the data infrastructure behind its products. A backend engineer by training, he has spent 8 years building large-scale scraping and automation systems, and now oversees how Pulldata extracts, validates and delivers web data at scale.

FAQ

Frequently asked questions

Everything you need to know about extracting web data, proxy management, and zero-cost failed rows.

Explore Documentation

Where can I extract public web data from with PullData?

PullData provides ready-to-use scrapers for Google Maps, Google Search SERP, directory listings, company websites, and social platforms, with built-in proxy rotation and automated anti-bot bypass.

Do I need coding skills or proxies to collect data?

No coding or proxy management is required. Everything runs in the cloud. You only configure your target keywords or URLs, and PullData handles rate limits, proxy rotation, and CAPTCHAs automatically.

In what file formats can I download extracted data?

You can export datasets instantly into CSV, Microsoft Excel (XLSX), or JSON. You can also connect directly via Webhook or REST API to sync rows with your database or CRM.

What happens if a scraping job encounters failed rows?

PullData only charges for successfully scraped and verified rows. Any failed row or timeout costs 0 credits, ensuring you only pay for actionable data.

Get Started Free

Ready to extract web data?

No code, no proxies, no engineering overhead. Start with $10 free credits and collect clean public data instantly.

Instant Cloud Setup $10 Free Credits Included Failed Rows Cost $0
Weekly Digest

Get weekly data-extraction insights

One short email a week — new guides, scraper tips, and the occasional teardown. No spam, unsubscribe anytime.