Code Monkey home page Code Monkey logo

crud-api-fastapi's Introduction

Simple Book Management API

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.

Note

must have python installed if not fellow the guide [https://realpython.com/installing-python/]

Setup

  1. Clone the repository:

    git clone https://github.com/martcpp/crud-api-fastapi.git
  2. Install dependencies:

    pip install -r requirements.txt
    cd src 
  3. Run the application:

    uvicorn app:app --reload

    The API will be available at http://localhost:8000.

using docker

  1. Clone the repository:

    git clone https://github.com/martcpp/crud-api-fastapi.git
    cd CRUD-API-FASTAPI
  2. Run the application:

    docker build -t crud-api .
    docker run -p 8000:8000 crud-api

    The API will be available at http://localhost:8000

Endpoints

http://localhost:8000/docs for more information about the API documentation

GET /books/

Retrieve all books.

POST /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"
}

GET /books/{book_id}

Retrieve a specific book by its ID.

PUT /books/{book_id}

Update an existing book by its ID. Send a JSON object with the updated book details in the request body.

DELETE /books/{book_id}

Delete a specific book by its ID.

Data Schema

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.

Dependencies

  • 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

crud-api-fastapi's People

Contributors

martcpp 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.