- Project detail
- Installing Dependencies
- Project setup
- Api Endpoints
This project is a class project given us by Mr OURO. The goals of this project can be summarized in these points:
- You need to build your API using python Flask / base Postgres data
- You should document your API specifying the responses you get after running each endpoint
- Deploy your API on the Heroku Cloud Platform
Python 3.10.4 Follow instructions to install the latest version of python for your platform (windows link there) on python official web site
pip 22.1 from C:\Users\Sidewinder\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10) Follow instructions to install the latest version of python for your platform on pip official web site
The requiered package.txt inside the tree structure contains all the requierd packages you need to use the API.
BOOK-API/
|----.gitignore
|----API_BIBLIOTHEQUE.postman_collection.json
|----Bookapi.py
|----README.md
|----requieredpackage.txt
pip install -r requieredpackage.txt
or
pip3 install -r requieredpackage.txt
We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the python docs
You can also use python extension for vscode if you are using visual studio code. you can find it on vs code market place
The project were made with postgres sql as database. You can use whatever database you want cause we used SQLAlchemy, an ORM of Flask. Check out the official web site. You just need to proceed according to the documentaition
Base URL: At present this app can only be run locally and is not hosted as a base URL. The backend app is hosted at the default, http://localhost:5000; which is set as a proxy in frontend configuration.
Errors are retourned as JSON objects in the following format:
{
"response": "Method not allowed",
"succes": false
}
{
"response": "Ressource not found",
"succes": false
}
The API will return two errors types when requests fail:
. 405: Method not allowed
. 404: Not found
There are 4 HTTP methods used : GET, POST, PATCH, DELETE for Book and Category.
This endpoints returns the list of all categories, success value, Number of saved categories. the URL based on local server :
http://127.0.0.1:5000/book/showallcategories
{
"Liste de categories": [
{
"id": 1,
"libelle_categorie": "Fiction"
},
{
"id": 2,
"libelle_categorie": "Horreur"
},
{
"id": 3,
"libelle_categorie": "Conte"
},
{
"id": 4,
"libelle_categorie": "Harlequin"
},
{
"id": 5,
"libelle_categorie": "Science"
},
{
"id": 6,
"libelle_categorie": "Mecanique"
},
{
"id": 7,
"libelle_categorie": "Biologie"
},
{
"id": 8,
"libelle_categorie": "Manuel"
},
{
"id": 9,
"libelle_categorie": "Etudes"
},
{
"id": 10,
"libelle_categorie": "Divertissement"
}
],
"Nombre de categories": 10,
"success": true
}
This endpoints returns success value, Number of saved categories. the URL based on local server :
http://127.0.0.1:5000/book/addcategories
{
"Nombre de Categorie": 8,
"Response": "enregistrement effectué",
"success": true
}
This endpoints returns success value, a list result from the search by ID of a category. the URL based on local server :
http://127.0.0.1:5000/book/showallcategories/1
{
"Id recherche": 1,
"Listecategorie": [
{
"id": 1,
"libelle": "Fiction"
}
],
"Nombre de categories": 10,
"success": true
}
This endpoints returns success value, Number of saved categories, the deleted category ID the URL based on local server :
http://127.0.0.1:5000/book/deletecategorie/10
{
"Categorie effacée": 10,
"Nombre de Categories": 7,
"Response": "Suppression effectuée correctement",
"success": true
}
This endpoints returns success value, Number of saved categories, the updated category ID the URL based on local server :
http://127.0.0.1:5000/book/updatecategory/3
{
"Nombre de Categories": 8,
"Response": "Modifie avec succes",
"id categorie moodifiee": 3,
"success": true
}
This endpoints returns success value, Number of saved books, the list of saved books the URL based on local server :
http://127.0.0.1:5000/book/showbooklist
{
"Liste de livres": [
{
"auteur": "aliexpress",
"categorie_id": 1,
"date_publication": "Mon, 25 May 1987 00:00:00 GMT",
"editeur": "kodjovi",
"id": 1,
"isbn": "12345678",
"titre": "Le vent se leve"
},
{
"auteur": "Lord",
"categorie_id": 2,
"date_publication": "Mon, 25 Jul 1977 00:00:00 GMT",
"editeur": "Yves le curseur",
"id": 2,
"isbn": "12345678",
"titre": "Ali aux pays des merveilles"
}
],
"Nombre de livres": 2,
"success": true
}
This endpoints returns success value, Number of saved books, the book searched by ID the URL based on local server :
http://127.0.0.1:5000/book/showbooklist/1
{
"Id recherché": 1,
"Listecategorie": [
{
"auteur": "aliexpress",
"categorie_id": 1,
"date_publication": "Mon, 25 May 1987 00:00:00 GMT",
"editeur": "kodjovi",
"id": 1,
"isbn": "12345678",
"titre": "Le vent se leve"
}
],
"success": true
}
This endpoints returns success value, Number of saved book the URL based on local server :
http://127.0.0.1:5000/book/addbooks
{
"Nombre de Livres": 4,
"Response": "enregistrement effectué",
"success": true
}
This endpoints returns success value, Number of saved books, the deleted book ID the URL based on local server :
http://127.0.0.1:5000/book/deletebook/4
{
"Livre effacé": 4,
"Nombre de Livres": 3,
"Response": "Suppression effectuée correctement",
"success": true
}
This endpoints returns success value, Number of saved books, The searched book by category ID the URL based on local server :
http://127.0.0.1:5000/book/showbooklist/4
{
"Id recherché": 3,
"Liste de Livres": [
{
"auteur": "Lord",
"categorie_id": 3,
"date_publication": "Mon, 25 Jul 1977 00:00:00 GMT",
"editeur": "Yves le curseur",
"id": 3,
"isbn": "123456787",
"titre": "la peche du dimanche"
}
],
"success": true
}
This endpoints returns success value, The updated book by ID, number of book the URL based on local server :
http://127.0.0.1:5000/book/updatebook/1
{
"Nombre de Livres": 6,
"Response": "Modifie avec succes",
"id categorie moodifiee": 1,
"success": true
}