Just start typing...
Technologies

Integration with SmartyStreets

Published August 22, 2016

While working on e-commerce websites, developers often face the issue of implementing address verification features in contact forms. SmartyStreets provides a convenient API for verification, validation, and autocomplete of addresses.

While working on e-commerce websites and online services, developers often face the problem of implementing address verification features in contact forms. This task encompasses address verification, detection of coordinates and auto-filling of missing address lines. There are various address verification services on the market, but in this article, we will take a look at just one of them – SmartyStreets. This service works with U.S. and international addresses.

Validation And Verification Addresses Integration With The Smarty Streets Service

Integration of the SmartyStreets service

SmartyStreets is an international address verification services that offers the following features:

  • Verification of the address entered by the user (validity and completeness check)
  • Detection of coordinates (latitude and longitude)
  • Search and detection of addresses in arbitrary text fragments
  • Field auto-filling once the address is entered

Today, SmartyStreets is one of the leading solutions for address verification. The most obvious advantages of SmartyStreets for businesses are shorter delivery times, less time spent on address checks, smaller number of returns, better customer service. Unlike its competitors, SmartyStreets can verify virtually any international address (over 240 countries are supported) and works faster (up to 1000 addresses per second), thus ensuring reliable and uninterrupted operation of your service.

Validation and correction of a U.S. address

In this example, we will take a look at a case of SmartyStreets integration with a platform for U.S. address validation and correction.

Smartystreets -before -valid

  1. Register on smartystreets.com
  2. Get 2 fields for working with the service: authId и authToken
  3. Create an http request to the service:
            
              String requestUrl = “https://api.smartystreets.com/street-address
              ?street=3785+South+Las+Vegs+Av
              &city=Los+Vegas
              &state=NV
              &auth-id=<AUTH_ID>
              &auth-token=<AUTH_TOKEN>”
    
              try {
                HttpGet httpGet = new HttpGet( requestUrl );
                // Create a custom response handler
                ResponseHandler< String > responseHandler = new ResponseHandler< String >() {
                  @Override
                  public String handleResponse( final HttpResponse response ) throws ClientProtocolException, IOException {
                    int status = response.getStatusLine().getStatusCode();
                    if( status >= 200 && status < 300 ) {
                      HttpEntity entity = response.getEntity();
                      return entity != null ? EntityUtils.toString( entity ) : null;
                    } else {
                      throw new ClientProtocolException( "Unexpected response status: " + status + "(" + response.getStatusLine().getReasonPhrase() + ")" );
                    }
                  }
                };
                String responseBody = httpClient.execute( httpGet, responseHandler );
              // processing of result
              } finally {
                httpClient.close();
              }
            
          
  • Get (as an example) the following result:
            
            {
            "input_index": 0,
            "candidate_index": 0,
            "delivery_line_1": "3785 Las Vegas Blvd S",
            "last_line": "Las Vegas NV 89109-4333",
            "delivery_point_barcode": "891094333992",
            "components": {
                "primary_number": "3785",
                "street_name": "Las Vegas",
                "street_postdirection": "S",
                "street_suffix": "Blvd",
                "city_name": "Las Vegas",
                "state_abbreviation": "NV",
                "zipcode": "89109",
                "plus4_code": "4333",
                "delivery_point": "99",
                "delivery_point_check_digit": "2"
            },
            "metadata": {
                "record_type": "H",
                "zip_type": "Standard",
                "county_fips": "32003",
                "county_name": "Clark",
                "carrier_route": "C024",
                "congressional_district": "01",
                "building_default_indicator": "Y",
                "rdi": "Commercial",
                "elot_sequence": "0119",
                "elot_sort": "A",
                "latitude": 36.10363,
                "longitude": -115.17237,
                "precision": "Zip9",
                "time_zone": "Pacific",
                "utc_offset": -8,
                "dst": true
            },
            "analysis": {
                "dpv_match_code": "D",
                "dpv_footnotes": "AAN1",
                "dpv_cmra": "N",
                "dpv_vacant": "N",
                "active": "Y",
                "footnotes": "A#B#H#L#M#"
            }
            
          

As you can see, the result consists of the following items:

  • Address components
  • Metadata, including latitude and longitude
  • Request processing results: how accurately the address was identified, which components were corrected

Smartystreets -after -valid

The received data can be saved to the database and used later.

Conclusion

As we can see from this example, the SmartyStreets service provides a convenient API for verification, validation, and autocomplete of addresses within the United States and around the world. In addition, the package provides a use of free operations for a month, to ensure its effectiveness.

The SmartyStreets site https://smartystreets.com/If your project requires professional assistance with web development, please contact us: hello@wave-access.com

Related Services

Application Development
Software Optimization
Project Recovery

How we process your personal data

When you submit the completed form, your personal data will be processed by WaveAccess USA. Due to our international presence, your data may be transferred and processed outside the country where you reside or are located. You have the right to withdraw your consent at any time.
Please read our Privacy Policy for more information.