Overview

Looking for a listing of Countries >> States >> Cities >> Streets ?

Our dockerised locations microservice is all you need!

HNG Locations API provides you with detailed corresponding information about a location through it's UID.

Features

How it works

Supply a location UID and get a specified JSON output of the information you require. Required info could be other locations closeby, location children etc.

Location information


To get basic information such as country, state, lat/long coordinates and driving instructions, about a location, you just pass the location UID to the API in this form:

http://locations.hng.tech/api/v2/NG

or

http://locations.hng.tech/api/v2/NG-5258ABUJA

Where NG and NG-5258ABUJA are location UIDs

Output:

    ## First option
    {
     "data":
        {
         "country":"Nigeria",
         "driving_instructions":"",
         "latitude":"0.00",
         "longitude":"0.00",
         "other":""
        },
         "status":"success"
    }     
## Second option { "data": { "country":"Nigeria", "state":"Abuja", "driving_instructions":"", "latitude":"0.00", "longitude":"0.00", "other":"" }, "status":"success" }


Location Relationship


From a location UID you can get information on the direct relationship of a particular location to another.
You pass the location UID to the API in this form:

http://locations.hng.tech/api/v2/NG-5258ABUJA/relations

Where NG-5258ABUJA is the location UID and relations is the corresponding information required from the API (in this case: location relationship).

Output:

     {
      "data":
       [{
         "location_isIn":
          [{
            "name":"Nigeria",
            "type":"country",
            "uid":"NG"
           }],
         "isIn_location":[]
        }],
      "status":"success"
     }


Location Parent


You can request information on the parent of a location. The API returns a list of the location's parent which includes it's name, UID and type.

For this example, let's request the parent of Abuja. To do this, you pass the country code (code for Nigeria is NG) to the API in this form:

http://locations.hng.tech/api/v2/NG-5258ABUJA/parent

Where NG-5258ABUJA is the location UID and parent is the corresponding information required from the API (in this case: location parent).

Output:

     {
      "data":
       [{
         "name":"Nigeria",
         "type":"country",
         "uid":"NG"
       }],
      "status":"success"
     }


Location Children


You can request information on the children of a location. The API returns a list of the location's children which includes their name, UID and type.

For this example, let's request the children of Nigeria. To do this, you pass the country code (code for Nigeria is NG) to the API in this form:

http://locations.hng.tech/api/v2/NG/children

Where NG is the parameter for the country code (in this case: Nigeria) and children is the corresponding information required from the API (in this case: location children).

Output:

    {
     "data":
      [
       {"name":"Abuja","type":"state","uid":"NG-5258ABUJA"},
       {"name":"Anambra","type":"state","uid":"NG-318ANAMBRA"},
       {"name":"Enugu","type":"state","uid":"NG-5441ENUGU"},
       {"name":"Akwa Ibom","type":"state","uid":"NG-7349AKWAIBO"},
       {"name":"Adamawa","type":"state","uid":"NG-3640ADAMAWA"},
       {"name":"Abia","type":"state","uid":"NG-570ABIA"},
       {"name":"Bayelsa","type":"state","uid":"NG-9057BAYELSA"},
       {"name":"Borno","type":"state","uid":"NG-425BORNO"},
       {"name":"Cross River","type":"state","uid":"NG-2894CROSSRI"},
       {"name":"Delta","type":"state","uid":"NG-2890DELTA"},
       {"name":"Ebonyi","type":"state","uid":"NG-9014EBONYI"},
       {"name":"Edo","type":"state","uid":"NG-7419EDO"},
       {"name":"Ekiti","type":"state","uid":"NG-3805EKITI"},
       {"name":"Gombe","type":"state","uid":"NG-529GOMBE"},
       {"name":"Imo","type":"state","uid":"NG-2883IMO"},
       {"name":"Jigawa","type":"state","uid":"NG-5197JIGAWA"},
       {"name":"Kaduna","type":"state","uid":"NG-145KADUNA"},
       {"name":"Kano","type":"state","uid":"NG-8805KANO"},
       {"name":"Katsina","type":"state","uid":"NG-2297KATSINA"},
       {"name":"Kebbi","type":"state","uid":"NG-2924KEBBI"},
       {"name":"Kogi","type":"state","uid":"NG-3377KOGI"},
       {"name":"Kwara","type":"state","uid":"NG-2961KWARA"},
       {"name":"Lagos","type":"state","uid":"NG-1564LAGOS"},
       {"name":"Nasarawa","type":"state","uid":"NG-9708NASARAW"},
       {"name":"Niger","type":"state","uid":"NG-2785NIGER"},
       {"name":"Ogun","type":"state","uid":"NG-5988OGUN"},
       {"name":"Ondo","type":"state","uid":"NG-8014ONDO"},
       {"name":"Osun","type":"state","uid":"NG-37OSUN"},
       {"name":"Oyo","type":"state","uid":"NG-2727OYO"},
       {"name":"Plateau","type":"state","uid":"NG-5037PLATEAU"},
       {"name":"Rivers","type":"state","uid":"NG-5296RIVERS"},
       {"name":"Sokoto","type":"state","uid":"NG-3046SOKOTO"},
       {"name":"Taraba","type":"state","uid":"NG-479TARABA"},
       {"name":"Yobe","type":"state","uid":"NG-2645YOBE"},
       {"name":"Zamfara","type":"state","uid":"NG-6687ZAMFARA"},
       {"name":"Benue","type":"state","uid":"NG-1050BENUE"},
       {"name":"Ashanti","type":"state","uid":"NG-9960ASHANTI"},
       {"name":"Greater Accra","type":"state","uid":"NG-5744GREATER"},
       {"name":"Volta","type":"state","uid":"NG-1475VOLTA"},
       {"name":"Central","type":"state","uid":"NG-2855CENTRAL"},
       {"name":"Northern","type":"state","uid":"NG-8635NORTHER"}
      ],
     "status":"success"
    }