Providing a public API for States and Cities in Nigeria


So Devs on DCsquare decided to take on another open source project. A simple API that lets you get a list of states, cities and local government areas in Nigeria. We attempted to make the most comprehensive dump of this data as it is not readily available anywhere. It’s in JSON. It’s made for the developer who wants to make a simple drop down list of Nigerian locations for any app in any language. (It’s also not limited to that developer’s use case).

It’s built in Python with Flask using Parse as a data store.

Github and Documentation:


Well done, guys.


More of this kind of stuff on here:


Good looks. Was just searching for something like this. :thumbsup:


Nice project. Built one too. But looking at a larger scale of this. Planning to add more to it. Anyone interested in another kind of mashape? Please contact me: 08066194746


I think I’ll build one for PHP using Codeigniter framework.


You REST API keys and application IDs are in your code, are those supposed to be public?

BTW I think this is a nice stuff. I have data for Polygon bounds of states, used in a previous project, I’ll work on adding this to your project once I get my Python game together.


They did mention its read-only in the


One other thing, I think you should reconsider using hyphen in property names, it makes the properties a bit difficult to use directly with JavaScript.

  "name": "Lagos",
  "max-lat": 6.7027984,
  "min-long": 3.0982732,
  "longitude": 3.3792057,
  "max-long": 3.696727799999999,
  "min-lat": 6.3936419,
  "latitude": 6.5243793,
  "capital": "Ikeja"

Using the above will require doing something like this: state['min-lat'] which would have been alot easier if camel cased, state.minLat


True, or underscores if they are like me and would rather avoid case ambiguity.


Hey bro, that data would very valuable, could you post a link to it.


Here’s a public Gist to piece of JSON data in a project I worked on sometime back


I’m also a codeigniyer developer. Nice1


You guys are the real mvps!!


Nice! consider using plurals for api resource name …v1/states/kaduna over v1/state/kaduna. Where states being a resource should be plural not state (singular). Good job guys


I read all the comments here and much advise coming from those who know things. I am a Python programmer and I code in Flask. One sure thing I consider is the seldom overlooked part of Unicode issues in Python.

No one wants to mess things up but they are surely there. I ran your code on the link:ım

You’ve got to work on urllib.unquote(state_name_or_code) in your def get_state(state_name_or_code). While we do not have Tanım in any place in Nigeria, it’s a reality that someone might break it one day.


I think you should just make the change: urllib.unquote(state_name_or_code.encode(‘utf8’)).

Look for other places you might have missed the unicode thing and sort it out.


Hello @nwaomachux Thanks so much for this! About your comments, thing is, this project is open source and you can get involved. Pull and fix it. :slight_smile: .You can also join the slack channel and talk to the guys that put this together.


OK, I’ll try my best to do as you’ve said.

I’ve done so.


Y U No link to the Slack Channel? :expressionless: