Zip Code Distance Endpoint
On this page, we'll dive into the zip code distance endpoint you can use to calculate distances between zip codes.
GET/v1/distance
Calculate Distances Between Zip Codes
This endpoint calculates the distance between a single zip code and one or more other zip codes.
Required attributes
- Name
code
- Type
- string
- Description
The source zip code to calculate distances from. Example: 99501
- Name
compare
- Type
- string
- Description
Comma-separated list of zip codes to compare distances to. Example: 90210,15106
Optional attributes
- Name
country
- Type
- string
- Description
Two letter country code. Default: us
- Name
unit
- Type
- string
- Description
Unit for distance calculation. Options: km, mi. Default: km
Request
GET
/v1/distancecurl -G https://api.zipcodestack.com/v1/distance?code=99501&compare=90210%2C15106&country=us&unit=km \
-H "apikey: YOUR-API-KEY"
Full Response
{
"query": {
"code": "99501",
"compare": [
"90210",
"15106"
],
"country": "us",
"unit": "km"
},
"results": {
"90210": 3754.89,
"15106": 5115.42
}
}