International Street Address API

Geocoding

Introduction

In today's world, we heavily rely on digital communication and the internet. Thus, it becomes crucial for companies to keep their data up-to-date, for example, their address database. One of the most challenging aspects of maintaining an updated address database includes dealing with international addresses.

That's why we have APIs like SmartStreet's International Street API. In this blog post, we will discuss the basics of the International Street API and provide examples of how to use it using JavaScript.

SmartStreet's International Street API

The International Street API enables you to validate, standardize, and enrich international addresses. With its extensive coverage of international addresses, the API is a comprehensive solution for businesses operating globally. It supports over 200 countries and territories worldwide.

Authentication

To use the International Street API, you need an API key provided by SmartStreet. You can visit their website to get started.

Basic Usage

Now, let's explore some basic examples of using the International Street API.

Validate an International Address

const API_KEY = "YOUR_API_KEY";
const URL = `https://us-street.api.smartystreets.com/verify-international?auth-id=${API_KEY}&`;
const address = "2 rue Léon Blum, 92800 Puteaux, France";
const urlEncodedAddress = encodeURIComponent(address);
const requestURL = `${URL}address=${urlEncodedAddress}`;

fetch(requestURL)
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

In this example, we first define the API Key provided by SmartStreet. Using this key, we construct the request URL by adding the auth-id parameter to the endpoint https://us-street.api.smartystreets.com/verify-international?. We then encode the address using encodeURIComponent and append it to the URL. Finally, we make a fetch request and print the response to the console.

Find Suggestions for an Incomplete Address

const API_KEY = "YOUR_API_KEY";
const URL = `https://us-street.api.smartystreets.com/autocomplete?auth-id=${API_KEY}&`;
const address = "2 rue";
const urlEncodedAddress = encodeURIComponent(address);
const requestURL = `${URL}prefix=${urlEncodedAddress}`;

fetch(requestURL)
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

In this example, we use the autocomplete endpoint to find suggestions for an incomplete address. We construct the request URL in the same way as before, but this time we use the prefix parameter to pass the partial address. Again, we make a fetch request and print the response to the console.

Conclusion

In this blog post, we explored the basics of the International Street API and provided examples in JavaScript. You can use these examples as a starting point to integrate the International Street API into your application. With the API's comprehensive coverage and easy-to-use interface, it becomes straightforward to standardize and validate international addresses.

Related APIs in Geocoding