Skip to content

Latest commit

 

History

History
222 lines (155 loc) · 5.18 KB

EN.md

File metadata and controls

222 lines (155 loc) · 5.18 KB

logo

GalsenApi is an API that allows you to easily manipulate data on Senegal. A project inspired by the package. Galsenify

Installation 💻

  • Create a virtual environment:
  python -m venv .venv
  • Activate the virtual environment:
  source .venv/bin/activate
  • Install the dependencies:
  pip install requirements.txt
  • Run the migrations:
  python manage.py makemigrations
  python manage.py migrate
  • Create a super user:
  python manage.py createsuperuser
  • Create a .env file in the Django project to store the secret key.

API Reference

Get all regions

  GET /api/regions/

Get a single region

  GET /api/regions/1/

Get all departments

  GET /api/departements

Get a single department

  GET /api/departements/1/

Get all villages :

  GET api/villages

Get a single village :

  GET /api/villages/1

Get country information

  GET /api/pays/

Usage

To get all regions, use a GET request: https://galsenapi.pythonanywhere.com/api/regions/

Example Result

[
  {
    "id": 1,
    "nom": "Dakar",
    "code": "DK",
    "population": 4042225,
    "superficie": 547,
    "departments": ["Dakar", "Pikine", "Guédiawaye", "Rufisque", "Keur Massar"]
  },
  {
    "id": 2,
    "nom": "Diourbel",
    "code": "DB",
    "population": 1980821,
    "superficie": 4824,
    "departments": ["Diourbel", "Bambey", "Mbacké"]
  }
]

To get a single region, use a GET request: https://galsenapi.pythonanywhere.com/api/regions/1/

Example Result

{
  "id": 1,
  "nom": "Dakar",
  "code": "DK",
  "population": 4042225,
  "superficie": 547,
  "departments": ["Dakar", "Pikine", "Guédiawaye", "Rufisque", "Keur Massar"]
}

Capture

Retrieval of information about the country

CAPTURE

Retrieval of all Departments

CAPTURE

Retrieval of a single department

CAPTURE

Retrieval of all Regions

CAPTURE

Retrieval off a single Region

CAPTURE

👤 Author

LASSANA SIBY
Created by Lassana SIBY

BuyMeACoffee PayPal

🔗 Links

portfolio linkedin twitter

Thank you to Daouda BA for the data..

Daouda BA

Example of using the API

Views for regions and departments.

def regions_view(request):
    query = request.GET.get('q')
    url = 'https://galsenapi.pythonanywhere.com/api/regions/'
    params = {'search': query} if query else {}
    response = requests.get(url, params=params)
    data = response.json()
    regions = data
    context = {'regions': regions, 'query': query}
    return render(request, 'demo/regions.html', context)


def departments_view(request):
    query = request.GET.get('q')
    url = 'https://galsenapi.pythonanywhere.com/api/departements/'
    params = {'search': query} if query else {}
    response = requests.get(url, params=params)
    data = response.json()
    departments = data
    context = {'departments': departments, 'query': query}
    return render(request, 'demo/departements.html', context)

def villages_view(request):
    query = request.GET.get('q')
    url = 'https://galsenapi.pythonanywhere.com/api/villages/'
    params = {'search': query} if query else {}
    response = requests.get(url, params=params)
    data = response.json()
    villages = data
    context = {'villages': villages, 'query': query}
    return render(request, 'demo/village.html', context)

CAPTURE CAPTURE CAPTURE

📝 License

MIT License

Made-In-Senegal

(back to top)