**European Economic Area (EEA) developers**

> [!NOTE]
> If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](https://developers.google.com/maps/comms/eea/faq.md.txt).

This document describes the steps you need to start using the Address Validation API.

## Prerequisites

This procedure guides you through setting up a Google Cloud Account and
Google Cloud project with billing enabled.


You should also be familiar with how you are charged for using the Address Validation API.

1. **Review** billing and cost for usage at [Address Validation API Usage and Billing](https://developers.google.com/maps/documentation/address-validation/usage-and-billing.md.txt).
2. **Verify** that you have a
   [Google Cloud Account](https://support.google.com/accounts/answer/15277265).

   [Sign in to the Google Cloud console](https://console.cloud.google.com/google/maps-apis/overview?utm_source=Docs_SignIn&utm_content=Docs_addressvalidation&ref=/maps/documentation/address-validation/get-api-key)

   > [!NOTE]
   > **Note:** If you are a new user and don't have a Google Cloud Account, meaning you cannot sign in to the console, see [Getting started with Google Maps Platform](https://developers.google.com/maps/get-started.md.txt).

3. **Verify** that you have a
   [Google Cloud project](https://cloud.google.com/apis/docs/getting-started#creating_a_google_project)
   with billing enabled.

   [Go to the Billing page](https://console.cloud.google.com/projectselector/billing?utm_source=Docs_Billing&utm_content=Docs_addressvalidation&ref=/maps/documentation/address-validation/get-api-key)

   > [!NOTE]
   > **Note:** If you are a new user and don't have a Google Cloud project, see [Getting started with Google Maps Platform](https://developers.google.com/maps/get-started.md.txt).

   1. Select your project to open the **Billing** page.
   2. On the **Billing** page:

      - If billing is already enabled for the selected project, and you only have a single billing account, then the **Billing** page opens.
      - If you have multiple billing accounts, select **Go to linked billing account** to see the details about the billing account associated with the project.
      - If a billing account exists but is not associated with the project, you are prompted to link a billing account with the project.
      - If no billing account exists, or you want to create a new billing a account, select **Manage Billing Accounts** to create a new billing account. For more information, see [Create a new self-serve Cloud Billing account](https://cloud.google.com/billing/docs/how-to/create-billing-account).

## Enable the API

Before you can use Address Validation API, you must use the Google Cloud console or the
[`gcloud`](https://cloud.google.com/sdk) command to enable
it in your Google Cloud project.

> [!NOTE]
> **Note:**After you enable an API you might have to wait a few minutes before you can make a request to it.

To enable the API:

### Console

1. Open the product page in the Google Cloud console:

   [Enable the Address Validation API](https://console.cloud.google.com/apis/library/addressvalidation.googleapis.com?utm_source=Docs_EnableAPIs&utm_content=Docs_addressvalidation&ref=/maps/documentation/address-validation/get-api-key)
2. Click the **Enable** button.

   > [!NOTE]
   > **Note:** If the API is already enabled, you see the **Manage** button instead of **Enable**.

### gcloud

```bash
gcloud services enable \
    --project "PROJECT" \
    "addressvalidation.googleapis.com"
```

Read more about the [Google Cloud SDK](https://cloud.google.com/sdk), [Cloud SDK installation](https://cloud.google.com/sdk/docs/install), and the following commands:

- [`gcloud services enable`](https://cloud.google.com/sdk/gcloud/reference/services/enable)
- [`gcloud services disable`](https://cloud.google.com/sdk/gcloud/reference/services/disable)

## Get an API key for use with Address Validation API

> [!IMPORTANT]
> **Key Point:** This setup guide includes the procedure for both **configuring an API key** and **creating an OAuth token**. Choose the procedure that is applicable for your deployment environment.

Google Maps Platform products are secured from unauthorized use by requiring API calls to
include **either** an **API key** or **OAuth token** .
The API key procedure comes first. To use an OAuth token instead, see
[Create an OAuth token](https://developers.google.com/maps/documentation/address-validation/get-api-key.md.txt#create-an-oauth-token).

An [API key](https://cloud.google.com/docs/authentication/api-keys) is a unique alphanumeric string that associates your Cloud Billing account and Google Cloud project with the request your application makes to a Google Maps Platform API or SDK. To create a new key or add an API or SDK to an existing key, follow these instructions.

### Console

1. Go to the **Google Maps Platform \> Keys \& Credentials**
   page.

   [Go to the Keys \&
   Credentials page](https://console.cloud.google.com/projectselector/google/maps-apis/credentials?utm_source=Docs_ManageAPIKey&utm_content=Docs_addressvalidation&ref=/maps/documentation/address-validation/get-api-key)
2. If prompted, select your project.
3. Do one of the following:

   - **Create a new key**:

     1. Click **Create credentials \> API key**.
     2. In the **Create API key** panel, open the **Select API restrictions** list.
     3. Clear any APIs that this key doesn't need, and make sure **Address Validation API** stays selected.
     4. Click **Create**. The panel displays your new API key.
   - **Use an existing key**:

     1. Click the name of the key.
     2. In the **Select API restrictions** list, select **Address Validation API**.
     3. Click **Save**.

   Selecting an API here doesn't enable it. Make sure
   Address Validation API is enabled on its
   [API Library page](https://console.cloud.google.com/apis/library/addressvalidation.googleapis.com).
4. To see the key string later, go to the **Keys \& Credentials** page and click **Show key** for the key.

If the console looks different from these steps, see
[Create an API key](https://cloud.google.com/docs/authentication/api-keys#create) and
[Add API restrictions](https://cloud.google.com/docs/authentication/api-keys#adding-api-restrictions) in the Google Cloud documentation.

### gcloud

Replace <var translate="no">PROJECT_ID</var> with your project ID in the following
commands.

- **Create a new key** : Run the following command, and
  replace <var translate="no">DISPLAY_NAME</var> with a name for the key.

  ```bash
  gcloud services api-keys create \
      --project="PROJECT_ID" \
      --display-name="DISPLAY_NAME" \
      --api-target=service=addressvalidation.googleapis.com
  ```

  Read more about the [Google Cloud SDK](https://cloud.google.com/sdk), [Cloud SDK installation](https://cloud.google.com/sdk/docs/install), and the following commands:
  - [`gcloud services api-keys create`](https://cloud.google.com/sdk/gcloud/reference/services/api-keys/create)
- **Use an existing key** : Run the following command, and
  replace <var translate="no">KEY_ID</var> with the ID of the key.
  The `--append` flag keeps
  the APIs that the key already allows. Without it, the command replaces
  them.

  ```bash
  gcloud services api-keys update KEY_ID \
      --project="PROJECT_ID" \
      --append \
      --api-target=service=addressvalidation.googleapis.com
  ```

  Read more about the [Google Cloud SDK](https://cloud.google.com/sdk), [Cloud SDK installation](https://cloud.google.com/sdk/docs/install), and the following commands:
  - [`gcloud services api-keys update`](https://cloud.google.com/sdk/gcloud/reference/services/api-keys/update)
  - [`gcloud services api-keys list`](https://cloud.google.com/sdk/gcloud/reference/services/api-keys/list)

  The key ID isn't the key string or display name. To find it, run
  `gcloud services api-keys list --project="PROJECT_ID"`.
  The ID is the last part of
  the `name` field:
  `projects/PROJECT_NUMBER/locations/global/keys/KEY_ID`.

To see the key string, run
`gcloud services api-keys get-key-string KEY_ID
--project="PROJECT_ID"`.

## Make an API request

Make a Address Validation API request to return a JSON response for validating the address
"1600 Amphitheatre Parkway, Mountain View, CA". You must include your API key's alphanumeric string
with every request and use HTTPS for requests that include the API key.

1. Click <var translate="no">API_KEY</var> in the code below to insert the key's alphanumeric string:

   ```
   curl -X POST -d '{
     "address": {
       "regionCode": "US",
       "locality": "Mountain View",
       "addressLines": ["1600 Amphitheatre Pkwy"]
     }
   }' \
   -H 'Content-Type: application/json' \
   "https://addressvalidation.googleapis.com/v1:validateAddress?key=API_KEY"
   ```
2. Click the copy icon in the code sample, ![Select the copy icon.](https://developers.google.com/static/maps/documentation/images/copy-icon.png), to copy the `curl` command.
3. Paste the command in a terminal window and run the command.

The response is a JSON object in the form:

```json
{
  "result": {
    "verdict": {
      "inputGranularity": "PREMISE",
      "validationGranularity": "PREMISE",
      "geocodeGranularity": "PREMISE",
      "addressComplete": true,
      "hasInferredComponents": true
    },
    "address": {
      "formattedAddress": "1600 Amphitheatre Parkway, Mountain View, CA 94043-1351, USA",
      "postalAddress": {
        "regionCode": "US",
        "languageCode": "en",
        "postalCode": "94043-1351",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "1600 Amphitheatre Pkwy"
        ]
      },
      "addressComponents": [
        {
          "componentName": {
            "text": "1600"
          },
          "componentType": "street_number",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "Amphitheatre Parkway",
            "languageCode": "en"
          },
          "componentType": "route",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "Mountain View",
            "languageCode": "en"
          },
          "componentType": "locality",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "USA",
            "languageCode": "en"
          },
          "componentType": "country",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "94043"
          },
          "componentType": "postal_code",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        },
        {
          "componentName": {
            "text": "CA",
            "languageCode": "en"
          },
          "componentType": "administrative_area_level_1",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        },
        {
          "componentName": {
            "text": "1351"
          },
          "componentType": "postal_code_suffix",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        }
      ]
    },
    "geocode": {
      "location": {
        "latitude": 37.4225022,
        "longitude": -122.0847398
      },
      "plusCode": {
        "globalCode": "849VCWF8+24"
      },
      "bounds": {
        "low": {
          "latitude": 37.4225022,
          "longitude": -122.0847398
        },
        "high": {
          "latitude": 37.4225022,
          "longitude": -122.0847398
        }
      },
      "placeId": "ChIJF4Yf2Ry7j4AR__1AkytDyAE",
      "placeTypes": [
        "street_address"
      ]
    },
    "metadata": {
      "business": true,
      "residential": false
    },
    "uspsData": {
      "standardizedAddress": {
        "firstAddressLine": "1600 AMPHITHEATRE PKWY",
        "cityStateZipAddressLine": "MOUNTAIN VIEW CA 94043-1351",
        "city": "MOUNTAIN VIEW",
        "state": "CA",
        "zipCode": "94043",
        "zipCodeExtension": "1351"
      },
      "deliveryPointCode": "00",
      "deliveryPointCheckDigit": "0",
      "dpvConfirmation": "Y",
      "dpvFootnote": "AABB",
      "dpvCmra": "N",
      "dpvVacant": "N",
      "dpvNoStat": "Y",
      "carrierRouteIndicator": "D",
      "postOfficeCity": "MOUNTAIN VIEW",
      "postOfficeState": "CA",
      "fipsCountyCode": "085",
      "county": "SANTA CLARA",
      "elotNumber": "0103",
      "elotFlag": "A",
      "addressRecordType": "S",
      "dpvNoStatReasonCode": 5,
      "dpvDrop": "N",
      "dpvThrowback": "N",
      "dpvNonDeliveryDays": "N",
      "dpvNoSecureLocation": "N",
      "dpvPbsa": "N",
      "dpvDoorNotAccessible": "N",
      "dpvEnhancedDeliveryCode": "Y"
    }
  },
  "responseId": "a3d051f9-a802-4d8a-b530-46ee45903453"
}
```

## Apply API key restrictions

> [!CAUTION]
> **Caution:** An **unrestricted** API key can be used to make a request to **any** Google Maps Platform service, including the Address Validation API. **You are financially responsible
> for charges caused by abuse of unrestricted API keys.**

Google strongly recommends that you restrict your API keys by limiting their
usage to only the APIs and apps that need them. Restricting API keys adds
security to your application by protecting it from unwarranted requests. API
keys support two types of restrictions:

- [API restrictions](https://cloud.google.com/docs/authentication/api-keys#adding-api-restrictions) specify which SDKs and APIs can be called using the API key. The console and the gcloud CLI require at least one API restriction when you create a key.
- [Application restrictions](https://cloud.google.com/docs/authentication/api-keys#adding-application-restrictions) specify which websites, IP addresses, or apps can use an API key.

For more information about applying restrictions, see
[Restrict your API keys](https://developers.google.com/maps/api-security-best-practices.md.txt#restricting-api-keys).

## Create an OAuth token

Address Validation API supports OAuth 2.0 for authentication. Google supports common
OAuth 2.0 scenarios, such as scenarios for a web server.

This document describes how to pass an OAuth token to a Address Validation API call
in your development environment. For more information about using OAuth in a
production environment, see
[Authentication methods at Google](https://cloud.google.com/docs/authentication).

You can call Google Maps APIs directly by making API requests to
the server, or you can use [client libraries](https://cloud.google.com/apis/docs/client-libraries-explained) to
simplify your code. Google Maps provides client libraries for Go,
Java, Node.js, and Python. For more information, see
[Address Validation API client libraries](https://developers.google.com/maps/documentation/address-validation/client-libraries).

## OAuth overview

You can create and manage access tokens with OAuth in several ways depending on
your deployment environment.

You can use OAuth 2.0 for server-to-server interactions between your
application and a Google service. For this scenario, you use a service account
that's associated with your application rather than an individual user. You
can make API requests using the service account without involving users
directly. For more information about authentication methods, see
[Authentication methods at Google](https://cloud.google.com/docs/authentication).

Alternatively, you can integrate Address Validation API into an Android or iOS
mobile app. For more information about using OAuth and managing access tokens
for different deployment environments, see
[Using OAuth 2.0 to Access Google APIs](https://developers.google.com/identity/protocols/oauth2.md.txt).

## OAuth scopes

To use OAuth with Address Validation API, you must assign the OAuth token the
following scope:

    https://www.googleapis.com/auth/cloud-platform

## Example: Try REST API calls in your local development environment

If you don't have an environment that generates tokens and you want to try
Address Validation API with an OAuth token, use the procedure in this section.

This example describes how to use the OAuth token provided by
[Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials) to make the call. For more
information about using ADC to call Google APIs with client libraries, see
[Authenticate using client libraries](https://cloud.google.com/docs/authentication/client-libraries).

Use the following REST procedure only for development or testing, not for
production.

### Prerequisites

Before you make a REST request using ADC, use the `gcloud` CLI to provide
credentials to ADC:

1. Install and initialize the `gcloud` CLI. For more information, see
   [Install the gcloud CLI](https://cloud.google.com/sdk/docs/install).

2. Authenticate with the `gcloud` CLI:

   ```
   gcloud auth application-default login
   ```
3. Complete the sign-in process to save your credentials in the
   [local credential file used by ADC](https://cloud.google.com/docs/authentication/application-default-credentials#personal).

For more information, see
[Set up ADC for a local development environment](https://cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

### Make a REST request

In this example, you pass two request headers:

- Pass the OAuth token in the `Authorization` header by using the following
  command to generate the token:

  [`gcloud auth application-default print-access-token`](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/print-access-token)

  The returned token has a scope of
  `https://www.googleapis.com/auth/cloud-platform`.
- Pass the ID or name of your Google Cloud project that has billing
  enabled in the `X-Goog-User-Project` header.

To call Address Validation API using an OAuth token, complete the following steps:

1. In the following code sample, replace <var translate="no">PROJECT_ID</var> with your
   Google Cloud project ID:

   ```
   curl -X POST -d '{
   "address": {
   "regionCode": "US",
   "locality": "Mountain View",
   "addressLines": ["1600 Amphitheatre Pkwy"]
   }
   }' \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
   -H "X-Goog-User-Project: PROJECT_ID" \
   "https://addressvalidation.googleapis.com/v1:validateAddress"
   ```
2. To copy the `curl` command, click **Copy** in the code sample.

3. Paste the command in a terminal window, and then run it.

The response is a JSON object:

```json
{
  "result": {
    "verdict": {
      "inputGranularity": "PREMISE",
      "validationGranularity": "PREMISE",
      "geocodeGranularity": "PREMISE",
      "addressComplete": true,
      "hasInferredComponents": true
    },
    "address": {
      "formattedAddress": "1600 Amphitheatre Parkway, Mountain View, CA 94043-1351, USA",
      "postalAddress": {
        "regionCode": "US",
        "languageCode": "en",
        "postalCode": "94043-1351",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "1600 Amphitheatre Pkwy"
        ]
      },
      "addressComponents": [
        {
          "componentName": {
            "text": "1600"
          },
          "componentType": "street_number",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "Amphitheatre Parkway",
            "languageCode": "en"
          },
          "componentType": "route",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "Mountain View",
            "languageCode": "en"
          },
          "componentType": "locality",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "USA",
            "languageCode": "en"
          },
          "componentType": "country",
          "confirmationLevel": "CONFIRMED"
        },
        {
          "componentName": {
            "text": "94043"
          },
          "componentType": "postal_code",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        },
        {
          "componentName": {
            "text": "CA",
            "languageCode": "en"
          },
          "componentType": "administrative_area_level_1",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        },
        {
          "componentName": {
            "text": "1351"
          },
          "componentType": "postal_code_suffix",
          "confirmationLevel": "CONFIRMED",
          "inferred": true
        }
      ]
    },
    "geocode": {
      "location": {
        "latitude": 37.4225022,
        "longitude": -122.0847398
      },
      "plusCode": {
        "globalCode": "849VCWF8+24"
      },
      "bounds": {
        "low": {
          "latitude": 37.4225022,
          "longitude": -122.0847398
        },
        "high": {
          "latitude": 37.4225022,
          "longitude": -122.0847398
        }
      },
      "placeId": "ChIJF4Yf2Ry7j4AR__1AkytDyAE",
      "placeTypes": [
        "street_address"
      ]
    },
    "metadata": {
      "business": true,
      "residential": false
    },
    "uspsData": {
      "standardizedAddress": {
        "firstAddressLine": "1600 AMPHITHEATRE PKWY",
        "cityStateZipAddressLine": "MOUNTAIN VIEW CA 94043-1351",
        "city": "MOUNTAIN VIEW",
        "state": "CA",
        "zipCode": "94043",
        "zipCodeExtension": "1351"
      },
      "deliveryPointCode": "00",
      "deliveryPointCheckDigit": "0",
      "dpvConfirmation": "Y",
      "dpvFootnote": "AABB",
      "dpvCmra": "N",
      "dpvVacant": "N",
      "dpvNoStat": "Y",
      "carrierRouteIndicator": "D",
      "postOfficeCity": "MOUNTAIN VIEW",
      "postOfficeState": "CA",
      "fipsCountyCode": "085",
      "county": "SANTA CLARA",
      "elotNumber": "0103",
      "elotFlag": "A",
      "addressRecordType": "S",
      "dpvNoStatReasonCode": 5,
      "dpvDrop": "N",
      "dpvThrowback": "N",
      "dpvNonDeliveryDays": "N",
      "dpvNoSecureLocation": "N",
      "dpvPbsa": "N",
      "dpvDoorNotAccessible": "N",
      "dpvEnhancedDeliveryCode": "Y"
    }
  },
  "responseId": "fac2ae1b-50ce-442c-8bc3-d459039950ef"
}
```

### Troubleshooting

If your request returns an error message stating that this API doesn't support
end-user credentials, see [Troubleshoot your ADC setup](https://cloud.google.com/docs/authentication/troubleshoot-adc).

<br />

## What's next

Now that you have enabled Address Validation API and made a successful request, see
[Send an address validation request](https://developers.google.com/maps/documentation/address-validation/requests-validate-address.md.txt)
and
[Understand a basic address validation response](https://developers.google.com/maps/documentation/address-validation/understand-response.md.txt)
to learn more about using the API.

<br />