How to Validate a Postal Code & Get Location Information About it using Java

Looking for a simple & cost-effective way to validate postal codes on your website/app? Our Postal Code Validation API can do the trick. This iteration of our Address Validation API endpoint accepts postal code, country name & country code inputs and returns a ValidPostalCode Boolean in response, along with information about the state/province the postal code is located in (including coordinates). Below, I’ve provided a sample input parse request:

And its ensuing response:

Below, I’ll demonstrate how you can take advantage of this API for free using ready-to-run Java code examples provided from our API console page. In addition to these examples, you’ll also need a Cloudmersive API key to authenticate the service (you can get one for free by registering a free account on our website).

Before we get around to calling the API function, our first step is to install the client with Maven. Let’s first add a reference to the pom.xml repository:

And let’s next add a reference to the pom.xml dependency:

Next, let’s add our imports to the top of our file and call the function. Once you pass your API key & parse request through the appropriate field, you’re all set:

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.