Validate postal address with the new Google Maps Address Validation API and Apps Script

Stéphane Giron
2 min readDec 7, 2022

--

When you have lots of address or if you want to send a packet to someone it is better to be sure the address exists :-)

Google just realeased a new API to validate your addresses, read announcement. You can validate each component of the address and get a well formated address. Additionally you also get the geocoding details and the Plus code of Google Maps.

onleeaddress can validate postal addresses from Gmail or in bulk with Google Sheets

The validation is not in the built in Maps service so we need to use UrlFetchApp.

NEW February 2023, you can now extract Google Maps data with onleeaddress. Retrieve leads and business information from Google Maps.

Get your API key

To use the Google Maps API you need an API Key, it is mandatory so first create a GCP Project and then your API Key. Google MAps is not a free API each request has a cost that is why you need a GCP project with a billing account setup.

Reference : create google maps api key

Validate your address with Address Validation API

Check the reference site if needed : link.

function validateAddress() {
const addr = "8 Pl. de Fourvière, 69005 Lyon";
const API_KEY = "";
const url = "https://addressvalidation.googleapis.com/v1:validateAddress?key="+API_KEY ;
const options = {
'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify({"address": {
"addressLines": [addr]
}})
};
const rep = UrlFetchApp.fetch(url, options);
console.log(rep.getContentText())
}

In response you get a validation result : link

Most interesting is the formated address and the confirmation of each component of the address. Google Maps will confirm if the number or street or city are valid, really convenient.

onleeaddress makes it simple to validate addresses

I made onleeadress to ease validation address, you can validate address from Gmail or in bulk from Google Sheets.

If you want to validate a list of adresses you can do that in bulk with onleeaddress Google Sheet add-on.

Bulk validate postal addresses with Google Sheets

If you want to get instant address validation when you receive an email you can do that with onleeaddress Gmail add-on.

Validate Postal Address in Gmail

You can try onleeaddress with a free quota of 20 addresses, then you need to buy more quota to validate new addresses.

Install onleeaddress : link

--

--