/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The address being validated. Unformatted addresses should be
* submitted via `address_lines` google.type.PostalAddress.address_lines.
* The total length of the fields in this input must not exceed 300
* characters.
* Supported regions can be found in the
* FAQ (https://developers.google.com/maps/documentation/address-validation/faq#which_regions_are_currently_supported).
* The language_code google.type.PostalAddress.language_code value in the
* input address is reserved for future uses and is ignored today. The
* validated address result will be populated based on the preferred language
* for the given address, as identified by the system.
* The Address Validation API ignores the values in
* recipients google.type.PostalAddress.recipients and
* organization google.type.PostalAddress.organization. Any values in those
* fields will be discarded and not returned. Please do not set them.
*/
// const address = {}
/**
* This field must be empty for the first address validation request. If
* more requests are necessary to fully validate a single address (for
* example if the changes the user makes after the initial validation need to
* be re-validated), then each followup request must populate this field with
* the
* response_id google.maps.addressvalidation.v1.ValidateAddressResponse.response_id
* from the very first response in the validation sequence.
*/
// const previousResponseId = 'abc123'
/**
* Enables USPS CASS compatible mode. This affects _only_ the
* google.maps.addressvalidation.v1.ValidationResult.usps_data field of
* google.maps.addressvalidation.v1.ValidationResult. Note: for USPS CASS
* enabled requests for addresses in Puerto Rico, a
* google.type.PostalAddress.region_code of the `address` must be provided
* as "PR", or an google.type.PostalAddress.administrative_area of the
* `address` must be provided as "Puerto Rico" (case-insensitive) or "PR".
* It's recommended to use a componentized `address`, or alternatively specify
* at least two google.type.PostalAddress.address_lines where the first line
* contains the street number and name and the second line contains the city,
* state, and zip code.
*/
// const enableUspsCass = true
// Imports the Addressvalidation library
const {AddressValidationClient} = require('@googlemaps/addressvalidation').v1;
// Instantiates a client
const addressvalidationClient = newAddressValidationClient();
async function callValidateAddress() {
// Construct request
const request = {
address: {
regionCode: 'US',
addressLines: ['1600 Amphitheatre Pkwy', 'Mountain View CA 94040'],
},
};
// Run request
const response = await addressvalidationClient.validateAddress(request);
console.log(response);
}
callValidateAddress();
Samples
Samples are in thesamples/directory. Each sample'sREADME.mdhas instructions for running its sample.
Our client libraries follow theNode.js release schedule.
Libraries are compatible with all currentactiveandmaintenanceversions of
Node.js.
If you are using an end-of-life version of Node.js, we recommend that you update
as soon as possible to an actively supported LTS version.
Google's client libraries support legacy versions of Node.js runtimes on a
best-efforts basis with the following warnings:
Legacy versions are not tested in continuous integration.
Some security patches and features cannot be backported.
Dependencies cannot be kept up-to-date.
Client libraries targeting some end-of-life versions of Node.js are available, and
can be installed through npmdist-tags.
The dist-tags follow the naming conventionlegacy-(version).
For example,npm install @googlemaps/addressvalidation@legacy-8installs client libraries
for versions compatible with Node.js 8.
This library is considered to be inbeta. This means it is expected to be
mostly stable while we work toward a general availability release; however,
complete stability is not guaranteed. We will address issues and requests
against beta libraries with a high priority.
Please note that thisREADME.md, thesamples/README.md,
and a variety of configuration files in this repository (including.nycrcandtsconfig.json)
are generated from a central template. To edit one of these files, make an edit
to its templates indirectory.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [1.0.1 (latest)](/nodejs/docs/reference/addressvalidation/latest)\n- [0.1.0](/nodejs/docs/reference/addressvalidation/0.1.0) \n\n[Address Validation API: Node.js Client](https://github.com/googleapis/google-cloud-node)\n=========================================================================================\n\n[](https://cloud.google.com/terms/launch-stages)\n[](https://www.npmjs.org/package/@googlemaps/addressvalidation)\n\nclient for Node.js\n\nA comprehensive list of changes in each version may be found in\n[the CHANGELOG](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-maps-addressvalidation/CHANGELOG.md).\n\n- [Address Validation API Node.js Client API Reference](https://cloud.google.com/nodejs/docs/reference/addressvalidation/latest)\n- [Address Validation API Documentation](https://mapsplatform.google.com/maps-products/address-validation/)\n- [github.com/googleapis/google-cloud-node/packages/google-maps-addressvalidation](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-maps-addressvalidation)\n\nRead more about the client libraries for Cloud APIs, including the older\nGoogle APIs Client Libraries, in [Client Libraries Explained](https://cloud.google.com/apis/docs/client-libraries-explained).\n\n**Table of contents:**\n\n- [Quickstart](#quickstart)\n - [Before you begin](#before-you-begin)\n - [Installing the client library](#installing-the-client-library)\n - [Using the client library](#using-the-client-library)\n- [Samples](#samples)\n- [Versioning](#versioning)\n- [Contributing](#contributing)\n- [License](#license)\n\nQuickstart\n----------\n\n### Before you begin\n\n1. [Select or create a Cloud Platform project](https://console.cloud.google.com/project).\n2. [Enable billing for your project](https://support.google.com/cloud/answer/6293499#enable-billing).\n3. [Enable the Address Validation API API](https://console.cloud.google.com/flows/enableapi?apiid=addressvalidation.googleapis.com).\n4. [Set up authentication with a service account](https://cloud.google.com/docs/authentication/getting-started) so you can access the API from your local workstation.\n\n### Installing the client library\n\n npm install @googlemaps/addressvalidation\n\n### Using the client library\n\n /**\n * This snippet has been automatically generated and should be regarded as a code template only.\n * It will require modifications to work.\n * It may require correct/in-range values for request initialization.\n * TODO(developer): Uncomment these variables before running the sample.\n */\n /**\n * Required. The address being validated. Unformatted addresses should be\n * submitted via `address_lines` google.type.PostalAddress.address_lines.\n * The total length of the fields in this input must not exceed 300\n * characters.\n * Supported regions can be found in the\n * FAQ (https://developers.google.com/maps/documentation/address-validation/faq#which_regions_are_currently_supported).\n * The language_code google.type.PostalAddress.language_code value in the\n * input address is reserved for future uses and is ignored today. The\n * validated address result will be populated based on the preferred language\n * for the given address, as identified by the system.\n * The Address Validation API ignores the values in\n * recipients google.type.PostalAddress.recipients and\n * organization google.type.PostalAddress.organization. Any values in those\n * fields will be discarded and not returned. Please do not set them.\n */\n // const address = {}\n /**\n * This field must be empty for the first address validation request. If\n * more requests are necessary to fully validate a single address (for\n * example if the changes the user makes after the initial validation need to\n * be re-validated), then each followup request must populate this field with\n * the\n * response_id google.maps.addressvalidation.v1.ValidateAddressResponse.response_id\n * from the very first response in the validation sequence.\n */\n // const previousResponseId = 'abc123'\n /**\n * Enables USPS CASS compatible mode. This affects _only_ the\n * google.maps.addressvalidation.v1.ValidationResult.usps_data field of\n * google.maps.addressvalidation.v1.ValidationResult. Note: for USPS CASS\n * enabled requests for addresses in Puerto Rico, a\n * google.type.PostalAddress.region_code of the `address` must be provided\n * as \"PR\", or an google.type.PostalAddress.administrative_area of the\n * `address` must be provided as \"Puerto Rico\" (case-insensitive) or \"PR\".\n * It's recommended to use a componentized `address`, or alternatively specify\n * at least two google.type.PostalAddress.address_lines where the first line\n * contains the street number and name and the second line contains the city,\n * state, and zip code.\n */\n // const enableUspsCass = true\n\n // Imports the Addressvalidation library\n const {AddressValidationClient} = require('https://cloud.google.com/nodejs/docs/reference/addressvalidation/latest/overview.html').v1;\n\n // Instantiates a client\n const addressvalidationClient = new https://cloud.google.com/nodejs/docs/reference/addressvalidation/latest/overview.html();\n\n async function callValidateAddress() {\n // Construct request\n const request = {\n address: {\n regionCode: 'US',\n addressLines: ['1600 Amphitheatre Pkwy', 'Mountain View CA 94040'],\n },\n };\n\n // Run request\n const response = await addressvalidationClient.validateAddress(request);\n console.log(response);\n }\n\n callValidateAddress();\n\nSamples\n-------\n\nSamples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample.\n\nThe [Address Validation API Node.js Client API Reference](https://cloud.google.com/nodejs/docs/reference/addressvalidation/latest) documentation\nalso contains samples.\n\nSupported Node.js Versions\n--------------------------\n\nOur client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).\nLibraries are compatible with all current *active* and *maintenance* versions of\nNode.js.\nIf you are using an end-of-life version of Node.js, we recommend that you update\nas soon as possible to an actively supported LTS version.\n\nGoogle's client libraries support legacy versions of Node.js runtimes on a\nbest-efforts basis with the following warnings:\n\n- Legacy versions are not tested in continuous integration.\n- Some security patches and features cannot be backported.\n- Dependencies cannot be kept up-to-date.\n\nClient libraries targeting some end-of-life versions of Node.js are available, and\ncan be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).\nThe dist-tags follow the naming convention `legacy-(version)`.\nFor example, `npm install @googlemaps/addressvalidation@legacy-8` installs client libraries\nfor versions compatible with Node.js 8.\n\nVersioning\n----------\n\nThis library follows [Semantic Versioning](http://semver.org/).\n\nThis library is considered to be in **beta**. This means it is expected to be\nmostly stable while we work toward a general availability release; however,\ncomplete stability is not guaranteed. We will address issues and requests\nagainst beta libraries with a high priority.\n\nMore Information: [Google Cloud Platform Launch Stages](https://cloud.google.com/terms/launch-stages)\n\nContributing\n------------\n\nContributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md).\n\nPlease note that this `README.md`, the `samples/README.md`,\nand a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)\nare generated from a central template. To edit one of these files, make an edit\nto its templates in\n[directory](https://github.com/googleapis/synthtool).\n\nLicense\n-------\n\nApache Version 2.0\n\nSee [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE)"]]