curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Mumbay&type=city&country=IN' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Deutschlnd&type=country' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Munchen&type=city&threshold=0.2&limit=5' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
const params = new URLSearchParams({ q: 'Mumbay', type: 'city', country: 'IN' });
const response = await fetch(
`https://api.countrystatecity.in/v1/search/fuzzy?${params}`,
{ headers: { 'X-CSCAPI-KEY': 'YOUR_API_KEY' } }
);
const matches = await response.json();
matches.forEach((m) => console.log(`${m.name} (${m.match_score})`));
import requests
response = requests.get(
'https://api.countrystatecity.in/v1/search/fuzzy',
params={'q': 'Mumbay', 'type': 'city', 'country': 'IN'},
headers={'X-CSCAPI-KEY': 'YOUR_API_KEY'}
)
for match in response.json():
print(f"{match['name']} -> {match['match_score']}")
[
{
"id": 132649,
"name": "Mumbai",
"state_id": 4008,
"state_code": "MH",
"country_id": 101,
"country_code": "IN",
"latitude": "19.07283000",
"longitude": "72.88261000",
"timezone": "Asia/Kolkata",
"native": "เคฎเฅเคเคฌเค",
"match_score": 0.87,
"matched_alias": null
}
]
[
{
"id": 132649,
"name": "Mumbai",
"native": "เคฎเฅเคเคฌเค",
"match_score": 1,
"matched_alias": "เคฎเฅเคเคฌเค"
}
]
{
"status": "error",
"message": "Invalid query parameters: q: Search query must be at least 2 characters"
}
{
"status": "error",
"message": "Invalid query parameters: country: country is not a valid filter when type=country"
}
{
"status": "error",
"message": "This feature is not available on your current plan.",
"details": {
"feature": "fuzzySearch",
"currentTier": "starter",
"requiredTier": "supporter",
"upgradeUrl": "https://app.countrystatecity.in/pricing"
}
}
Fuzzy Search
Typo-tolerant search for cities, states, and countries using trigram similarity
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Mumbay&type=city&country=IN' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Deutschlnd&type=country' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Munchen&type=city&threshold=0.2&limit=5' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
const params = new URLSearchParams({ q: 'Mumbay', type: 'city', country: 'IN' });
const response = await fetch(
`https://api.countrystatecity.in/v1/search/fuzzy?${params}`,
{ headers: { 'X-CSCAPI-KEY': 'YOUR_API_KEY' } }
);
const matches = await response.json();
matches.forEach((m) => console.log(`${m.name} (${m.match_score})`));
import requests
response = requests.get(
'https://api.countrystatecity.in/v1/search/fuzzy',
params={'q': 'Mumbay', 'type': 'city', 'country': 'IN'},
headers={'X-CSCAPI-KEY': 'YOUR_API_KEY'}
)
for match in response.json():
print(f"{match['name']} -> {match['match_score']}")
[
{
"id": 132649,
"name": "Mumbai",
"state_id": 4008,
"state_code": "MH",
"country_id": 101,
"country_code": "IN",
"latitude": "19.07283000",
"longitude": "72.88261000",
"timezone": "Asia/Kolkata",
"native": "เคฎเฅเคเคฌเค",
"match_score": 0.87,
"matched_alias": null
}
]
[
{
"id": 132649,
"name": "Mumbai",
"native": "เคฎเฅเคเคฌเค",
"match_score": 1,
"matched_alias": "เคฎเฅเคเคฌเค"
}
]
{
"status": "error",
"message": "Invalid query parameters: q: Search query must be at least 2 characters"
}
{
"status": "error",
"message": "Invalid query parameters: country: country is not a valid filter when type=country"
}
{
"status": "error",
"message": "This feature is not available on your current plan.",
"details": {
"feature": "fuzzySearch",
"currentTier": "starter",
"requiredTier": "supporter",
"upgradeUrl": "https://app.countrystatecity.in/pricing"
}
}
?q=), fuzzy search ranks results by how similar they are to your query, so Mumbay still resolves to Mumbai and Beijng to Beijing.
Matching uses PostgreSQL trigram similarity over both the English name and the native name, returning a match_score so you can decide how confident a hit is.
403 on Community and Starter plans.Response
Returns an array sorted bymatch_score descending. Each item carries the standard fields for the entity (city, state, or country) at your planโs data-access level โ every plan with fuzzy search access (Supporter, Professional, Business) resolves to the full field set โ plus two fuzzy-specific fields:
match_score. The score compares the query with the English and native names, not with the translation that matched.curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Mumbay&type=city&country=IN' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Deutschlnd&type=country' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
curl -X GET 'https://api.countrystatecity.in/v1/search/fuzzy?q=Munchen&type=city&threshold=0.2&limit=5' \
-H 'X-CSCAPI-KEY: YOUR_API_KEY'
const params = new URLSearchParams({ q: 'Mumbay', type: 'city', country: 'IN' });
const response = await fetch(
`https://api.countrystatecity.in/v1/search/fuzzy?${params}`,
{ headers: { 'X-CSCAPI-KEY': 'YOUR_API_KEY' } }
);
const matches = await response.json();
matches.forEach((m) => console.log(`${m.name} (${m.match_score})`));
import requests
response = requests.get(
'https://api.countrystatecity.in/v1/search/fuzzy',
params={'q': 'Mumbay', 'type': 'city', 'country': 'IN'},
headers={'X-CSCAPI-KEY': 'YOUR_API_KEY'}
)
for match in response.json():
print(f"{match['name']} -> {match['match_score']}")
[
{
"id": 132649,
"name": "Mumbai",
"state_id": 4008,
"state_code": "MH",
"country_id": 101,
"country_code": "IN",
"latitude": "19.07283000",
"longitude": "72.88261000",
"timezone": "Asia/Kolkata",
"native": "เคฎเฅเคเคฌเค",
"match_score": 0.87,
"matched_alias": null
}
]
[
{
"id": 132649,
"name": "Mumbai",
"native": "เคฎเฅเคเคฌเค",
"match_score": 1,
"matched_alias": "เคฎเฅเคเคฌเค"
}
]
{
"status": "error",
"message": "Invalid query parameters: q: Search query must be at least 2 characters"
}
{
"status": "error",
"message": "Invalid query parameters: country: country is not a valid filter when type=country"
}
{
"status": "error",
"message": "This feature is not available on your current plan.",
"details": {
"feature": "fuzzySearch",
"currentTier": "starter",
"requiredTier": "supporter",
"upgradeUrl": "https://app.countrystatecity.in/pricing"
}
}
Related Endpoints
- Autocomplete โ deterministic exact/starts-with/fuzzy ranking with a ready-to-display
label, built for type-ahead UIs - Get All Countries โ exact/substring inline search via
?q= - Get Cities by Country โ list cities, filterable by
?q= - Lookup Country by ISO Code โ resolve a known ISO code to a country
Authorizations
API key for authentication. Get your free key at app.countrystatecity.in.
Query Parameters
Search query โ 2 to 100 characters. Case-insensitive.
2 - 100"Mumbay"
Entity type to search
city, state, country "city"
ISO 3166-1 alpha-2 country code to narrow the search (e.g., IN). Ignored when type=country.
"IN"
Maximum number of results to return (1โ50)
1 <= x <= 5010
Minimum trigram similarity score (0.1โ1.0). Lower values yield looser matches.
0.1 <= x <= 10.3
Adds localized_name and matched_locale using exact locale โ base language โ native name โ English name fallback. The English name and id stay unchanged. Supporter+ plans only.
2 - 7^[a-zA-Z]{2}(-[a-zA-Z]{2,4})?$"ja"
When true, includes the full translation JSON string. Supporter+ plans only.
true
Response
List of matching results ranked by similarity score
Entity ID (city, state, or country)
57606
English name of the matched entity
"Mumbai"
Trigram similarity score (0โ1, rounded to 2 decimals). Higher is a closer match.
0.85
ISO 3166-1 alpha-2 code (country results) or state ISO code (state results); not present on city results.
ISO 3166-1 alpha-3 code. Country results only.
ISO 3166-1 numeric code. Country results only. Coordinates tier and above.
International dialling code. Country results only.
Capital city name. Country results only.
Currency code. Country results only.
Full currency name. Country results only. Coordinates tier and above.
Currency symbol. Country results only. Coordinates tier and above.
Top-level domain. Country results only. Coordinates tier and above.
Nationality/demonym. Country results only. Coordinates tier and above.
Geographic region. Country results only.
Region identifier. Country results only.
Geographic subregion. Country results only.
Subregion identifier. Country results only.
JSON string of timezone objects. Country results only.
Flag emoji. Country results only.
Flag emoji Unicode points. Country results only. Coordinates tier and above.
Gross domestic product (USD). Country results only. Coordinates tier and above.
Area in square kilometres. Country results only. Coordinates tier and above.
Postal code format pattern. Country results only. Coordinates tier and above.
Postal code validation regex. Country results only. Coordinates tier and above.
Parent country ID. State/city results only. Ungated on state results; Coordinates tier and above on city results.
Parent country ISO2 code. State/city results only. Ungated on state results; Coordinates tier and above on city results.
Parent country name. State/city results only. Always present regardless of plan tier.
Parent state ID. City results only. Coordinates tier and above.
Parent state ISO2 code. City results only. Coordinates tier and above.
Parent state name. City results only. Always present regardless of plan tier.
FIPS code. State results only. Coordinates tier and above.
ISO 3166-2 subdivision code. State results only. Coordinates tier and above.
Administrative type (state results) or settlement type (city results). Coordinates tier and above.
Administrative level. State/city results only. Coordinates tier and above.
Parent subdivision ID (state results) or parent city ID (city results). Coordinates tier and above.
Name in native language. Ungated on country results; Coordinates tier and above on state/city results.
Population count. Coordinates tier and above.
Latitude coordinate. Ungated on country/state results; Coordinates tier and above on city results.
Longitude coordinate. Ungated on country/state results; Coordinates tier and above on city results.
IANA timezone identifier. State/city results only. Ungated on state results; Coordinates tier and above on city results.
JSON string of translations. Supporter+ plans only, and only when include_translations=true is passed.
Wikidata item identifier. Full access level only.
Localized display name selected by locale. The English name remains unchanged. Supporter+ plans only.
"ใ ใณใใค"
Translation or fallback used for localized_name: the exact locale, base language, native, or en. Supporter+ plans only.
"ja"
Native-script name if it scored higher than the English name; null otherwise
null