This is a simple RESTful API built with FastAPI for managing books. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on a collection of books stored in a database.
must have python installed if not fellow the guide [https://realpython.com/installing-python/]
-
Clone the repository:
git clone https://github.com/martcpp/crud-api-fastapi.git
-
Install dependencies:
pip install -r requirements.txt cd src
-
Run the application:
uvicorn app:app --reload
The API will be available at
http://localhost:8000
.
-
Clone the repository:
git clone https://github.com/martcpp/crud-api-fastapi.git
cd CRUD-API-FASTAPI
-
Run the application:
docker build -t crud-api . docker run -p 8000:8000 crud-api
The API will be available at
http://localhost:8000
http://localhost:8000/docs
for more information about the API documentation
Retrieve all books.
Create a new book. Send a JSON object with the book details in the request body.
Example Request Body:
{
"title": "Example Book",
"author": "John Doe",
"year": 2024,
"isbn": "978-3-16-148410-0"
}
Retrieve a specific book by its ID.
Update an existing book by its ID. Send a JSON object with the updated book details in the request body.
Delete a specific book by its ID.
The following fields are available for a book:
id
(integer): Unique identifier for the book.title
(string): Title of the book.author
(string): Author of the book.year
(integer): Year of publication.isbn
(string): ISBN (International Standard Book Number) of the book.
- FastAPI: Web framework for building APIs with Python.
- SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM) library for Python.
- uvicorn: ASGI server for running FastAPI applications.
- MySQL: MySQL server for running FastAPI applications with MySQL support enabled
- psycopg2 : for connecting to to postgresql databases