Logo Lanfrica

blingyplus/ghana-location-api

Domain:

geospatialdigital infrastructure

Record type:

software
Creator:
bli
Host:
Unofficial free Geo-location API for regions, districts, constituencies, cities, towns etc. # Ghana Location API A read-only REST API providing normalized administrative location data for Ghana, including countries, regions, districts, constituencies, and cities. ghana-location-api.vercel.a… ## Overview This API serves as a canonical source for Ghana's administrative geography hierarchy: ``` Country └── Regions └── Districts / Metros / Municipals └── Constituencies └── Cities / Towns ``` The API is designed to be: - **Read-only** - No mutations, no user data - **Fast** - Optimized queries with proper indexing - **Stable** - Slug-based identifiers that never change - **Cache-friendly** - HTTP cache headers on all responses ## Prerequisites - Go 1.22 or higher - PostgreSQL (or Supabase) - Supabase CLI (if using Supabase) ## Local Setup ### 1. Clone the repository ```bash git clone github.com cd ghana-location-api ``` ### 2. Install dependencies ```bash go mod download ``` ### 3. Configure environment Create a `.env` file in the root directory: ```env DATABASE_URL=postgres://user:password@localhost:5432/ghana_location PORT=8080 ``` For Supabase, you can get your connection string from your Supabase project dashboard or use: ```bash supabase db get-connection-string ``` ### 4. Run database migrations Run the migration using the migrate command: ```bash go run cmd/migrate/main.go ``` Or manually using psql: ```bash psql $DATABASE_URL -f migrations/001_initial_schema.sql ``` ### 5. Seed data Seed the database with location data: ```bash go run cmd/seed/main.go ``` This will load data from the JSON files in the `data/` directory: - `countries.json` - `regions.json` - `districts.json` - `constituencies.json` - `cities.json` ### 6. Run the API ```bash go run cmd/api/main.go ``` The API will start on port 8080 (or the port specified in your `.env` file). ## API Endpoints All endpoints are prefixed with `/api/v1`. ### Countries - `GET /api/v1/countries` - List all cou …

Licenses