Using the Nigeria State, Town and Local Government API

Benson Arafat
3 min readOct 20, 2023

--

I am writing this article to guide everyone on using the Nigeria local government area API I developed. So if you are using the API or you want to contribute to the API you are welcome to do that.

Firstly, we have the API itself, where all requests are made, and secondly, we have the app where you can make live contributions.

So, I am starting from the API and covering two separate sections:

  1. How to use the API
  2. How you can contribute to the source code on GitHub

Using the API (Part One)

API Endpoint

https://nigeria-states-towns-lgas.onrender.com/api

API Overview:

Your API provides information about Nigeria State, Towns, Local Government Areas, languages spoken, hospitals, airports, universities, polytechnics, and more. Here’s how to interact with it with some examples:

Get All States and their details

  1. Method: GET
  2. Endpoint: https://nigeria-states-towns-lgas.onrender.com/api/all
  3. Description: Retrieve a list of all states in Nigeria.
  4. Response: An array of state objects containing information about the state.

Get only state information

  1. Method: GET
  2. Endpoint: https://nigeria-states-towns-lgas.onrender.com/api/states
  3. Description: Retrieve a list of all states in Nigeria.
  4. Response: Returns a list of states in Nigeria only

Get Towns in a State

  1. Method: GET
  2. Endpoint: https://nigeria-states-towns-lgas.onrender.com/api/{state_code}/towns
  3. Description: Retrieve a list of towns within a specific state by providing the state_code.
  4. Response: An array of town objects within the specified state.

Example

https://nigeria-states-towns-lgas.onrender.com/api/FCT/towns

Get LGA in a State

  1. Method: GET
  2. Endpoint: https://nigeria-states-towns-lgas.onrender.com/api/{state_code}/lgas
  3. Description: Retrieve a list of LGA within a specific state by providing the state_code.
  4. Response: An array of lga objects within the specified state.

Example

https://nigeria-states-towns-lgas.onrender.com/api/ABIA/lgas

Others

You can also get items for any of the states. Examples: the National Resources, Languages spoken, Ethnic Groups, Religions etc.

Example

  1. Method: GET
  2. Endpoint: https://nigeria-states-towns-lgas.onrender.com/api/{state_code}/{type}
  3. Description: Retrieve a list of items within a specific state by providing the state_code and type.
  4. Response: An array of items objects within the specified state.
https://nigeria-states-towns-lgas.onrender.com/api/FCT/airports

Contributing to the API

Contributions are also welcome to the project. Firstly, you will have to clone the repository.

The API is developed using NodeJs (purely Javascript) as the backend with ExpressJs. Also with a NoSQL database i.e. Monogodb.

GitHub Repository:

In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non-trivial fixes. In case of trivial fixes open a pull request directly.

Live Update (Part Two)

In this part, I’ll walk you through how the live update works and how you can contribute online.

Firstly, you have to visit the URL: https://nigeria-locality.vercel.app/ all states are already inserted so no need to add a new state.

Adding new Town and Local Government Areas.

Click on the view button to view details of the state, you can add a new town, or local government or update the state details

Note: Before you add a new Town or Local Government Area, please make sure it does not exist already before you do so.

Contributing to the App

You can also contribute to the application on GitHub. The application was built using Vue.js and Typescript.

In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non-trivial fixes. In case of trivial fixes open a pull request directly.

Thanks.

--

--