Skip to content

EngineerDanny/GH-GPS-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GH-GPS-DJANGO-REST-API

A REST api for Ghana's Global Positioning System (GPS) written with Python Django 🐍🐍

API Usage


Get GhanaPostGPS Address from PlaceName or GPSName.

Request

End Point URL: https://gh-gps.herokuapp.com/api/get-address
Method: POST
Content-Type: application/json

Payload

When using with a PlaceName

{
  "name": "KNUST Guesthouse"
}

When using with a GPSName

{
  "name": "AE-0147-4625"
}

Response


1. When Address exists, it returns an address field which contains a list of Addresses
{
  "status": "Address found",
  "address": [
    {
      "Place_Name": "KNUST Guesthouse",
      "CenterLatitude": "5.5677456",
      "CenterLongitude": "-0.1863609",
      "Region": "Greater Accra",
      "District": "Korley Klote",
      "Area": "RINGWAY ESTATES",
      "StreetName": "Nuumo Klotey Street",
      "GPSName": "GA0315033",
      "PostCode": "GA031",
      "PlaceName": "KNUST Guesthouse, GA-031-5033, Korley Klote",
      "Street": "KNUST Guesthouse, Nuumo Klotey Street"
    }
  ],
  "count": 1
}
  1. No Address was found
{
  "status": "No Address found"
}
  1. Encounter an error
{
  "error": "Request is missing name in the body"
}

Get GhanaPostGPS Address from Position (Latitude and Longitude)

Request

End Point URL: https://gh-gps.herokuapp.com/api/get-gps
Method: POST
Content-Type: application/json

Payload

{
  "lat": "6.1250",
  "long": "-1.94872"
}

Response


1. When Address exists, it returns an address field which contains a list of Addresses
{
  "status": "Address found",
  "address": [
    {
      "GPSName": "AV31641332",
      "Region": "Ashanti",
      "District": "Amansie Central",
      "PostCode": "AV3164",
      "NLat": 6.12502457351701,
      "SLat": 6.12497965404504,
      "WLong": -1.94876026156099,
      "Elong": -1.94871534579679,
      "Area": ".",
      "Street": ".[Unknown Street]",
      "PlaceName": ""
    }
  ],
  "count": 1
}
  1. No Address was found
{
  "status": "No Address found"
}
  1. Encounter an error
{
  "error": "Request is missing latitude or longitude in the body"
}

API Local Set-Up


Technologies
  • Django: The web framework for perfectionists with deadlines (Django builds better web apps with less code).
  • DRF: A powerful and flexible toolkit for building Web APIs

Installation
  • Make sure you've got Python installed.

  • Install virtualenv globally with:

        $ pip install virtualenv
  • Clone this repo

        $ git clone https://github.com/EngineerDanny/GH-GPS-REST-API.git
  • Dependencies

    1. Cd into your the cloned repo as such:
          $ cd GH-GPS-API
    2. Create and fire up your virtual environment:
          $ virtualenv  venv -p python3
          $ source venv/bin/activate
    3. Install the dependencies needed to run the app:
          $ pip install -r requirements.txt

Running
  1. Start the server with:
        $ python manage.py runserver
  2. You can access the local server by using the following ENDPOINTS:
        http://localhost:8000/api/
        http://localhost:8000/api/get-address
        http://localhost:8000/api/get-gps
    

License


This project is under license from MIT. For more details, see the LICENSE file.

Made with ❤️ by EngineerDanny