Giter VIP home page Giter VIP logo

galsenapi's Introduction

logo

GalsenApi est une API qui vous permet de manipuler facilement des données sur le Sénégal. Ce projet s'inspire du package Galsenify

Read in English

Installation 💻

  • Créez un environnement virtuel :
  python -m venv .venv
  • Activez l'environnement virtuel :
  source .venv/bin/activate
  • Installez les dépendances :
  pip install requirements.txt
  • Effectuez les migrations :
  python manage.py makemigrations
  python manage.py migrate
  • Créez un super utilisateur :
  python manage.py createsuperuser
  
  • Lancez le serveur :
  python manage.py runserver
  

Créez un fichier .env dans le projet Django pour stocker la clé secrète.

API Reference

Voici les différentes méthodes d'API disponibles :

Récupérer toutes les régions :

  GET /api/regions/

Récupérer une seule région :

  GET /api/regions/1/

Récupérer tous les départements :

  GET /api/departements

Récupérer un seul département :

  GET /api/departements/1/

Récupérer tous les villages :

  GET api/villages

Récupérer un seul département :

  GET /api/villages/1

Récupérer les informations sur le pays :

  GET /api/pays/

Utilisation

Pour récupérer toutes les régions : GET https://galsenapi.pythonanywhere.com/api/regions/

Exemple de résultat :

    [
    {
        "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é"
       	]
	}
]

Pour récupérer une seule région : https://galsenapi.pythonanywhere.com/api/regions/1/

Exemple de résultat :

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

Captures d'écran

Voici quelques captures d'écran pour illustrer les résultats de l'API :

Récuperations des infos sur le pays

CAPTURE

Récuperations de tout les Départements

CAPTURE

Récuperations d'un seul departement

CAPTURE

Récuperations de tout les Régions

CAPTURE

Récuperations d'une seul région

CAPTURE

Récuperations de tout les villages

CAPTURE

Récuperations d'un seul village

CAPTURE

👤 Author

LASSANA SIBY
Created by Lassana SIBY

BuyMeACoffee PayPal

🔗 Links

portfolio linkedin twitter

Merci à Daouda BA pour les donées.

Daouda BA

Exemple d'utilisation de l'api

Views region et departement

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)

galsenapi's People

Contributors

sibylassana95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.