Skip to content

Repository files navigation

OpenNG REST API 🇳🇬

License: MIT NestJS REST API Prisma ORM TypeScript Contributions Welcome

An open-source, robust, and strongly-typed RESTful API providing comprehensive, verified data on Nigerian geography, governance, education, culture, history, and tourism.


📖 Table of Contents


🌟 What is OpenNG?

OpenNG REST API is a standardized, public RESTful API for Nigerian socio-economic, political, cultural, educational, and geographic data.

It structures verified data across Nigeria’s 36 states and the Federal Capital Territory (FCT), 774 Local Government Areas (LGAs), wards, political offices, historical timelines, higher institutions, ethnic groups, languages, and tourism destinations into a predictable and developer-friendly REST interface.


🎯 Why OpenNG?

The Problem

  • Scattered Data: Nigerian public data is fragmented across government websites, PDFs, and unofficial repositories.
  • Inconsistent Naming & Formats: LGA names, state boundaries, and historical dates frequently suffer from spelling inconsistencies and lack standardized schemas.
  • Integration Friction: Developers building fintech KYC, civic apps, or travel platforms must manually compile and maintain separate datasets.

The Solution

  • Unified REST Endpoints: Intuitive, predictable REST resource paths (/api/v1/states, /api/v1/universities, /api/v1/governors).
  • Standardized Envelopes: Consistent JSON payload responses with built-in pagination metadata (total, page, limit, totalPages).
  • Interactive Documentation: Self-documenting OpenAPI / Swagger UI accessible out of the box.
  • Open & Free: 100% open-source under the MIT License.

✨ Key Highlights

  • High Performance: Fast response times with built-in in-memory caching and response compression.
  • 📐 Strict Validation: Request validation via NestJS ValidationPipe and class-validator.
  • 📖 Interactive Swagger UI: Explore and test all endpoints directly in your browser.
  • 🛡️ Enterprise Security: Helmet security headers, CORS protection, request rate limiting, and structured JSON logging.

🗂️ Knowledge Domains

                               ┌───────────────┐
                               │ OpenNG REST   │
                               └───────┬───────┘
          ┌─────────────┬──────────────┼──────────────┬─────────────┐
          ▼             ▼              ▼              ▼             ▼
    ┌───────────┐ ┌───────────┐  ┌───────────┐  ┌───────────┐ ┌───────────┐
    │ Geography │ │Governance │  │ Education │  │  Culture  │ │  History  │
    └───────────┘ └───────────┘  └───────────┘  └───────────┘ └───────────┘
Domain Description Base Endpoints
🌍 Geography Administrative divisions & geopolitical boundaries /api/v1/states, /api/v1/lgas, /api/v1/regions, /api/v1/wards
🏛️ Politics & Governance Executive offices, electoral history, and parties /api/v1/governors, /api/v1/presidents, /api/v1/political-parties, /api/v1/offices
🎓 Education Accredited tertiary learning institutions /api/v1/universities, /api/v1/polytechnics, /api/v1/colleges
🎭 Culture & Heritage Indigenous identities, languages & monarchs /api/v1/ethnic-groups, /api/v1/languages, /api/v1/festivals, /api/v1/traditional-institutions
📜 History Timeline of Nigerian milestones & regimes /api/v1/historical-events, /api/v1/people
🏖️ Tourism Heritage landmarks, waterfalls, nature parks /api/v1/tourism-sites

🔌 Consuming the REST API

API Base URL & Versioning

All API requests are prefixed with the /api/v1 namespace:

https://api.openng.org/api/v1 (Production)
http://localhost:3000/api/v1   (Local)

Interactive Swagger / OpenAPI Docs

Access the full interactive OpenAPI documentation in your browser:
👉 http://localhost:3000/api/v1/docs

Standard Response Envelope

Every endpoint returns a standardized JSON envelope:

{
  "success": true,
  "statusCode": 200,
  "message": "Data retrieved successfully",
  "data": { ... },
  "meta": {
    "total": 37,
    "page": 1,
    "limit": 10,
    "totalPages": 4
  }
}

💡 Endpoint Examples & Usage

1. Geography: States, LGAs & Demographics

Fetch State by Slug

GET /api/v1/states/lagos HTTP/1.1
Host: localhost:3000
{
  "success": true,
  "statusCode": 200,
  "message": "State retrieved successfully",
  "data": {
    "name": "Lagos",
    "slug": "lagos",
    "capital": "Ikeja",
    "areaKm2": 3577,
    "population": 12550598,
    "regionName": "South West",
    "governor": "Babajide Sanwo-Olu",
    "governorParty": "APC",
    "lgasCount": 20,
    "universitiesCount": 8
  }
}

List LGAs within a State

GET /api/v1/states/lagos/lgas?page=1&limit=5 HTTP/1.1

2. Governance: Governors & Political Parties

List Current State Governors

GET /api/v1/governors?page=1&limit=10 HTTP/1.1
{
  "success": true,
  "statusCode": 200,
  "data": [
    {
      "stateName": "Lagos",
      "governorName": "Babajide Sanwo-Olu",
      "governorPartyName": "All Progressives Congress",
      "deputyName": "Obafemi Hamzat",
      "deputyPartyName": "All Progressives Congress"
    }
  ]
}

3. Education: Accredited Tertiary Institutions

List Universities by Pagination

GET /api/v1/universities?page=1&limit=5 HTTP/1.1
{
  "success": true,
  "statusCode": 200,
  "meta": {
    "total": 260,
    "page": 1,
    "limit": 5,
    "totalPages": 52
  },
  "data": [
    {
      "name": "University of Lagos",
      "slug": "unilag",
      "type": "Federal",
      "foundedYear": 1962,
      "stateName": "Lagos"
    }
  ]
}

4. Culture: Ethnic Groups, Languages & Festivals

Fetch Ethnic Group Details

GET /api/v1/ethnic-groups/yoruba HTTP/1.1
{
  "success": true,
  "statusCode": 200,
  "data": {
    "name": "Yoruba",
    "slug": "yoruba",
    "populationEstimate": 45000000,
    "primaryStates": "Lagos, Ogun, Oyo, Osun, Ondo, Ekiti, Kwara, Kogi",
    "festivalsCount": 14
  }
}

5. History: Historical Events & Regimes

List Historical Milestones

GET /api/v1/historical-events?page=1&limit=5 HTTP/1.1
{
  "success": true,
  "statusCode": 200,
  "data": [
    {
      "title": "Independence of Nigeria",
      "slug": "nigerian-independence-1960",
      "eventYear": 1960,
      "eventDate": "1960-10-01",
      "category": "Political",
      "regimeType": "Civilian",
      "summary": "Nigeria gained independence from the United Kingdom."
    }
  ]
}

6. Tourism: Landmarks & Sites

List Tourism Destinations

GET /api/v1/tourism-sites?page=1&limit=5 HTTP/1.1

🚀 Target Use Cases

  • 💳 Fintech & KYC Verification: Standardize state of origin, LGA mappings, and residential verification without spelling mismatches.
  • 🗳️ Civic Tech & Governance Dashboards: Track political representation, executive administrations, and electoral history.
  • 📚 EduTech Platforms: Validate accredited universities, polytechnics, and colleges with verified ownership types.
  • 🗺️ Travel & Tourism Applications: Power tourism discovery platforms showcasing cultural festivals, heritage monuments, and attractions.
  • 📰 Journalism & Fact-Checking: Instantly access historical milestones, political timelines, and demographic data.

🛡️ Security & Reliability

  • Security Headers: Powered by Helmet to secure HTTP headers.
  • CORS Protection: Configurable Cross-Origin Resource Sharing for API security.
  • Rate Limiting & Throttling: Automated request limiting via @nestjs/throttler.
  • Structured JSON Observability: Zero-overhead logging with Pino and Prometheus telemetry (/metrics).

🛠️ Contributing & Local Development

Interested in adding datasets, writing controllers, running the project locally, or submitting a pull request?

👉 Please see our CONTRIBUTING.md for complete instructions on:

  • Local setup (Node.js, PostgreSQL, Prisma)
  • Environment variable configuration
  • Running local development and debug servers
  • Database migrations and Prisma Studio
  • Running tests, ESLint, and Prettier
  • Conventional Commits and PR submission guidelines

📜 Code of Conduct

We are committed to fostering an inclusive, welcoming community. All participants must adhere to our Code of Conduct.


📄 License

This project is licensed under the MIT License.
Copyright (c) 2026 OpenNG Contributors.

About

OpenNG — A fast, scalable, developer friendly free, and well-documented REST/GRAPHQL API for Nigerian data, built with NestJS, Prisma, and PostgreSQL. GRAPHQL repo: https://github.com/Kim5Y/OpenNG-graphql

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages