Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Geocoding API

REST API to convert city names to latitude/longitude coordinates. Get precise geographic coordinates with a single API call.

Features

  • 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
}
}

Get API Key

Create an account at omkar.cloud to get your API key, and use it in requests. 100 requests are free every month.

Quick Start

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
}
}
]

Installation

Python

pip install requests
importrequestsresponse=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']}")

Node.js

npm install axios
importaxiosfrom"axios";constresponse=awaitaxios.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}`);

API Reference

Endpoint

GET https://geocoding-api.omkar.cloud/geocode

Headers

HeaderRequiredDescription
API-KeyYesAPI key from omkar.cloud/api-key

Parameters

ParameterRequiredDescription
cityYesCity name to geocode (e.g., "London", "Tokyo")
stateNoState/region to disambiguate same-named cities
country_codeNoTwo-letter ISO country code (e.g., "US", "GB", "JP")

Response Fields

FieldTypeDescription
namestringCity/place name
statestringState or province
country_codestringTwo-letter ISO country code
coordinatesobjectContains latitude and longitude

Examples

Basic city lookup

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']}")

Filter by country

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']}")

Error Handling

response=requests.get(
"https://geocoding-api.omkar.cloud/geocode",
params={"city": "New York"},
headers={"API-Key": "YOUR_API_KEY"}
)
ifresponse.status_code==200:
data=response.json()
elifresponse.status_code==401:
# Invalid API keypasselifresponse.status_code==429:
# Rate limit exceededpass

Rate Limits

PlanPriceRequests/Month
Free$0100
Starter$163,000
Grow$4815,000
Scale$14875,000

Questions? We have answers.

Reach out anytime. We will solve your query within 1 working day.

Contact Us on WhatsApp about Geocoding API

Contact Us on Email about Geocoding API