Search states by city
Country Data API provides detailed information about +200 different countries
HTTP GET
https://api.countrydataapi.com/v1/states/city
Returns the state that contains that city.
Some examples of the structure
Country: USA, State: Colorado, City: Denver
Country: Spain, State: Comunidad Valenciana, City: Valencia
Relevant Information
Keep in mind that there are many cities with the same name
According to the requested fields, there will be 3 types of requests:
BASIC: Returns the fields id, state_name, lang Each state will cost 1 token
NORMAL: Returns the field state_cities [All IDs and names of cities in the state] Each city will cost 1 token
ADVANCED: Returns the field state_zip_codes [All postal codes of the city] Each postal code costs 1 token
Query Params
Parameter | Type | Description |
---|---|---|
apikey | required, token | Account authentication key |
city | required, string | Name of the city found in the state |
limitToken | optional, number | 1000 (default). Maximum number of tokens you want to spend on this request |
fields | optional, string | id,lang,state_name (default). Expected fields in the response |
lang | optional, lang | en (default). Expected language of the response |
Sample Response
[
{
"id": "8dd25479-067a-43b0-ac4a-8e7faf2bcafb",
"state_name":"Takhar",
"lang":"en",
"state_cities":[
{
id: "8dd25476-067a-43b0-ac4b-8e7faf2bcbfb",
"city_name":"City",
...
}
],
"state_zip_codes": [
00000,
000001,
...
]
}
]