Implementing Zip Code API in a Web Application

vteam #642 was hired to work on a web application which connects patients in need of urgent orthopedic care directly to the orthopedic surgeons in their local area. The client had a unique requirement of displaying search result within a certain radius of the searched zip code.

Solution

After doing some R&D, vteams engineer came up with a solution to use an open source Zip Code Distance, Radius and Location API. This API provides the following methods to calculate:

  • Distance between Zip Codes
  • Zip Code in Radius
  • Zip Code to Location
  • Location to Zip Code
  • Custom SQL Search
  • Find Close Zip Code
    .

These methods can be implemented as per individual needs.

In the current scenario, Doctors are already registered with their zip codes and other details. When an end user search by entering the zip code of his/her area and specifying some radius, he/she will get the search results sorted by the distance within the specified radius. vteams engineer used Zip Code in Radius method.

The following steps were implemented to:

  • Get the user input for the following two fields:
    • Zip Code
    • Radius
  • Request the data from the API by using the following parameters (of API):
    • Zip code
    • Radius
    • Distance Metrics, Km/Miles
    • Expected Output format (JSON/XML)
  • Parse the results as per already set search criteria
  • Sort the results in ascending order
    .

Conclusion

As a result, the end user will get the search results in ascending order based on the zip code and specified radius.