How to Generate an API Key for Google Maps API
Last updated
Last updated
Step 1: Create a Google Cloud Platform Project
Go to the .
Click on the project drop-down and select “New Project”.
Give your project a name and click on the “Create” button.
Step 2: Enable the Google Maps JavaScript API
In the Google Cloud Platform Console, select your project from the project drop-down.
In the left sidebar, click on “APIs & Services” and then “Library”.
Search for “Google Maps JavaScript API” and click on it.
Click on the “Enable” button to enable the API for your project.
Step 3: Create an API Key
In the left sidebar, click on “APIs & Services” and then “Credentials”.
Click on the “Create Credentials” button and select “API key” from the drop-down menu.
A new API key will be created. You can copy it and use it in your application.
Step 4: Restrict the API Key (Optional)
Restricting the API key adds an extra layer of security to prevent unauthorized use and billing. You can choose to restrict the API key based on the referrer URL or IP address.
In the API key creation window, click on the “Restrict key” button.
Under the “Application restrictions” section, select the desired restriction type.
To restrict by referrer URL, choose “HTTP referrers” and add the URLs from which your application will make requests.
To restrict by IP address, choose “IP addresses” and add the allowed IP addresses.
3. Under the “API restrictions” section, select “Maps JavaScript API”.
4. Click on the “Save” button to apply the restrictions.
Step 5: Use the API Key
Once you have generated the API key, you can start using it in your application. Depending on the library or framework you are using, you may need to add the API key to the respective configuration file or use it directly in your code.
NOTE: If you are using the Google Maps Platform for commercial purposes, you will need to add your credit card details to your API key in order to pay for the usage. The amount you pay will depend on the number of requests you make and the type of APIs you use.
You can find more information about Google Maps Platform pricing here: