A REST API providing global geographical data for countries, states, and cities. Freely hosted on Vercel and open for contributions.
- Worldwide geographical data coverage
- Lightweight, fast responses
- Consistent RESTful interface
- No authentication required
- CORS-enabled for browser applications
Endpoint | Description |
---|---|
GET /countries |
Retrieve a lightweight list of all countries with basic information |
GET /countries/:id |
Get full details for a specific country by ID |
GET /countries/iso/:code |
Look up a country by ISO code (both ISO2 and ISO3 supported) |
GET /countries/search/:term |
Search countries by name |
Endpoint | Description |
---|---|
GET /countries/:id/states |
Get all states/provinces for a specific country |
GET /states/:id |
Get details for a specific state by ID |
Endpoint | Description |
---|---|
GET /countries/:id/cities |
Get all cities in a specific country |
GET /states/:id/cities |
Get all cities in a specific state |
Endpoint | Description |
---|---|
GET /regions |
List all distinct geographical regions |
GET /regions/:region/countries |
Get all countries in a specific region |
Endpoint | Description |
---|---|
GET /health |
Get server health, memory usage, and uptime information |
https://city-state-country.vercel.app
Fetch all countries:
curl https://city-state-country.vercel.app/countries
Search for countries containing "united":
curl https://city-state-country.vercel.app/countries/search/united
Get states in the United States (assuming ID is 233):
curl https://city-state-country.vercel.app/countries/233/states
- Clone the repository
git clone /~https://github.com/DeepakKumarKhatri/city-state-country
cd city-state-country
- Install dependencies
npm install
- Start the development server
npm start
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is open-source and available under the OBbL.
This repository uses the dataset from countries-states-cities-database, available under the Open Database License (ODbL).
Special thanks to all open source contributors for creating and curating this data in a useful and accessible format.
⭐ If you find this API useful, please consider giving it a star on GitHub!