Sidebar Menu

Postal Address Verification
Quick Start: JavaScript

There are three steps to integrating the Postal Address Verification API into your Node.js project.

1. Create an account.

Sign up for an Esendex account. When you register you will receive a license key. You will need this to use the API.

2. Install Node.js.

Install Node.js if it is not on your computer already. To check, run this command in your terminal: node -v

PS C:\> node -v

3. Verify an address.

Create a new JavaScript module file. Let's call it demo.mjs.

You can use the VerifyAddressAdvanced method to verify an address. Add the displayed code to your new file.

Replace the LicenseKey value with your account's license key.

const body = JSON.stringify({
    'FirmOrRecipient': 'City Manager's Office',
    'PrimaryAddressLine': '306 Cedar Road',
    'SecondaryAddressLine': '6th Floor',
    'CityName': 'Chesapeake',
    'State': 'VA',
    'ZipCode': '23322',
    'LicenseKey': '00000000-0000-0000-0000-000000000000'

const url = '';

const options = {
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    method: 'POST'

const response = await fetch(url, options);
const json = await response.json();

const returnCodeDescription = ({
    1: 'Invalid input',
    2: 'Invalid license key',
    10: 'Input address is not found',
    100: 'Input address is DPV-confirmed for all components',
    101: 'Input address is found, but not DPV-confirmed',
    102: 'Input address primary number is DPV-confirmed, secondary number is present but not DPV-confirmed',
    103: 'Input address primary number is DPV-confirmed, secondary number is missing',
    200: 'Canadian address on input, verified on city level only',
})[json['ReturnCode']] || 'Unknown return code';

console.log(`Return code: ${json['ReturnCode']} - ${returnCodeDescription}`);
console.log(`${json['CityName']}, ${json['StateAbbreviation']} ${json['ZipCode']}`);

Run the project in your terminal with this command: node demo.mjs. The program will display the results of the address verification.

PS C:\JsDemo> node demo.mjs
Return code: 100 - Input address is DPV-confirmed for all components
CHESAPEAKE, VA 23322-5514