Country State City API
for Cascading Dropdowns
Three lightweight JSON endpoints that fill a country, state and city form: pick a country, load its states, pick a state, load its cities. Each call costs a fixed 1 token, whatever the list size.
Try the cascading dropdown
This demo runs in your browser on our open datasets and a small city sample. It calls no API and uses no key. The real endpoints return the same id and name shape for every country, state and city.
The three endpoints
All three live under /v1/select and authenticate with apikey. Names come back in English by default; pass lang (en, es, pt, fr, de, it) to translate.
Requests (cURL)
curl "https://api.countrydataapi.com/v1/select/countries?apikey=YOUR_API_KEY&lang=en"
curl "https://api.countrydataapi.com/v1/select/states?apikey=YOUR_API_KEY&country=US"
curl "https://api.countrydataapi.com/v1/select/cities?apikey=YOUR_API_KEY&state=STATE_ID&country=US"/countries: optionallang./states: requiredcountry(ID or name)./cities: requiredstate(ID from /states), optionalcountryto disambiguate.
Responses (abridged)
{
"success": true,
"data": [
{ "id": "ES", "name": "España", "code": "ES", "phone_code": "+34", "flag": "🇪🇸" },
...
],
"count": 250,
"tokens_used": 1
}{
"success": true,
"data": [
{ "id": "66c7a6cae4bda21f4ab11d16", "name": "Alabama" },
{ "id": "66c7a6cae4bda21f4ab11d17", "name": "Alaska" },
...
]
}{
"success": true,
"data": [
{ "id": "66c7a6d1e4bda21f4ab5c825", "name": "Adelanto" },
{ "id": "66c7a6d1e4bda21f4ab5c826", "name": "Agoura Hills" },
...
]
}Wire it up in your stack
JavaScript (fetch)
const BASE = 'https://api.countrydataapi.com/v1/select';
const KEY = 'YOUR_API_KEY'; // keep it on your server for public sites
const get = (path, params) =>
fetch(`${BASE}/${path}?${new URLSearchParams({ apikey: KEY, ...params })}`)
.then((r) => r.json())
.then((r) => r.data);
const countries = await get('countries', { lang: 'en' });
const states = await get('states', { country: countryId });
const cities = await get('cities', { state: stateId, country: countryId });TypeScript SDK (@countrydataapi/sdk)
import { CountryDataApi } from '@countrydataapi/sdk';
const api = new CountryDataApi({ apiKey: 'YOUR_API_KEY' });
const countries = await api.select.countries({ lang: 'en' });
const states = await api.select.states({ country: 'ES' });
const cities = await api.select.cities({ state: 'Madrid', country: 'ES' });React
function StateSelect({ country, value, onChange }) {
const [states, setStates] = useState([]);
useEffect(() => {
if (!country) return setStates([]);
api.select.states({ country }).then(setStates);
}, [country]);
return (
<select value={value} onChange={(e) => onChange(e.target.value)} disabled={!states.length}>
<option value="">State</option>
{states.map((s) => <option key={s.id} value={s.id}>{s.name}</option>)}
</select>
);
}Angular
states = toSignal(
this.form.controls.country.valueChanges.pipe(
filter(Boolean),
switchMap((country) =>
this.http.get<{ data: Option[] }>(`${BASE}/states`, { params: { apikey, country } })
),
map((r) => r.data),
),
{ initialValue: [] },
);Full tutorials: Angular, Vue and vanilla JavaScript. Keep the key on your server for public sites.
Pricing
Plans start at €5/month with 200,000 tokens, and each select call is 1 token. The Developer plan has a 30-day trial (card required). The MCP server is free with no API key, and the country and state lists are free to download as open datasets.
See pricing plansFrequently asked questions
What is a country state city API?
It is a service that returns countries, their states or provinces and their cities as JSON, so a form can offer chained dropdowns instead of free text. CountryDataAPI exposes them as /v1/select/countries, /v1/select/states and /v1/select/cities.
How do I build a country, state and city dropdown?
Load the countries once. When the user picks one, call /v1/select/states with that country. When they pick a state, call /v1/select/cities with the state ID. Disable each child select until its parent has a value.
How much does each call cost?
Each select request costs a fixed 1 token, no matter how many items it returns. Paid plans start at €5/month with 200,000 monthly tokens.
Is there a free country state city API?
The REST API is paid, with a 30-day trial on the Developer plan (card required). What is free: the public MCP server (no API key) and the downloadable country and state datasets. Cities are only available through the API.
Can I call it directly from the browser?
The API key travels in the query string, so anything you ship to the browser exposes it. For public sites, call the API from your server and cache the lists, which change rarely.
Which languages are supported?
Pass lang with en, es, pt, fr, de or it to get names in that language. English is the default.
Ship your location form today
Create an account, grab your key and load the first dropdown in minutes.
Need suggestions as the user types? See the city autocomplete API or the zip code API.