Skip to content

Eduardo-J-Morales/Books-Management-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Books Management API

A RESTful API for managing books, built with Flask, Flask-RESTful, SQLAlchemy, and secured with HTTP Basic Authentication.

Note: There is an explanation to install this API below for developers, however you don't need to install anything to try this API!
An online demo is available here: Live API Deployment (See below for usage instructions and example requests.)

Features

  • CRUD operations for book records
  • Data validation for integrity
  • Basic authentication for all endpoints
  • Dockerized for easy deployment

Technology Stack

  • Python
  • Flask
  • Flask-RESTful
  • SQLAlchemy
  • SQLite
  • Docker
  • HTTP Basic Auth

Getting Started

Important: All endpoints require HTTP Basic Auth:

Here is the default username and password for the authentication if you want to change this look for the "users" object in the app.py file.

  • Username: admin
  • Password: password123

API Endpoints

Method Endpoint Description
GET /books List all books
POST /books Add a new book
GET /books/<book_id> Get a specific book
PUT /books/<book_id> Update a book
DELETE /books/<book_id> Delete a book

Examples

  1. GET (List all books)

    curl -u admin:password123 http://localhost:5000
  2. POST (Add a new book)

    curl -u admin:password123 -X POST http://localhost:500 \
    -H "Content-Type: application/json" \
    -d '{
        "title": "The Pragmatic Programmer",
        "author": "Andrew Hunt",
        "published_year": 1999,
        "isbn": "9780201616224"
      }'
  3. GET (Get a specific book)

    curl -u admin:password123 http://localhost:5000/books/<book_id>
  4. PUT (Update a book)

    curl -u admin:password123 -X PUT http://localhost:5000/books/<book_id> \
      -H "Content-Type: application/json" \
      -d '{
        "title": "The Pragmatic Programmer (Updated)",
        "author": "Andrew Hunt",
        "published_year": 1999,
        "isbn": "9780201616224"
      }'
  5. DELETE (Delete a book)

    curl -u admin:password123 -X DELETE http://localhost:5000/books/<book_id>

Installation

  1. Clone the repo:

    git clone https://github.com/Eduardo-J-Morales/Books-Management-API.git
    cd Books-Management-API
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the app:

    python app.py

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A RESTful API for managing books, built with Flask, Flask-RESTful, SQLAlchemy, and secured with HTTP Basic Authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors