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": "supporter",
"requiredTier": "professional",
"upgradeUrl": "https://app.countrystatecity.in/pricing"
}
}
Search Endpoints
Fuzzy Search
Typo-tolerant search for cities, states, and countries using trigram similarity
GET
/
v1
/
search
/
fuzzy
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": "supporter",
"requiredTier": "professional",
"upgradeUrl": "https://app.countrystatecity.in/pricing"
}
}
Search cities, states, and countries by an approximate query that tolerates misspellings, transliterations, native-script variants, and stored translations. Unlike the exact/substring inline search (
?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.
Availability: Professional plan and above. Returns
403 on Community, Starter, and Supporter plans.Each result is scored against the English and native names. Queries with at least 3 characters also check stored translations. Responses are cached separately by query, filters, plan, locale, and translation output.
Authentication
string
required
Your API key for authentication
Query Parameters
string
required
The search text. 2–100 characters. Matched case-insensitively against the English and native names.
string
default:"city"
What to search. One of
city, state, or country.string
Restrict results to a single country by ISO 3166-1 alpha-2 code, e.g.
IN, US. Case-insensitive (auto-uppercased). Applies to type=city and type=state only — sending it with type=country returns 400.integer
default:"10"
Maximum number of results to return. 1–50.
number
default:"0.3"
Minimum trigram similarity a row must reach to be returned. 0.1–1. Lower values are more permissive (more, looser matches); higher values are stricter. The default
0.3 is a good balance for typo tolerance.string
Add
localized_name and matched_locale to each result. Example: ja or pt-BR. Professional and Business plans only. See Localized Place Names.boolean
default:"false"
Include the full raw
translations JSON string. Professional and Business plans only.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 — Professional and Business resolve to the full field set — plus two fuzzy-specific fields:
number
Trigram similarity of the best-matching name (English or native), from
0 to 1, rounded to 2 decimals. Higher means a closer match.string | null
The native name when it scored higher than the English name (e.g. a Devanagari or Han query that matched the local spelling).
null when the English name was the better match.string
The display name for
locale, when requested and available on your plan.string
The locale used for
localized_name, including fallback values such as native or en.A result found only through a translation can have a low
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": "supporter",
"requiredTier": "professional",
"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
Was this page helpful?