Complete location data solution with cascading dropdowns and REST API
250+ countries, 4,000+ states, and 150,000+ cities with regular updates
Simple SDK implementation with automatic dropdown population
Direct API endpoints for custom implementations
Only 5KB minified with zero dependencies
Built-in caching to reduce API calls and improve performance
99.9% uptime with scalable infrastructure
Add this script to your HTML (replace with your app_key):
<script src="https://cdn.api1.in/country-state-city/sdk.js?app_key=YOUR_APP_KEY"></script>
Create three dropdown elements with these default IDs:
<select id="country"></select>
<select id="state"></select>
<select id="city"></select>
All endpoints require your app_key as a query parameter:
GET https://api1.in/country-state-city/api/v1/countries?app_key=YOUR_APP_KEY
[
{
"id": 101,
"name": "India",
"iso2": "IN",
"iso3": "IND",
"phone_code": "91",
"capital": "New Delhi"
},
{
"id": 231,
"name": "United States",
"iso2": "US",
"iso3": "USA",
"phone_code": "1",
"capital": "Washington, D.C."
}
]
GET https://api1.in/country-state-city/api/v1/states?country_id=101&app_key=YOUR_APP_KEY
GET https://api1.in/country-state-city/api/v1/cities-by-state?state_id=32&app_key=YOUR_APP_KEY
GET https://api1.in/country-state-city/api/v1/cities-by-country?country_id=101&app_key=YOUR_APP_KEY
app_key in client-side production code. For production use, call these endpoints from your backend server.
<select id="custom-country"></select>
<select id="custom-state"></select>
<select id="custom-city"></select>
<script>
document.addEventListener('DOMContentLoaded', function() {
CountryStateCitySDK.init({
countryId: 'custom-country',
stateId: 'custom-state',
cityId: 'custom-city'
});
});
</script>
CountryStateCitySDK.init({
onCountryChange: function(countryId) {
console.log('Country changed:', countryId);
},
onStateChange: function(stateId) {
console.log('State changed:', stateId);
},
onCityChange: function(cityId) {
console.log('City changed:', cityId);
}
});
// Refresh all data
CountryStateCitySDK.refresh();
// Refresh with specific country preselected
CountryStateCitySDK.refresh('101');
| Method | Description | Parameters |
|---|---|---|
init(options) |
Initialize with custom options |
countryId, stateId, cityId,onCountryChange, onStateChange, onCityChange
|
refresh(countryId) |
Reload all data | countryId (optional) |
version |
Current SDK version | None |
| Code | Description |
|---|---|
| 200 | Success |
| 400 | Invalid request |
| 401 | Unauthorized (invalid app_key) |
| 404 | Not found |
| 429 | Rate limit exceeded |
Our database is updated monthly with the latest geopolitical changes. Accuracy levels:
Standard plans include:
Yes! The SDK works in web views, or you can call the API directly from native code.
Email support@api1.in for technical assistance.