How to find zip codes in a mile radius

In my app, I need to find a list of zip codes within a given radius from an entered zip code.

Does anyone know of an API, Plug-In or formula to obtain this data along with their counties & states?

Thanks for any ideas

The Zip Code API has this exact call and should do precisely what you need!

1 Like

I’m able to receive zip codes but no text (i.e. county or state data).

Any suggestions?

Use the “Zip Code to Location” call to retrieve city and state. Same plugin, different call selected in “get external data from API”. Use it the same way, select your input as the zip value and compose the expression to read like below:

3 Likes

I wasn’t able to get it to work.

Am I suppose to run the radius call separate and then run the location call?

Yes you’re right you will have to make two calls. First to get the a list of zip codes and then get the city and state for each zip code.
This is because the “Get Zip Codes in Radius” call implemented in the bubble zip code api returns a list of zips. I looked at the api documentation and also the api source code in bubble and realized that the developer is using the minimal version of “Get Zip Codes in Radius” - see https://www.zipcodeapi.com/API#radius
If you want to make one call, then you can simply create your own api connector call and don’t use the minimal version.
You can take a look at the source code of zip code api in bubble here https://bubble.io/plugin_editor?id=1489136635322x734883709591224300&tab=tabs-3
Expand the “Get Zip Codes in Radius” call and just replicate this in your own api connector. But remember to remove the “minimal” at the end of the url.
So your call should be
https://www.zipcodeapi.com/rest/[api_key]/radius.json/[zip_code]/[distance]/[units]
instead of the current one in the api which is
https://www.zipcodeapi.com/rest/[api_key]/radius.json/[zip_code]/[distance]/[units]?minimal

That will return you a response like this:
{
“zip_codes”: [
{
“zip_code”: “19129”,
“distance”: 1.552,
“city”: “Philadelphia”,
“state”: “PA”
},
{
“zip_code”: “19144”,
“distance”: 0,
“city”: “Philadelphia”,
“state”: “PA”
},
{
“zip_code”: “19141”,
“distance”: 1.537,
“city”: “Philadelphia”,
“state”: “PA”
},
{
“zip_code”: “19119”,
“distance”: 1.608,
“city”: “Philadelphia”,
“state”: “PA”
},
{
“zip_code”: “19138”,
“distance”: 1.733,
“city”: “Philadelphia”,
“state”: “PA”
}
]
}

This thread discusses how to display API call in a repeated group.
Hope this helps a bit.

1 Like

Yes, this was very helpful. However Im still in need of the returned data needing to include"county" names. (key component to my app)

Any APIs that has “county” names as their returned data?

You can use google geolocation api which gives you more information about a certain zip or even postal codes.But you will have to do some work to retrieve the values from the json response.
You can use this api call
http://maps.googleapis.com/maps/api/geocode/json?address=[zip or postal code]
e.g.
http://maps.googleapis.com/maps/api/geocode/json?address=19144 returns the following response

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "19144",
               "short_name" : "19144",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Philadelphia",
               "short_name" : "Philadelphia",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Philadelphia County",
               "short_name" : "Philadelphia County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Pennsylvania",
               "short_name" : "PA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Philadelphia, PA 19144, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.052241,
                  "lng" : -75.15390599999999
               },
               "southwest" : {
                  "lat" : 40.0134289,
                  "lng" : -75.202496
               }
            },
            "location" : {
               "lat" : 40.0358382,
               "lng" : -75.174734
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.052241,
                  "lng" : -75.15390599999999
               },
               "southwest" : {
                  "lat" : 40.0134289,
                  "lng" : -75.202496
               }
            }
         },
         "place_id" : "ChIJd-vvjze4xokRCZ1t4bxxPqI",
         "types" : [ "postal_code" ]
      }
   ],
   "status" : "OK"
}

As you can see there a lot of info including the county. I’m sure if you dig into the api documentation there might be a way to strip it down to easily process the response in bubble.

Is it possible to use an API thats not in the Bubble library?

Zip-Codes.com has the mile radius finder that returns the county & other data I need.

On their site they talk about the “Zip Code API” feature but frankly it’s all a foreign lanuage to me.

Anyone care to shed any light on this?

I’m still a bit confused. When I complete the 1st call for the zips that works fine but how do I set up the 2nd call for the city & state to again display in a repeating group?

EDIT******

I found an API @ Zipwise.com that return Zip Codes, City, State, County & Distance with only 1 call.

1 Like

This plugin is great but it works with US zip codes only. Outside of US what options do I have to be able to use a zip code?

The https://zipcodedownload.com/ZipCodeApi will meet your needs. Will return Zip Codes, City, State, County & Distance with only 1 call for USA and Canada.

1 Like

Can you use this to get items with in a radius of a geo location?