Press enter to see results or esc to cancel.

TUTORIAL: Verify Addresses with the Streetlayer API

A street address is one type of data you don’t want to get wrong. Whether you’re building an app for mailing, shipping or legal purposes, getting an address right is integral to having your product, you know, delivered. Having an invalid (or incorrectly typed) address could cause delays and annoyance for your app’s users, and cost you a lot of money.

Validating data is a core best practice of software development. Unlike other types of data, however, addresses are notoriously hard to validate for the following reasons:

  • Lack of universal structure: Do you type 345 Abbey Rd. or Abbey Rd. 234? Depending on where your users are from, the answer varies.
  • Variety of parameters: The many different inputs (apartment / suite numbers, road / street / avenue etc. ) makes validation even more challenging.
  • International variance: When you have customers from all around the world, handling international address verification makes this already difficult task even harder. Just as an example, not all countries have states / regions within them, while in other countries it is not uncommon for the same city to appear twice in two regions.

It almost makes you want to give up on verifying addresses all together.

Source: xkcd
Source: xkcd

Luckily, we have the StreetLayer API!

The Streetlayer API is an easy-to-integrate solution for address verification. It can verify addresses nationally and internationally. From a basic check we’ve performed on a few hundred addresses with https://openaddresses.io, it seems to be highly accurate. Beyond the standard address verification, StreetLayer also offers geocoding – a way to turn your addresses into latitude longitude coordinates. This geocoding feature could be highly useful if you want to present an address on a map.

One of the aspects that we like best about Streetlayer is its ability to treat addresses in a structured way. The API breaks addresses down into their logical components (country code, street, house number, state etc…). If you’re going to store address data in your database, this could be a great way to break down the data rather than store an unparsed string. Storing it that way will also allow you to query by street / country / region down the road (pun not intended).

Step 0: Get a Streetlayer API key

To start using the StreetLayer API, head over to https://streetlayer.com and click ‘Sign Up Free’ in the top right corner. StreetLayer has a free tier with up to 50 requests / month. This tier should be plenty for this tutorial and for development, though you may want to scale up to the Basic ($9.99 / month) or Pro ($49.99 / month) as your app moves into production.

Once you’ve finished the signup process, you’ll be taken to the dashboard and presented with the API key. Keep that as it is required to identify you in every API call you make.

streetlayer-api-key

In the dashboard, you can also view your API usage (in the left menu). It’ll show you how much of your plan you’ve used up.

Step 1: Use RapidAPI to Make an API Request

Now that you’re all set up with Streetlayer,  head over to StreetLayer on RapidAPI to start making requests. RapidAPI will let you test a Streetlayer API call in your browser, then you’ll be able to export the code snippet in your preferred language.
We’ll start out by using the validateAddress function. Enter your API key and and address and click test.

screen-shot-2017-03-16-at-5-16-52-pm

Your response should look like this:

[  
   {  
      "success":true,
      "validation_status":"valid",
      "address_components":{  
         "country_code_alpha2":"US",
         "country_code_alpha3":"USA",
         "country":"United States",
         "county":"San Francisco County",
         "locality":"San Francisco",
         "postal_code":"94105",
         "region":"California",
         "region_code":"CA",
         "street":"Beale St.",
         "housenumber":"388",
         "neighbourhood":"Rincon Hill"
      },
      "validation_result":{  
         "locality":true,
         "county":null,
         "region":null,
         "postal_code":null,
         "street":true,
         "housenumber":true
      },
      "formatted_address":[  
         "388 Beale St.",
         "San Francisco, CA 94105",
         "United States"
      ],
      "coordinates":{  
         "latitude":37.787676,
         "longitude":-122.391777
      }
   }
]

In the response you can see that the validation_status parameter is set to valid, and thus the address is valid. You can also see the three line formatted_address and the address components.

You can copy the code into your app in order to verify addresses. Since it’s also considered best practice to verify all data received in the backend, you could easily verify the address there as well.

 

Bonus Step! Add Address Auto-Completion

StreetLayer can also be used in the front end to auto-complete addresses.

As we all know, entering addresses can oftentimes be tedious. Having to type your zip code, street address, state and country every time you use an online service is a true annoyance. No wonder address entry is one of the biggest drop-off points in online forms!

StreetLayer has another function set to change this – autocompleteAddress. You can pass this function a fragment of an address and get suggestions for possible addresses. Using a library like jQuery UI, you can show those suggestions to the user in a dropdown. Much like the suggestion given in Google search, this functionality will save your users the effort of address entry.

Here is a small jsFiddle using StreetLayer’s autocomplete functionality with jQuery UI. Every time a user types in a fragment of an address, jQuery will call the autocomplete function (see below). The function will make a request to RapidAPI with the text and pass back an array of options, which jQuery will then show to the user.

You can checkout the complete jsFiddle here.

Conclusion

Overall, the Streetlayer API a great way to make sure your users are entering valid addresses frustration-free. Better yet, unlike services like Google Maps, this solution is 100% white label, not requiring you to put a 3rd party logo on your website. Test an API call for yourself and let us know what you think!

 

Comments

13 Comments

מיזוג אוויר

… [Trackback]

[…] Find More here|Find More|Find More Informations here|Here you can find 95043 more Informations|Infos on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

www.cpns2016.com

… [Trackback]

[…] Read More here|Read More|Find More Infos here|There you can find 80675 additional Infos|Infos on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

Dokter Gigi Jakarta Utara

… [Trackback]

[…] Find More here|Find More|Read More Infos here|Here you can find 42593 more Infos|Infos to that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

Michael Dave

Nice Post.

roof repair

… [Trackback]

[…] Find More here|Find More|Find More Infos here|Here you will find 53889 additional Infos|Informations on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

DMPK Studies

… [Trackback]

[…] Find More here|Find More|Read More Informations here|Here you will find 35896 additional Informations|Informations to that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

friv 2

… [Trackback]

[…] Find More here|Find More|Find More Informations here|Here you can find 94549 additional Informations|Informations on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

Festivales

… [Trackback]

[…] Read More on|Read More|Find More Infos here|Here you can find 4885 additional Infos|Informations to that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

mondo sonoro

… [Trackback]

[…] Find More on|Find More|Read More Infos here|Here you can find 71847 more Infos|Infos on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

St George Heater

… [Trackback]

[…] Find More here|Find More|Find More Infos here|There you will find 73604 additional Infos|Informations on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

lowongan kerja bandung terbaru

… [Trackback]

[…] Find More here|Find More|Find More Infos here|There you can find 98170 more Infos|Infos on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

Event Managers in Hyderabad

… [Trackback]

[…] Find More here|Find More|Read More Informations here|Here you will find 74675 more Informations|Infos on that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]

snmptn 2018 itb dkv

… [Trackback]

[…] Find More here|Find More|Find More Informations here|Here you will find 2784 more Informations|Informations to that Topic: blog.rapidapi.com/2017/03/20/tutorial-verify-addresses-with-the-streetlayer-api/ […]


Leave a Comment

Tell us your thoughts!

Spread the API ❤️