Validate/verify addresses with API

Verify addresses with API to check user input
Verify addresses with API to check user input

Address Validation API lets to verify postal addresses programmatically. For example, this allows web applications to test if an address provided by the user valid or not, run bulk address reviews for a large number of inputs, integrate checks to CRMs, applications, and other services.

In this article, we would like to show how to validate and verify addresses efficiently and at low costs with Geoapify Geocoding API.

Address Validation API vs Geocoding API

There is a large number of special Address Validation APIs and services offered by different companies. So why we are talking about this topic again?

Yes, some APIs specializes in address validation and verification. Usually, those APIs are focused on particular countries and do their job quite well. However, in general, it's quite an expensive service, with no or just a small free tier.

On the other hand, the Geocoding API does almost the same job, it parses and looks up addresses and definitely can answer the question "Is the address valid or not?"

Let's compare those two APIs and summarize the advantages and disadvantages of both approaches:

CriteriaAddress Validation APIsGeoapify Geocoding API
CoverageExact countries or areasWorldwide
DatasourcesOfficial and private data sources. Those sources may contain more detailed data, but are less flexible and dynamic. For example, new streets and buildings appear in the data sources with a huge delay.Open-, crowd-powered datasets. For example, OpenStreetMap, GeoNames. This lets us improve the coverage from month to month and offer you permissive conditions.
Storing the dataIn general, it's not allowed. Check Terms and Conditions of a service provider.Our main focus is data quality and not data protection (we use open-sourced data). You can store and reuse address validation results.
Address parsingAccept structured address (separate values for house number, street, city, postcode, etc.) as a parameterAccept both free-form address and structured address
LocationUsually the Address Validation API do not return latitude/longitude coordinates as a resultThe Geocoding API returns location, latitude/longitude coordinates within a result
CostThe specialized APIs are usually up to x10 times more expensive. Check pricing on a service provider webpage.We offer different pricing plans for different usage. Our Free Plan includes up to 3000 request / day (up to 90000 requests / month).

Summarizing the table below, the Geoapify Geocoding API can be used as an alternative to Address Validation API to verify and check addresses. It empowers you to process structured and free-form addresses and do not worry about going over budget.

How to verify addresses with Geocoding API?

The Geoapify Geocoding API accepts both structured address (separate address components) and whole position as an input. It tries to find the most appropriate location for each address. In addition, it returns confidence values, which can be used to make assumptions on the address validity. The whole process can be described in two steps:

  1. Lookup address
  2. Decide if the address is valid

As the Geoapify APIs work via HTTP and returns GeoJSON FeatureCollection as a result, you can use any language to make the API calls. Here are JavaScript code samples showing how to call Geocoding API to lookup an address:

Step 1. Option 1. Lookup a free-form address JS code sample

Use text input parameter to pass the address to the Geoapify Geocoding API:

const url = `https://api.geoapify.com/v1/geocode/search?text=${encodeURIComponent(ADDRESS_TO_SEARCH)}&apiKey=${YOUR_API_KEY}`;

fetch(url).then(response => response.json())
  .then(result => {
    console.log(result);

    if (result.features.length === 0) {
      console.log("The address is not found");
    } else {
      console.log("Matched address:")
      console.log(result.features[0]);
    }
  })
  .catch(error => console.log('error', error));

Learn more about the Geoapify Geocoding API option on the API documentation page or try it with a Playground.

Step1. Option 2. Lookup a structured address

Use housenumber, street, postcode, city, state, and country input parameters to pass the structured address to the Geoapify Geocoding API. Set only the existing values, skip parts that are missing:

const url = `https://api.geoapify.com/v1/geocode/search?housenumber=${encodeURIComponent(HOUSE_NUMBER)}
&street=${encodeURIComponent(STREET)}&postcode=${encodeURIComponent(POSTCODE)}&city=${encodeURIComponent(CITY)}&apiKey=${YOUR_API_KEY}`;

fetch(url).then(response => response.json())
  .then(result => {
    console.log(result);

    if (result.features.length === 0) {
      console.log("The address is not found");
    } else {
      console.log("Matched address:")
      console.log(result.features[0]);
    }
  })
  .catch(error => console.log('error', error));

Learn more about the Geoapify Geocoding API option on the API documentation page or try it with a Playground.

Step 2. Validate the address

The API returns up to three confidence parameters, that allow making assumptions about the address correctness:

  • rank.confidence - confidence level for the whole address
  • rank.confidence_street_level - confidence level for the street level, tells how confident we are that found street if correct
  • rank.confidence_city_level - confidence level for the city level, tells how confident we are that found city if correct

The parameters have values in the interval [0, 1], where the value 1 means that we are confident that the returned address corresponds to the given address. By calculating the confidence coefficient we compare all address components of given and received address, we apply different heuristics and cover the most common cases. The confidence value is decreased when we are not sure if addresses are the same. Here is an example of how you can interpret the address geocoding results:

const ACCEPT_LEVEL = 0.95;
const DECLINE_LEVEL = 0.2;

const validationResult = {};

 return fetch(url).then(response => response.json())
  .then(result => {
    console.log(result);

    if (result.features.length === 0) {
      validationResult.validation = 'NOT_CONFIRMED';
      return validationResult;
    }

    const address = result.features[0].properties;

    if (address.rank.confidence >= ACCEPT_LEVEL) {
      validationResult.validation = 'CONFIRMED';
    } else if (address.rank.confidence < DECLINE_LEVEL) {
      validationResult.validation = 'NOT_CONFIRMED';
    } else {
      validationResult.validation = 'PARTIALLY_CONFIRMED';

      if (!address.rank.confidence_city_level || address.rank.confidence_city_level < ACCEPT_LEVEL) {
        validationResult.validation_details = 'CITY_LEVEL_DOUBTS';
      } else if (!address.rank.confidence_street_level || address.rank.confidence_street_level < ACCEPT_LEVEL) {
        validationResult.validation_details = 'STREET_LEVEL_DOUBTS';
      } else {
        validationResult.validation_details = 'BUILDING_NOT_FOUND';
      }
    }

    return validationResult;
  })
  .catch(error => console.log('error', error));

Tips and tricks

We contatnly improve our algorithms and make them work with different address fromats. Nevertheless, the results qulity is stronly depend on the input data qulity. Here are some tips and tricks that help to improve address validation results.

Improve input address quality

The geocoding result and validation result respectively depend a lot on the input quality. Our algorithms are already very smart and can parse even very complicated cases. However, it's always a win-win situation when prepare/clean up addresses before the API call. This especially important when you pass a free-form address as an input.

We always return your original query and parsed address as a part of the result. So you can easily know, if the provided address is parsed successfully or not:

{
   "type":"FeatureCollection",
   "features":[
    ...
   ],
   "query":{
      "text":"Industriestr. 2, 83734 Hausham",
      "parsed":{
         "housenumber":"2",
         "street":"industriestr.",
         "postcode":"83734",
         "city":"hausham",
         "expected_type":"building"
      }
   }
}

Try to geocode addresses in Geocoding API Playground and check if the address format is understandable by the API.

Filters and bias for better results

The Geoapify Geocoding API lets set filters and bias parameters that may help to find addresses more precise, especially if some address details are not omitted.

We recommend to set at least country filter when you look up addresses in a certain country and bias when the address leans to a map view or user location.

Bulk address validation with a 50% discount

Use Geoapify Batcher to validate a large number of addresses. As all batch requests cost are counted with a 50% discount, this will decrease your operational costs and let you process two times more addresses at the same costs.

What's next

FAQ

What is Address Validation API?

Address Validation API is an application programming interface that can answer the question if the provided address is valid or not. It's very useful when the API return the reason why the address is not correct or which part of the address was not confirmed.

How much does Address Validation API cost?

In general, the Address Validation APIs are not sixpenny. You can have to pay hundreds of dollars/euro to process a few thousand addresses. However, there is good news as well! The Geocoding API is more general and used to look up addresses, so it's much less expensive. For example, with Geoapify Geocoding API you can validate up to 90000 addresses/month for Free.

Which API can I use to validate addresses for Free?

All the Address Validation APIs provide Free tier or demo versions. For example, by using Geoapify Geocoding API you can verify up to 90000 addresses for Free each month.

Which datasets are used to verify addresses?

Geoapify Geocoding API uses open and crowd-powered data sources. We use OpenStreetMap, GeoNames, OpenAddresses, and other data sources.

Can I validate addresses from a CSV or an Excel file?

Yes! Geoapify offers a Free Address Validation Tool that processes addresses from a CSV or Excel file.

World map

Try Geocoding API for Address Validation

Start now for Free and upgrade when you need it!