{"id":50488580,"url":"https://github.com/txuli/geohub-api","last_synced_at":"2026-06-02T00:30:55.092Z","repository":{"id":342698847,"uuid":"1137766096","full_name":"txuli/geohub-api","owner":"txuli","description":"A simple API providing information about cities and countries.","archived":false,"fork":false,"pushed_at":"2026-05-09T16:12:17.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-09T17:41:22.964Z","etag":null,"topics":["api-country","bun","country-list","express"],"latest_commit_sha":null,"homepage":"https://geohub.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/txuli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-19T20:05:33.000Z","updated_at":"2026-05-09T16:12:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/txuli/geohub-api","commit_stats":null,"previous_names":["txuli/finda.city","txuli/geohub-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/txuli/geohub-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txuli%2Fgeohub-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txuli%2Fgeohub-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txuli%2Fgeohub-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txuli%2Fgeohub-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/txuli","download_url":"https://codeload.github.com/txuli/geohub-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txuli%2Fgeohub-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33800675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-country","bun","country-list","express"],"created_at":"2026-06-02T00:30:54.935Z","updated_at":"2026-06-02T00:30:55.081Z","avatar_url":"https://github.com/txuli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeoHub API\n\nA RESTful API for discovering countries and cities worldwide, with geolocation features and Wikipedia data integration.\n\n## Overview\n\nFinda.city is a geographic data API that provides information about countries and cities around the world. It features IP-based geolocation, proximity search, and integrates with Wikipedia to provide enriched data about locations.\n\n## Features\n\n- 🌍 **Country Information**: Get data about countries including population, life expectancy, coordinates, and capital cities\n- 🏙️ **City Search**: Find cities by name, country, or population range\n- 📍 **Proximity Search**: Find nearby cities based on IP geolocation\n- 📊 **Wikipedia Integration**: Automatically enriches data with information from Wikidata\n- 🗄️ **MongoDB Database**: Efficient data storage with geospatial indexing\n- ⚡ **Built with Bun**: Fast runtime and package management\n\n## Tech Stack\n\n- **Runtime**: [Bun](https://bun.sh)\n- **Framework**: Express.js\n- **Database**: MongoDB with Mongoose\n- **Language**: TypeScript\n\n\n## API Endpoints\n\n### Health Check\n```\nGET /health\n```\nReturns the health status of the API.\n\n**Response:**\n```json\n{\n  \"ok\": true\n}\n```\n\n### Countries\n\n#### Get All Countries\n```\nGET /countries\n```\nReturns a list of all countries in the database.\n\n**Response:**\n```json\n[\n  {\n    \"CountryLabel\": \"spain\",\n    \"country\": \"Spain\",\n    \"CapitalLabel\": \"Madrid\",\n    \"iso2\": \"ES\",\n    \"population\": 47450795,\n    \"lifeExpectancy\": 83.2,\n    \"continent\": \"Europe\",\n    \"lat\": 40.4,\n    \"lon\": -3.7,\n  }\n]\n```\n\n#### Get Country by Name\n```\nPOST /country\n```\nGet information about a specific country.\n\n**Request Body:**\n```json\n{\n  \"country\": \"spain\"\n}\n```\n\n**Response:**\n```json\n[\n  {\n    \"CountryLabel\": \"spain\",\n    \"country\": \"Spain\",\n    \"CapitalLabel\": \"Madrid\",\n    \"iso2\": \"ES\",\n    \"population\": 47450795,\n    \"lifeExpectancy\": 83.2,\n    \"continent\": \"Europe\",\n    \"lat\": 40.4,\n    \"lon\": -3.7,\n  }\n]\n```\n\n#### Update Countries from Wikipedia\n```\nGET /getIdWiki\n```\nAdmin endpoint to update country data from Wikidata (life expectancy, wiki IDs, etc.).\n\n### Cities\n\n#### Get Cities Near You\n```\nGET /nearme\n```\nReturns the 5 closest cities to your current location based on your IP address.\n\n**Response:**\n```json\n[\n  {\n    \"city\": \"Madrid\",\n    \"cityLabel\": \"madrid\",\n    \"country\": \"507f1f77bcf86cd799439011\",\n    \"location\": {\n      \"type\": \"Point\",\n      \"coordinates\": [-3.7038, 40.4168]\n    },\n    \"population\": 3223334\n  }\n]\n```\n\n#### Search Cities\n```\nGET /getCity\n```\nSearch for cities by name, country, and/or population range.\n\n**Query Parameters:**\n- `city` (string): City name (case-insensitive)\n- `country` (string): Country name (case-insensitive)\n- `minPopulation` (number): Minimum population\n- `maxPopulation` (number): Maximum population\n\n**Example:**\n```\nGET /getCity?city=madrid\u0026country=spain\nGET /getCity?minPopulation=1000000\u0026maxPopulation=5000000\n```\n\n**Response:**\n```json\n[\n  {\n    \"city\": \"Madrid\",\n    \"cityLabel\": \"madrid\",\n    \"country\": \"507f1f77bcf86cd799439011\",\n    \"location\": {\n      \"type\": \"Point\",\n      \"coordinates\": [-3.7038, 40.4168]\n    },\n    \"population\": 3223334\n  }\n]\n```\n\n## Installation\n\n### Prerequisites\n- [Bun](https://bun.sh) installed\n- MongoDB instance running\n- Redis instance running (optional, for ratelimit)\n\n### Setup\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/txuli/finda.city.git\ncd finda.city\n```\n\n2. Install dependencies:\n```bash\nbun install\n```\n\n3. Configure environment variables (create a `.env` file):\n```env\nPORT=3000\nMONGODB_URI=mongodb://localhost:27017/finda\nREDIS_URL=redis://localhost:6379\n```\n\n4. Start the server:\n```bash\nbun run src/index.ts\n```\n\nThe API will be running at `http://localhost:3000`\n\n## Data Models\n\n### Country Schema\n```typescript\n{\n  CountryLabel: string,      // Lowercase country name\n  country: string,           // Capitalized country name\n  CapitalLabel: string,      // Capital city name\n  iso2: string,              // ISO 3166-1 alpha-2 code\n  population: number,        // Country population\n  lifeExpectancy: number,    // Life expectancy in years\n  continent: string,         // Continent name\n  lat: number,              // Latitude\n  lon: number,              // Longitude\n  fullData: boolean,        // Data completeness flag\n  wikiId: string            // Wikidata ID (e.g., \"Q29\")\n}\n```\n\n### City Schema\n```typescript\n{\n  city: string,              // City name\n  cityLabel: string,         // Lowercase city name\n  country: ObjectId,         // Reference to Country\n  location: {\n    type: \"Point\",\n    coordinates: [number, number]  // [longitude, latitude]\n  },\n  population: number         // City population\n}\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxuli%2Fgeohub-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftxuli%2Fgeohub-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxuli%2Fgeohub-api/lists"}