> ## Content Index
> Fetch the complete content index at: https://blog.afi.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# A practical guide to the Google Geocoding API
- URL: https://blog.afi.io/blog/a-practical-guide-to-the-google-geocoding-api/
- Published: 2025-07-14T01:58:17.000Z
- Updated: 2026-08-21T05:16:12.000Z
- Description: Use the Geocoding API for forward and reverse geocoding, address validation, and displaying building outlines and entrances.
- Author: Afian Anwar
- Tags: googlemaps

In this tutorial series, we are going to take a deep dive into Google Map's second most popular\* API, the [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/overview?ref=blog.afi.io). I'll explain what its used for, go through several worked examples and end each blog post with a working demo and source code that you can use in your own projects. We’ll also look at two related APIs: the [Address Validation API](https://developers.google.com/maps/documentation/address-validation/overview?ref=blog.afi.io), which helps identify and correct bad addresses, and [Building Outlines and Entrances](https://developers.google.com/maps/documentation/geocoding/building-attributes?ref=blog.afi.io), which allows you to display a building’s footprint and entrances on a map.

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/3D-Map.png)

**Part 1: A practical guide to the Google Geocoding API (this article)**  
Part 2: [Forward geocoding with the Google Geocoding API](https://www.afi.io/blog/forward-geocoding-with-the-google-geocoding-api/?ref=blog.afi.io)  
Part 3: [Google Maps reverse geocoding: Get addresses from coordinates](https://blog.afi.io/blog/google-reverse-geocoding-get-addresses-from-coordinates/)  
Part 4: [Fix bad addresses with the Google Address Validation API](https://blog.afi.io/blog/fix-bad-addresses-with-the-google-address-validation-api/)  
Part 5: [Google Maps Building Outlines and Entrances API](https://blog.afi.io/blog/google-maps-building-outlines-and-entrances-api/)

\* The #1 Google Maps API is of course the [Maps Javascript API](https://developers.google.com/maps/documentation/javascript/overview?ref=blog.afi.io), which is used to render map tiles on the web.

[Google Forward Geocoding DemoHow to use the Google Geocoding API to convert address strings into geographic coordinates![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/icon/logo192-32.png)![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/thumbnail/logo512-37.png)](https://google-forward-geocoding.afi.dev/?ref=blog.afi.io)

[Google Reverse Geocoding DemoHow to use the Google Geocoding API to convert geographic coordinates into addresses![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/icon/logo192-33.png)![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/thumbnail/logo512-38.png)](https://google-reverse-geocoding.afi.dev/?ref=blog.afi.io)

[Google Maps Building Outlines and Entrances DemoHow to use the Google Maps Geocoding API to display building outlines and entrances![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/icon/logo192-37.png)![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/thumbnail/logo512-42.png)](https://building-outlines-and-entrances-demo.afi.dev/?ref=blog.afi.io)

### What is the Google Geocoding API?

The [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/overview?ref=blog.afi.io) is a web service that converts addresses - like "555 West Hastings Street, Vancouver BC, Canada", into geographic coordinates such as (49.2846966, -123.11258). It also supports the reverse process, turning latitude and longitude coordinates into human readable addresses or place names from the Google Maps database.

You can try this yourself on Google Maps ([https://www.google.com/maps](https://www.google.com/maps?ref=blog.afi.io)) by entering an address in the search bar and noting the latitude and longitude that appear in the URL. This process is called *forward geocoding* (or geocoding for short).

![Using the Google Maps app on the web for geocoding](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-3.png)

Using the Google Maps app on the web for geocoding

Reverse geocoding does the opposite - it converts a geographic location into a human readable address. To try it on Google Maps, click and hold anywhere on the map until a small marker appears. The address will then show up in a pop-up window at the bottom of the screen.

![Using the Google Maps app on the web for reverse geocoding](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-4.png)

Using the Google Maps app on the web for reverse geocoding

Of the two, forward geocoding (address 👉 coordinates) is generally more popular because it often is the first step in turning real world addresses into usable data for navigation, planning, and analytics.

### What is geocoding used for?

Geocoding is essential when you need to display an address on a map or provide location data to an API. Many APIs, such as the [Google Weather API](https://developers.google.com/maps/documentation/weather?hl=en&ref=blog.afi.io) or the [Google Maps Route Optimization API](https://developers.google.com/maps/documentation/route-optimization?ref=blog.afi.io) (GMPRO), require GPS coordinates as input. For example, a delivery management tool might use forward geocoding to convert customer addresses into precise coordinates before sending them to GMPRO to generate optimized delivery routes.

![Geocoding converts addresses into coordinates, which can be used in different APIs](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-5.png)

Geocoding converts addresses into coordinates, which can be used in different APIs

Reverse address geocoding on the other hand, is used to convert GPS coordinates into readable location names for various applications such as location based services (e.g. weather apps displaying your current area), asset tracking (e.g. Apple’s [FindMy app](https://www.apple.com/icloud/find-my/?ref=blog.afi.io) showing where you left your AirTags), and geotagging (e.g. social media platforms tagging photos with specific locations for easier discovery and context).

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/Screen-Shot-2024-03-26-at-12.58.41-PM.png)

Reverse geocoding used for (A) location aware apps, (B) asset tagging and (C) social media

### What's the difference between the Google Geocoding API and Autocomplete?

Both the [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/overview?ref=blog.afi.io) and [Places Autocomplete](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete?ref=blog.afi.io) return the latitude and longitude for a given address. However, they serve different purposes: the Geocoding API is ideal for processing address text strings stored in a file or database, while Autocomplete is designed for user input - helping users select the correct address or place name from a searchable list. For example, a delivery management system might use the Geocoding API to process a batch of uploaded addresses, whereas an e-commerce site would use Autocomplete to guide customers in entering their delivery address during checkout.

![The difference between Google geocoding and address autocomplete](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/Screenshot-2025-07-14-at-9.13.04---AM.png)

The difference between Google geocoding and address autocomplete

### How to get a Google Geocoding API key​

To begin using the Geocoding API, you first need to set it up in the Google Cloud Console. Create a new project at [https://console.cloud.google.com/](https://console.cloud.google.com/?ref=blog.afi.io) and name the project `geocoding-api-demo`. Click \[CREATE\].

![Starting a new GCP project to test the Geocoding API](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-6.png)

Starting a new GCP project to test the Geocoding API

To enable the Geocoding API, navigate to the APIs & Services page by selecting it from the menu on the left. Then, click \[+ Enable APIs and Services\] and search for "Geocoding API".

![Searching for the Geocoding API on the GCP Console](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/Screenshot-2025-07-11-at-5.21.21---PM.png)

Searching for the Geocoding API on the GCP Console

Click on the \[Geocoding API\] link and hit the \[Enable\] button.

![Enabling the Google Maps Geocoding API on your GCP Console](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-7.png)

Enabling the Google Maps Geocoding API on your GCP Console

Click \[Save\]. If you return to the Keys and Credentials page, you can find your new API key by clicking the \[Show Key\] link on the right.

![Retrieving your Geocoding API enabled API key from the GCP Console](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/image-8.png)

Retrieving your Geocoding API enabled API key from the GCP Console

### Google Geocoding API examples

The Geocoding API is easy enough to use. Once you have an API key, replace {GOOGLE\_MAPS\_API\_KEY} with it in the examples below, copy the full URL, and paste it into your browser’s address bar. Press \[Enter\], and the response will appear directly in your browser.

**Forward geocoding request**

Method: `GET`

```
https://maps.googleapis.com/maps/api/geocode/json?address=555+west+hastings+street+vancouver&key={GOOGLE_MAPS_API_KEY}
```

**Response**

![The response to a typical Geocoding API request is a geocoded address with coordinates](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/Screenshot-2025-07-12-at-1.37.10---PM.png)

The response to a typical geocodingrequest is a geocoded address with coordinates

[forward\_geocoding\_responseforward\_geocoding\_response.json3 KBdownload-circle](https://blog.afi.io/content/files/2025/07/forward%5Fgeocoding%5Fresponse.json "Download")

**Reverse geocoding request**

Method: `GET`

```
https://maps.googleapis.com/maps/api/geocode/json?latlng=49.2846966,-123.1119349&key={GOOGLE_MAPS_API_KEY}
```

**Response**

![The response to a reverse geocoding request is an address or place name](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2025/07/Screenshot-2025-07-12-at-1.51.59---PM.png)

The response to a reverse geocoding request is an address or place name

[reverse\_geocoding\_responsereverse\_geocoding\_response.json37 KBdownload-circle](https://blog.afi.io/content/files/2025/07/reverse%5Fgeocoding%5Fresponse.json "Download")

### Is the Google Geocoding API free?

No, the Geocoding API is not completely free. Pricing starts at $5 per 1,000 addresses geocoded (CPM). However, Google offers a generous free tier that includes 10,000 geocoded addresses per month enough to support most mid-sized delivery operations without incurring any charges.

### Google Geocoding API pricing

Like other Google Maps Platform APIs, the Geocoding API uses a pay-as-you-go pricing model. Customers are billed based on the number of addresses sent to the API. The first 10,000 addresses each month are free, and beyond that, the cost per 1,000 addresses (CPM) depends on the total monthly volume.

| **0 - 10k**   | **10k - 100k** | **100k - 500k** | **500k - 1M** | **1M - 5M** | **5M+** |       |
| ------------- | -------------- | --------------- | ------------- | ----------- | ------- | ----- |
| Geocoding API | FREE           | $5.00           | $4.00         | $3.00       | $1.50   | $0.38 |

If you are dealing with high usage volumes, you can work with a [Google Maps partner](https://cloud.google.com/find-a-partner/?products=Google+Maps+Platform&ref=blog.afi.io) for volume discounts. See the [official pricing page](https://mapsplatform.google.com/pricing/?ref=blog.afi.io) for details.

### Can I cache Google Maps geocoding data?

Officially, no. The [Google Maps Terms of Service](https://cloud.google.com/maps-platform/terms/maps-service-terms?hl=en&ref=blog.afi.io) clearly states:

> 5.3 Caching. Customer may temporarily cache latitude (lat) and longitude (lng) values from the Geocoding API for up to 30 consecutive calendar days, after which Customer must delete the cached latitude and longitude values.

But in practice everyone does it anyway and there's no way for Google to enforce this rule. A popular way to reduce geocoding costs is by first checking if the address has been "seen". If it has, reuse the stored latitude and longitude. If it's a new address, geocode it once and save both the address and its coordinates to a database for future use.

### Google Geocoding API alternative

If you're considering alternatives to the Google Maps Geocoding API, several competing services such as [Mapbox](https://www.mapbox.com/geocoding?ref=blog.afi.io), [HERE Maps](https://www.here.com/platform/geocoding?ref=blog.afi.io) or [Tom Tom](https://developer.tomtom.com/geocoding-api/documentation/product-information/introduction?ref=blog.afi.io) offer solid options at a lower cost. For example, Mapbox's paid tier starts at just $0.75 per 1,000 requests (CPM) and includes 100,000 free geocodes per month. However, Google remains the top choice for many due to the superior accuracy and freshness of its address data. For last mile logistics businesses operating on tight margins, the cost of a failed delivery due to an incorrect address can far outweigh the $0.005 it costs to get accurate geocoding from Google.

🌐

Want to host your own geocoder for free? See [Building a free geocoding and reverse geocoding service with OpenStreetMap](https://www.afi.io/blog/building-a-free-geocoding-and-reverse-geocoding-service-with-openstreetmap?ref=blog.afi.io).

### What you'll learn in this tutorial series

The Google Geocoding API is a mainstay of the Google Maps Platform. By the end of this tutorial series, you'll be able to:

1. [Convert any address into its latitude and longitude](https://www.afi.io/blog/forward-geocoding-with-the-google-geocoding-api?ref=blog.afi.io),
2. [Reverse geocode](https://blog.afi.io/blog/google-reverse-geocoding-get-addresses-from-coordinates/) GPS coordinates into human-readable addresses and place names,
3. Use the Google Address Validation API to [check if an address is deliverable](https://blog.afi.io/blog/fix-bad-addresses-with-the-google-address-validation-api/) and,
4. [Display building outlines and mark entrances on a map](https://blog.afi.io/blog/google-maps-building-outlines-and-entrances-api/)

**This article was written by** [**Afi Labs**](https://afi.io/?ref=blog.afi.io)**, a** [**Google Maps Premier Partner**](https://www.afi.io/?ref=blog.afi.io) **and reseller. We build route optimization, navigation, and fleet tracking software on Google Maps, and offer volume pricing on GMP licensing.** [**Talk to an engineer**](https://www.afi.io/contact%5Fus?ref=blog.afi.io) **or** [**follow Afian on LinkedIn**](https://www.linkedin.com/in/afian-anwar/?ref=blog.afi.io)**.**

Next: [Part 2: Forward geocoding with the Google Geocoding API](https://www.afi.io/blog/forward-geocoding-with-the-google-geocoding-api/?ref=blog.afi.io)