A simple REST API built with FastAPI to manage a bookstore. This project includes full CRUD functionality and demonstrates use of path/query parameters, Pydantic validation, and Pipenv for dependency management.
- β Get all books with optional author filtering
- β Get a book by its ID
- β Add a new book (with duplicate ID prevention)
- β Update an existing book
- β Delete a book
- β Validation for rating (must be between 0 and 5)
- β Price field included
- β Built using Pipenv for clean dependency management
git clone https://github.com/Jayasurya003/Bookstore_FastAPI.git
cd Bookstore_FastAPIpipenv installpipenv shelluvicorn main:app --reload- Go to:
http://127.0.0.1:8000 - Use the interactive docs:
http://127.0.0.1:8000/docs
| Method | Endpoint | Description |
|---|---|---|
| GET | /books |
Get all books (with optional author filter) |
| GET | /books/{book_id} |
Get one book by its ID |
| POST | /books |
Add a new book |
| PUT | /books/{book_id} |
Update an existing book |
| DELETE | /books/{book_id} |
Delete a book |
ratingmust be a float between0and5(validated withconfloat)- Prevents adding books with duplicate
id - Uses
Optionalfields likedescriptionandratingfor flexibility
- Add persistence (e.g., database integration)
- Add authentication
- Add pagination or search filtering