COMPANY : CODTECH IT SOLUTIONS
NAME : DHARUN PRASHOB M M
INTERN ID : CT04DY2328
DOMAIN : SOFTWARE DEVELOPMENT
DURATION : 4 WEEEKS
MENTOR : NEELA SANTOSH
A robust and well-documented RESTful API for managing a collection of books. This project was built to demonstrate the core principles of API development using Python, Flask, and SQLAlchemy.
- Full CRUD Functionality: Create, Read, Update, and Delete books.
- Input Validation: Ensures required data like
title
andauthor
are present and not empty. - JSON Error Handling: Provides clear, consistent JSON error messages for 404 (Not Found), 400 (Bad Request), and 500 (Internal Server) errors.
- Interactive Documentation: Auto-generated, interactive API documentation powered by Swagger (Flasgger).
- Backend: Python 3
- Framework: Flask
- ORM: Flask-SQLAlchemy
- Database: SQLite
- API Documentation: Flasgger (OpenAPI 2.0 / Swagger)
Interactive API documentation is available once the server is running. It allows you to view all available endpoints and test them directly from your browser.
- Swagger UI URL:
http://127.0.0.1:5000/apidocs
Follow these steps to get the project running on your local machine.
git clone https://github.com/drun16/library-api.git
cd library-api
It's highly recommended to use a virtual environment to manage project dependencies.
-
For macOS/Linux:
python3 -m venv venv source venv/bin/activate
-
For Windows:
python -m venv venv .\venv\Scripts\activate
Install all the necessary packages from the requirements.txt
file.
pip install -r requirements.txt
This command will start the Flask development server. The db.create_all()
command will automatically create the library.db
database file if it doesn't exist.
python app.py
The API will now be running at http://127.0.0.1:5000/apidocs
.
Method | Endpoint | Description |
---|---|---|
POST |
/books |
Add a new book. |
GET |
/books |
Get a list of all books. |
GET |
/books/<book_id> |
Get a single book by its ID. |
PUT |
/books/<book_id> |
Update an existing book. |
DELETE |
/books/<book_id> |
Delete a book. |