The API splits Nigeria into
- States (36)
- Local Government Areas (LGAs) (775)
You can get more information about Nigeria by sending a
GET request to
api/country?search=nigeria. Assuming you don't know the
It should return something like this
Now you know the
id, you can try this
The response will look like this
It would make a lot of sense to have something like
api/countries/nigeria. But I asked a few more experienced backend persons and the reason it's not a good practice is that resource identifiers should be unique. What if the country decides to change their names🤷♀️? I'm pretty sure the
ids will never change, so the search approach makes more sense.
There are 36 states in Nigeria. You can get all of them by sending a
GET request to the
/api/countries/countryId/states endpoint. Here's an example
This will return something like this
You can get to a state by appending their Ids
You'll get the following response
You can do pretty much anything on the
States endpoint - Searching, Sorting, Filtering by following these guides. Here's an example of how you can sort by
name and filter the
Your response would look like
States are futher split into local government areas (LGAs) and they can be accessed relative to the states. Here is an example that gets all the LGAs in Lagos state.
You'll get the following response.
LGA, like any other entity on WhereAPI, enables searching, pagination, sorting and ordering.
We can combine the
take query params to request data progressively. Here's an example where we get the
name of 4 LGAs in Abuja, but skip the first 2.
The first guid in this url is the
id of Nigeria, while the second is the
id of Abuja. They can pretty much be any Id of any other state.