Postal Address Verification Online API

You can integrate the Byteplant address validation API directly into your sign-up forms or web apps and allow your website visitors to fix errors in their data instantly - only valid addresses will be accepted.

How Does It Work?

Integrating our Address Validation Online API into the Javascript, PHP, Java, C#, VB.NET code of your website or application or into content management systems (CMS) like Drupal, Typo3, WordPress or Joomla is very easy - all you have to do is to send a HTTP or HTTPS (TLS) request to our servers! The request returns a status code (valid/invalid) and the address in standardized format.


<script type="text/javascript" src="path/to/jquery"></script>
<script type="text/javascript">
$(document).ready(function() {
    ...
    // send API request
    Locale = 'en';
    $.ajax({
        url: 'http://api.address-validator.net/api/verify',
        type: 'POST',
        data: { StreetAddress: StreetAddress,
                City: City,
                PostalCode: PostalCode,
                State: State,
                CountryCode: CountryCode,
                Locale: Locale,
                APIKey: 'your API key'},
        dataType: 'json',
        success: function (json) {
            // check API result
            if (typeof(json.status) != "undefined") {
                status = json.status;
                formattedaddress = json.formattedaddress;
            }
        }
    });
    ...
});
</script>

...
// build API request
$APIUrl = 'http://api.address-validator.net/api/verify';
$Params = array('StreetAddress' => $StreetAddress,
                'City' => $City,
                'PostalCode' => $PostalCode,
                'State' => $State,
                'CountryCode' => $CountryCode,
                'Locale' => $Locale,
                'APIKey' => 'your API key');
$Request = @http_build_query($Params);
$ctxData = array(
     'method' => "POST",
     'header' => "Connection: close\r\n".
     "Content-Length: ".strlen($Request)."\r\n",
     'content'=> $Request);
$ctx = @stream_context_create(array('http' => $ctxData));

// send API request
$result = json_decode(@file_get_contents(
    $APIUrl, false, $ctx));

// check API result
if ($result && $result->{'status'} == 'VALID') {
    $formattedaddress = $result->{'formattedaddress'};
} else {
    echo $result->{'info'};
}
...

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
...
HttpClient client = new DefaultHttpClient();
String StreetAddress = "...";
String City = "...";
String PostalCode = "...";
String State = "...";
String CountryCode = "us";
String Locale = "en";
String APIKey = "your API key";
String APIURL = "http://api.address-validator.net/api/verify";
try {
    HttpPost request = new HttpPost(APIURL);
    List <NameValuePair> Input = new ArrayList<NameValuePair>();
    Input.add(new BasicNameValuePair("StreetAddress", StreetAddress));
    Input.add(new BasicNameValuePair("City", City));
    Input.add(new BasicNameValuePair("PostalCode", PostalCode));
    Input.add(new BasicNameValuePair("State", State));
    Input.add(new BasicNameValuePair("CountryCode", CountryCode));
    Input.add(new BasicNameValuePair("Locale", Locale));
    Input.add(new BasicNameValuePair("APIKey", APIKey));
    request.setEntity(new UrlEncodedFormEntity(Input));
    HttpResponse response = client.execute(request);
    HttpEntity entity = response.getEntity();
    String Output = EntityUtils.toString(entity, "UTF-8");
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(Output);
    JSONObject jsonObject = (JSONObject) obj;
    String result = (String) jsonObject.get("status");
    if (result.equalsIgnoreCase("VALID")) {
        String formattedaddress = (String) jsonObject.get("formattedaddress");
    }
    ...
} catch (IOException e) {
    e.printStackTrace();
} catch (ParseException e) {
    e.printStackTrace();
} finally {
    client.getConnectionManager().shutdown();
}
...

// C# .NET 4.5
using System;
using System.Collections.Generic;
using System.Net.Http;
...

private class APIResult
{
    public String status { get; set; }
    public String formattedaddress { get; set; }
}

const String APIURL = "http://api.address-validator.net/api/verify";
HttpClient client = new HttpClient();
String StreetAddress = "...";
String City = "...";
String PostalCode = "...";
String State = "...";
String CountryCode = "us";
String Locale = "en";
String APIKey = "your API key";

var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("StreetAddress", StreetAddress));
postData.Add(new KeyValuePair<string, string>("City", City));
postData.Add(new KeyValuePair<string, string>("PostalCode", PostalCode));
postData.Add(new KeyValuePair<string, string>("State", State));
postData.Add(new KeyValuePair<string, string>("CountryCode", CountryCode));
postData.Add(new KeyValuePair<string, string>("Locale", Locale));
postData.Add(new KeyValuePair<string, string>("APIKey", APIKey));

HttpContent content = new FormUrlEncodedContent(postData);

HttpResponseMessage result = client.PostAsync(APIURL, content).Result;
string resultContent = result.Content.ReadAsStringAsync().Result;

APIResult res = new System.Web.Script.Serialization.JavaScriptSerializer().
                    Deserialize<APIResult>(resultContent);

if (res.status.Equals("VALID")) {
    String FormattedAddress = res.formattedaddress;
}
...

' VB.NET 4.5
...
Private Sub checkAddress(ByVal StreetAddress As String,
                       ByVal City As String,
                       ByVal PostalCode As String,
                       ByVal State As String,
                       ByVal CountryCode As String,
                       ByVal Locale As String,
                       ByVal APIKey As String)
    Const APIURL As String = "http://api.address-validator.net/api/verify"
    Using client As New Net.WebClient
      Dim postData As New Specialized.NameValueCollection
      postData.Add("StreetAddress", StreetAddress)
      postData.Add("City", City)
      postData.Add("PostalCode", PostalCode)
      postData.Add("State", State)
      postData.Add("CountryCode", CountryCode)
      postData.Add("Locale", Locale)
      postData.Add("APIKey", APIKey)
      Dim reply = client.UploadValues(APIURL, "POST", postData)
      Dim data As String = (New System.Text.UTF8Encoding).GetString(reply)
      Dim res = New System.Web.Script.Serialization.JavaScriptSerializer().
        Deserialize(Of APIResult)(data)
      If res.status.Equals("VALID") Then
        Dim FormattedAddress As String = res.formattedaddress
      End If
    End Using
End Sub

Private Class APIResult
    Public status As String
    Public formattedaddress As String
End Class
...

API URL : http://api.address-validator.net/api/verify
Method: GET/POST
Input:
   StreetAddress: Street address (string)
   AdditionalAddressInfo: Apt/Suite/additional address info (string)
   City: City (string)
   PostalCode: Zip/Postal code (string)
   State: State/Province (string)
   Country: Country (string)
   CountryCode: Two-letter ISO 3166-1 country code (string); default 'US'
   Locale: IETF language tag (string); default 'en'
   APIKey: API key (string)
Output (JSON):
   status: VALID or INVALID (string)
   formattedaddress: Full Address in standardized format (string)
   streetaddress: Street address in standardized format (string)
   streetnumber: Street number in standardized format (string)
   postalcode: Zip/Postal code in standardized format (string)
   city: City in standardized format (string)
   state: State/Province in standardized format (string)
   country: Two-letter ISO 3166-1 country code (string)