Retrieve detailed information for a specific state or province using the country’s ISO2 code and the state’s ISO2 code.
Path Parameters
ISO2 code of the country (e.g., “IN”, “US”)
ISO2 code of the state/province (e.g., “MH” for Maharashtra, “CA” for California)
Authentication
Your API key for authentication
Response
Unique identifier for the state/province
Official name of the state/province
Unique identifier of the parent country
ISO2 code of the parent country
ISO2 code for the state/province
Administrative division type (e.g., “state”, “province”, “region”)
Approximate latitude coordinate of the state/province center
Approximate longitude coordinate of the state/province center
curl -X GET 'https://api.countrystatecity.in/v1/countries/IN/states/MH' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
{
"id": 4008,
"name": "Maharashtra",
"country_id": 101,
"country_code": "IN",
"iso2": "MH",
"type": "state",
"latitude": "19.75147980",
"longitude": "75.71388840"
}
Common Use Cases
Use coordinates for distance calculations and mapping.const calculateDistance = (lat1, lng1, lat2, lng2) => {
const R = 6371; // Earth's radius in km
const dLat = (lat2 - lat1) * Math.PI / 180;
const dLng = (lng2 - lng1) * Math.PI / 180;
const a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLng/2) * Math.sin(dLng/2);
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
};
const getDistanceFromState = async (countryCode, stateCode, targetLat, targetLng) => {
const state = await getStateDetails(countryCode, stateCode);
return calculateDistance(
parseFloat(state.latitude),
parseFloat(state.longitude),
targetLat,
targetLng
);
};
Administrative Type Validation
Validate administrative division types for data processing.const isStateType = async (countryCode, stateCode, expectedType) => {
const state = await getStateDetails(countryCode, stateCode);
return state && state.type === expectedType;
};
Use this endpoint when you need precise geographical coordinates or want to validate specific state/country combinations.