Providing a public API for States and Cities in Nigeria


#1

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: https://github.com/devcenter-square/states-cities


#2

Well done, guys.


#3

More of this kind of stuff on here: https://github.com/olibenu/csv49/blob/master/index.csv


#4

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


#5

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


#6

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


#7

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.


#8

They did mention its read-only in the README.md


#9

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


#10

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


#11

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


#12

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


#13

I’m also a codeigniyer developer. Nice1


#14

You guys are the real mvps!!


#15

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


#16

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:
http://127.0.0.1:8080/api/v1/state/Tanı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.


#17

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.
Thanks.


#18

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.


#19

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

[[Addendum]]
I’ve done so.


#20

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

Fixed: https://devcenter-square-slack.herokuapp.com/