GeoHub — Free Country & City REST API
GeoHub is a free REST API that provides detailed geographic data for every country and city worldwide. No API key required — just make HTTP GET requests and receive instant JSON responses.
Why GeoHub?
- 100% free — no sign-up, no API key, no rate limits
- Every country in the world with full data
- City data with population, coordinates and more
- IP-based geolocation endpoint
- Fast JSON responses in milliseconds
API Endpoints
GET /getCountry
Returns full data for a single country. Example: https://api.geohub.pm/getCountry?country=Spain
Returns: name, capital, population, area, coordinates, time zones, languages, currencies, flag, ISO codes.
GET /getCountries
Returns all countries in the database. Example: https://api.geohub.pm/getCountries
GET /getRandomCountry
Returns one or more random countries. Example: https://api.geohub.pm/getRandomCountry?limit=3
GET /getCity
Returns cities filtered by country and optional population range. Example: https://api.geohub.pm/getCity?country=Spain&minPopulation=100000
GET /getrandomCity
Returns one or more random cities. Example: https://api.geohub.pm/getrandomCity?limit=5
GET /nearme
Returns up to 5 cities closest to your IP-based location. Example: https://api.geohub.pm/nearme?max=50000
Data Fields per Country
Each country response includes: official name, capital city, population, area in km², latitude and longitude, time zones, official languages, currencies, flag emoji, ISO 3166-1 alpha-2 code, ISO 3166-1 alpha-3 code.
Frequently Asked Questions
Is GeoHub free to use?
Yes, GeoHub is completely free with no API key required and no usage limits.
What countries does GeoHub cover?
GeoHub covers all countries worldwide.
Does GeoHub support IP geolocation?
Yes, the /nearme endpoint detects your location via IP and returns the nearest cities.
What format are responses in?
All responses are JSON.
Base URL: https://api.geohub.pm — Website: https://geohub.pm