Skip to content

Latest commit

 

History

History
141 lines (109 loc) · 4.12 KB

EN.md

File metadata and controls

141 lines (109 loc) · 4.12 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/

For more information, consult the documentation

👤 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.vercel.app/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.vercel.app/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.vercel.app/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)