canonical: https://jentic.com/apis/countrystatecity.in/country-state-city

# Countrystatecity In Country State City API

Jentic publishes the only available OpenAPI specification for Country State City API, keeping it validated and agent-ready. The Country State City API provides reference data for the world's countries, states or provinces, and cities, addressing each by its ISO code. It exposes 7 read-only endpoints covering 247+ countries, 5000+ states, and 151,000+ cities.

## For AI agents

Look up reference data for countries, states or provinces, and cities by ISO code across 7 read-only endpoints. Authenticates with an API key in the X-CSCAPI-KEY header.

## Scope

Does not geocode, route, or render maps, and provides no city demographics beyond names and ISO codes. Use for country, state, and city reference lookups only.

## Capabilities

- List all countries with their ISO codes and metadata
- Look up a single country or state by its ISO code
- Get the states or provinces within a country
- Get the cities within a country or a specific state

## Use cases

### Agent-Driven Address Form Population

An AI agent connected through Jentic can fill in the geographic fields of an address or profile form without hard-coded lists. It lists countries, then fetches the states for the chosen country and the cities for the chosen state, so the form always reflects the API's 247+ countries and 151,000+ cities rather than a stale local copy.

Example prompt: Given a selected country ISO2 code, fetch its states and then the cities of the chosen state to build a three-level address selector

### Location Reference Lookup

Systems that store an ISO country or state code often need the human-readable name and related metadata. The Country State City API resolves a country or state from its ISO2 code, so a workflow can turn stored codes into display names and validate that a state genuinely belongs to a country.

Example prompt: Resolve the ISO2 code 'US' to its country record and confirm that the state code 'CA' is one of its states

### Geographic Data Enrichment

Before geocoding or mapping, an agent often needs a clean, canonical name for a city or state. Using the Country State City API it can retrieve the standardized city and state list for a country and hand those names to a geocoding service, reducing mismatches from free-text location strings.

Example prompt: Fetch the cities of a state, match a free-text city name against that list, and pass the canonical name to a geocoder

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/countries` | List all countries |
| GET | `/countries/{iso2}` | Get a country by its ISO2 code |
| GET | `/countries/{iso2}/states` | Get the states within a country |
| GET | `/countries/{iso2}/cities` | Get the cities within a country |
| GET | `/countries/{iso2}/states/{stateIso2}/cities` | Get the cities within a specific state |

## Key resources

- **Countries** — List all countries or fetch one by its ISO2 code
- **States** — List states or provinces, globally or within a country, and fetch one by ISO2 code
- **Cities** — List the cities within a country or within a specific state

## Why Jentic

- **Setup:** Wiring Country State City by hand means registering for an API key, setting the X-CSCAPI-KEY header, and chaining the country, state, and city lookups yourself. Through Jentic you install once, import the API from the API Directory, store the key once, and your agent calls the lookups directly.
- **Permission scoping:** Every operation is read-only and countries and states are addressed by ISO code in the URL path, so a rule can bound your agent to the specific lookups it needs, such as listing countries and states only. It can never write or delete data.
- **Credential handling:** Your X-CSCAPI-KEY value is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'get the cities in a country', and Jentic returns the matching operation with its input schema so the agent calls it with the right ISO code.

## Related APIs

- **GeoNames** — Geographic database with countries, administrative divisions, and populated places
- **GeoDB Cities** — Cities, regions, and countries reference data with filtering and population figures
- **OpenCage Geocoding** — Converts a place name into latitude and longitude coordinates
- **LocationIQ** — Geocoding and reverse geocoding for addresses and coordinates

## FAQ

### Why is there no official OpenAPI spec for Country State City API?

Country State City publishes documentation but not a machine-readable OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call the API via structured tooling. It is validated against the live API and kept up to date. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### What authentication does the Country State City API use?

The Country State City API authenticates with an API key sent in the X-CSCAPI-KEY request header, per its OpenAPI spec. Through Jentic the key is stored once by your own self-hosted instance and injected when the agent calls, so it never appears in the agent's prompt or logs.

### Is there a Country State City MCP server?

You don't need an MCP server to give your agent the Country State City API. Jentic connects it directly from the API Directory: import it, store your API key once, and your agent calls the country, state, and city lookups. Operations are discovered on demand, so nothing extra loads into the agent's context.

### Can I limit what my agent is allowed to do with the Country State City API?

Yes. Every operation is a read, and countries and states are addressed by ISO code in the URL path, so a rule can bound the agent to the specific lookups it needs and it can never modify data. You might allow country and state listing but nothing else, with every call logged.

### How much geographic data does the Country State City API cover?

According to its specification the API covers 247+ countries, 5000+ states or provinces, and 151,000+ cities, each carrying ISO codes and related metadata. You can list them globally or narrow to a single country or state.

### What are the rate limits for the Country State City API?

The OpenAPI spec does not specify rate limits. Check the Country State City documentation at https://countrystatecity.in for current limits before running large batch lookups.

### How do I look up cities by country through Jentic?

Search Jentic by intent, for example 'get the cities in a country', and Jentic returns the matching operation with its input schema. Your agent supplies the country ISO2 code and reads back the city list. To run it on your own infrastructure, install Jentic One from its GitHub repo.
