Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

GeoDB

REST API for city and geographic data. Returns city name, state, country, coordinates, population, and capital status.

Features

  • Single endpoint for city lookups worldwide
  • Returns structured JSON with full location data
  • Filter by city name and/or country code
  • 100 requests/month on free tier
  • Example Response:
[
  {
    "city_name": "New York",
    "state": "New York",
    "country_code": "US",
    "is_capital": false,
    "coordinates": {
      "latitude": 40.6943,
      "longitude": -73.9249
    },
    "population": 18713220
  }
]

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://city-api.omkar.cloud/city?name=New%20York" \
  -H "API-Key: YOUR_API_KEY"
[
  {
    "city_name": "New York",
    "state": "New York",
    "country_code": "US",
    "is_capital": false,
    "coordinates": {
      "latitude": 40.6943,
      "longitude": -73.9249
    },
    "population": 18713220
  }
]

Installation

Python

pip install requests
import requests

response = requests.get(
    "https://city-api.omkar.cloud/city",
    params={"name": "New York"},
    headers={"API-Key": "YOUR_API_KEY"}
)

cities = response.json()

Node.js

npm install axios
import axios from "axios";

const response = await axios.get("https://city-api.omkar.cloud/city", {
    params: { name: "New York" },
    headers: { "API-Key": "YOUR_API_KEY" }
});

const cities = response.data;

API Reference

Endpoint

GET https://city-api.omkar.cloud/city

Headers

Header Required Description
API-Key Yes API key from omkar.cloud/api-key

Parameters

Parameter Required Default Description
name No City name (e.g., "New York", "Tokyo")
country_code No Two-letter ISO country code (e.g., "US", "JP")

Response

[
  {
    "city_name": "string",
    "state": "string",
    "country_code": "string",
    "is_capital": "boolean",
    "coordinates": {
      "latitude": "number",
      "longitude": "number"
    },
    "population": "number"
  }
]
Field Type Description
city_name string City name
state string State or province
country_code string Two-letter ISO code
is_capital boolean Whether it's the country's capital
coordinates.latitude number Latitude coordinate
coordinates.longitude number Longitude coordinate
population number City population

Examples

Search by city name

response = requests.get(
    "https://city-api.omkar.cloud/city",
    params={"name": "Tokyo"},
    headers={"API-Key": "YOUR_API_KEY"}
)

for city in response.json():
    print(f"{city['city_name']}, {city['country_code']}: {city['population']}")

Filter by country

response = requests.get(
    "https://city-api.omkar.cloud/city",
    params={"name": "London", "country_code": "GB"},
    headers={"API-Key": "YOUR_API_KEY"}
)

london_uk = response.json()[0]

Get coordinates

const { data } = await axios.get("https://city-api.omkar.cloud/city", {
    params: { name: "Paris" },
    headers: { "API-Key": "YOUR_API_KEY" }
});

const { latitude, longitude } = data[0].coordinates;

Error Handling

response = requests.get(
    "https://city-api.omkar.cloud/city",
    params={"name": "InvalidCity123"},
    headers={"API-Key": "YOUR_API_KEY"}
)

if response.status_code == 200:
    data = response.json()
    if not data:
        # No cities found
        pass
elif response.status_code == 401:
    # Invalid API key
    pass
elif response.status_code == 429:
    # Rate limit exceeded
    pass

Rate Limits

Plan Price Requests/Month
Free $0 100
Starter $16 3,000
Grow $48 15,000
Scale $148 75,000

Support

Contact Us on WhatsApp about GeoDB

Contact Us on Email about GeoDB