Skip to main content

Resolve a city or place name to latitude, longitude, and timezone

Resolve a city or place name to coordinates and timezone. Returns up to {limit} matches. When a query is ambiguous (e.g. 'Fatehabad' exists in multiple states), multiple results are returned so the developer can present a disambiguation UI or use the first result. Examples: ?q=Mumbai, ?q=Rome Italy, ?q=New York USA, ?q=London UK Pass state/country for precise results: ?q=Fatehabad,Haryana or ?q=Fatehabad&country=in

Endpoint

GET /v1/utils/geocode

Request parameters

FieldTypeRequiredDescription
qstringYesCity or location name. Use comma for disambiguation: 'Fatehabad,Haryana'
limitintegerNoMaximum results to return
countrystring | nullNoISO country code to narrow results, e.g. 'in', 'us'

Example request

curl -X GET "https://api.asterwise.com/v1/utils/geocode?q=Mumbai&limit=3" \
-H "Authorization: Bearer YOUR_API_KEY"

Example response

{
"success": true,
"message": "success",
"data": {
"query": "Mumbai",
"count": 1,
"ambiguous": false,
"results": [
{
"label": "Mumbai, Maharashtra, India",
"city": "Mumbai",
"state": "Maharashtra",
"country": "India",
"latitude": 19.054999,
"longitude": 72.8692035,
"timezone": "Asia/Kolkata",
"place_id": "230315199"
}
],
"tip": null
}
}

Response fields

FieldTypeDescription
successbooleanTrue if the request succeeded
messagestringHuman-readable status message
dataobject
data.querystringThe search query as received.
data.countintegerNumber of results returned.
data.ambiguousbooleanTrue if multiple locations matched the query.
data.resultsarray[object]List of matching locations.
data.results[].labelstringHuman-readable location label.
data.results[].citystring | nullCity name.
data.results[].statestring | nullState or region.
data.results[].countrystring | nullCountry name.
data.results[].latitudenumberLatitude in decimal degrees.
data.results[].longitudenumberLongitude in decimal degrees.
data.results[].timezonestringIANA timezone identifier.
data.results[].place_idstringNominatim place ID.
data.tipstring | nullDisambiguation hint when ambiguous is True.

Errors

CodeDescriptionReference
authentication_failedMissing or invalid API key.authentication_failed
ephemeris_unavailableUpstream ephemeris service error.ephemeris_unavailable
insufficient_tierAPI key tier does not include this endpoint.insufficient_tier
internal_errorUnexpected server error.internal_error
ip_rate_limit_exceededToo many requests in a short window.ip_rate_limit_exceeded
payload_too_largeRequest body exceeds the size limit.payload_too_large
resource_not_foundReferenced resource was not found.resource_not_found
validation_errorRequest body failed schema validation.validation_error