REST API to convert city names to latitude/longitude coordinates. Get precise geographic coordinates with a single API call.
Convert any city name to lat/long coordinates Filter by state and country code for accuracy Covers cities worldwide 100 requests/month on free tier Example Response: {
"name" : " New York" ,
"state" : " New York" ,
"country_code" : " US" ,
"coordinates" : {
"latitude" : 40.7127281 ,
"longitude" : -74.0060152
}
} Create an account at omkar.cloud to get your API key, and use it in requests. 100 requests are free every month.
curl -X GET " https://geocoding-api.omkar.cloud/geocode?city=New%20York" \
-H " API-Key: YOUR_API_KEY" [
{
"name" : " New York" ,
"state" : " New York" ,
"country_code" : " US" ,
"coordinates" : {
"latitude" : 40.7127281 ,
"longitude" : -74.0060152
}
}
] import requests response = requests .get (
"https://geocoding-api.omkar.cloud/geocode" ,
params = {"city" : "New York" },
headers = {"API-Key" : "YOUR_API_KEY" }
)
data = response .json ()[0 ]
print (f"Coordinates: { data ['coordinates' ]['latitude' ]} , { data ['coordinates' ]['longitude' ]} " )import axios from "axios" ; const response = await axios . get ( "https://geocoding-api.omkar.cloud/geocode" , { params : { city : "New York" } , headers : { "API-Key" : "YOUR_API_KEY" } } ) ; console . log ( `Coordinates: ${ response . data [ 0 ] . coordinates . latitude } , ${ response . data [ 0 ] . coordinates . longitude } ` ) ; GET https://geocoding-api.omkar.cloud/geocode
Headers Parameter Required Description cityYes City name to geocode (e.g., "London", "Tokyo") stateNo State/region to disambiguate same-named cities country_codeNo Two-letter ISO country code (e.g., "US", "GB", "JP")
Field Type Description namestring City/place name statestring State or province country_codestring Two-letter ISO country code coordinatesobject Contains latitude and longitude
response = requests .get (
"https://geocoding-api.omkar.cloud/geocode" ,
params = {"city" : "London" },
headers = {"API-Key" : "YOUR_API_KEY" }
)
location = response .json ()[0 ]
print (f"{ location ['name' ]} : { location ['coordinates' ]['latitude' ]} , { location ['coordinates' ]['longitude' ]} " )response = requests .get (
"https://geocoding-api.omkar.cloud/geocode" ,
params = {
"city" : "Paris" ,
"country_code" : "FR"
},
headers = {"API-Key" : "YOUR_API_KEY" }
)
location = response .json ()[0 ]
print (f"{ location ['name' ]} , { location ['country_code' ]} " )Filter by state (US cities) response = requests .get (
"https://geocoding-api.omkar.cloud/geocode" ,
params = {
"city" : "Portland" ,
"state" : "Oregon"
},
headers = {"API-Key" : "YOUR_API_KEY" }
)
location = response .json ()[0 ]
print (f"{ location ['name' ]} , { location ['state' ]} " )response = requests .get (
"https://geocoding-api.omkar.cloud/geocode" ,
params = {"city" : "New York" },
headers = {"API-Key" : "YOUR_API_KEY" }
)
if response .status_code == 200 :
data = response .json ()
elif response .status_code == 401 :
# Invalid API key pass elif response .status_code == 429 :
# Rate limit exceeded pass Plan Price Requests/Month Free $0 100 Starter $16 3,000 Grow $48 15,000 Scale $148 75,000
Questions? We have answers. Reach out anytime. We will solve your query within 1 working day.