Autocomplete Endpoint
Returns the postal codes of a country that start with what the user typed so far, in order, each with its place.
Use it to power postal code suggestions in address forms and to fill in the city automatically once a code is picked.
This endpoint costs 1 credit per request. Wait until the user has typed two or three characters and debounce the input to keep requests low.
GET/v1/autocomplete
Autocomplete
Required attributes
- Name
q- Type
- string
- Description
The beginning of the postal code. Matching ignores case.
- Name
country- Type
- string
- Description
Two letter country code. Example: at
Optional attributes
- Name
limit- Type
- integer
- Description
How many codes to return, 1 to 50. Default 10.
Response
results lists distinct postal codes in ascending order. Each carries the first place, state and state code we have for it; when a code covers several places, call /v1/search with the chosen code to get all of them.
Request
GET
/v1/autocompletecurl -G https://api.zipcodestack.com/v1/autocomplete \
-d q=10 \
-d country=at \
-d limit=3 \
-H "apikey: YOUR-API-KEY"
Response
{
"query": {
"q": "10",
"country": "AT",
"limit": 3
},
"results": [
{
"postal_code": "1010",
"city": "Wien, Innere Stadt",
"state": "Wien",
"state_code": "09"
},
{
"postal_code": "1020",
"city": "Wien, Leopoldstadt",
"state": "Wien",
"state_code": "09"
},
{
"postal_code": "1030",
"city": "Wien, Landstraße",
"state": "Wien",
"state_code": "09"
}
]
}