Polygon Search Endpoint
On this page, we'll dive into the polygon search endpoint you can use to find all postal codes within a custom polygon area.
This endpoint costs 10 credits per request.
POST/v1/polygon
Find Codes Inside Polygon
This endpoint returns all postal codes within a specified polygon area defined by coordinate pairs.
Required attributes
- Name
country- Type
- string
- Description
Two letter country code (query parameter). Example: us
- Name
coordinates- Type
- array
- Description
Array of coordinate pairs [longitude, latitude] defining the polygon. Minimum 3 points required.
Request
POST
/v1/polygoncurl -X POST https://api.zipcodestack.com/v1/polygon?country=us \
-H "apikey: YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"coordinates": [
[-149.9, 61.2],
[-149.8, 61.2],
[-149.8, 61.3],
[-149.9, 61.3],
[-149.9, 61.2]
]
}'
Full Response
{
"query": {
"country": "us"
},
"results": [
{
"code": "99501",
"city": "Anchorage",
"state": "AK",
"city_en": "Anchorage",
"state_en": "Alaska",
"latitude": 61.2181,
"longitude": -149.9003,
"distance": 0
}
]
}