Follow these steps to get an API key:
- Go to the Google Cloud Platform Console.
- Create or select a project.
- Click Continue to enable the API.
- On the Credentials page, get an API key.
Note: If you have an existing unrestricted API key or a key with browser restrictions, you may use that key.
- From the dialog displaying the API key, select Restrict key to set a browser restriction on the API key.
- In the Key restriction section, select HTTP referrers (websites), then follow the on-screen instructions to set referrers, then click Save. Read more about restricting API keys.
For more information on using the Google Cloud Platform Console, see Google Cloud Platform Console Help.
Restricting an API key:
Google Maps Platform APIs are available for web browsers, Android or iOS apps, and via HTTP web services. APIs in any platform can use a generic (unrestricted) API key. You can optionally add a restriction (for example, HTTP referrer) to the API key. Once restricted, a key will only work on platforms that support that type of restriction.
Tip: Before moving your app or website to production, you should secure your API key. Keys for the Maps Embed API use the HTTP referrers (websites) key restriction. Learn more about keys and credentials.
To add web browser restrictions to an existing, generic API key, do the following:
- Go to the Credentials page of the Google Cloud Platform Console.
- Select the project that contains the API key you want to edit.
- On the Credentials page, from the list of API keys, select the name of the API key to edit the details of the key.
- In the Key restriction section of the page, select HTTP referrers (websites), follow the on-screen instructions to set referrers, then click Save.