{"id":24796048,"url":"https://github.com/vinayakchandra/restful-api-library-jwt","last_synced_at":"2026-05-10T03:21:43.810Z","repository":{"id":256339076,"uuid":"853870328","full_name":"vinayakchandra/RESTful-API-library-JWT","owner":"vinayakchandra","description":"Flask-based API for managing books in a library database, secured with JWT authentication.","archived":false,"fork":false,"pushed_at":"2024-09-10T05:06:55.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T00:33:36.884Z","etag":null,"topics":["flask","mysql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vinayakchandra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-07T19:03:36.000Z","updated_at":"2024-09-10T05:06:58.000Z","dependencies_parsed_at":"2024-09-10T07:51:46.844Z","dependency_job_id":null,"html_url":"https://github.com/vinayakchandra/RESTful-API-library-JWT","commit_stats":null,"previous_names":["vinayakchandra/restful-api-library-jwt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinayakchandra%2FRESTful-API-library-JWT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinayakchandra%2FRESTful-API-library-JWT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinayakchandra%2FRESTful-API-library-JWT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinayakchandra%2FRESTful-API-library-JWT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinayakchandra","download_url":"https://codeload.github.com/vinayakchandra/RESTful-API-library-JWT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245343993,"owners_count":20599867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","mysql"],"created_at":"2025-01-30T00:30:44.721Z","updated_at":"2026-05-10T03:21:43.747Z","avatar_url":"https://github.com/vinayakchandra.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Library Management API with JWT Authentication\n\n## Overview\n\nThis is a Flask-based API for managing books in a database, secured with JSON Web Token (JWT) authentication. The API\nsupports all CRUD operations such as retrieving, adding, updating, and deleting books. Authentication is required for all actions\nvia JWT, which is obtained by logging in as a user.\n\n## Features\n\n1. JWT Authentication.\n2. CRUD operations for managing books (Create, Read, Update, Delete).\n3. MySQL integration for storage of books.\n\n## Setup\n\n### Installation\n\n1. Clone the repository.\n2. Install required dependencies:\n\n    ```bash\n    pip install flask mysql-connector-python flask-jwt-extended\n    ```\n\n3. Create a MySQL Database:\n\n    ```sql\n    CREATE DATABASE library;\n    ```\n4. Create Table inside `library` Database\n    ```sql\n    CREATE TABLE book (\n    bookID int,\n    bookName varchar(255),\n    author varchar(255)\n    );\n    ```\n\n5. Configure MySQL credentials in the `mysql_connect.py` file.\n\n### Database Schema:\n\n![image](schema.png)\n\n### Running the Application\n\n```bash\npython app.py\n```\n\n## Endpoints\n\n### Login (`POST` /login)\n\nAuthenticate the user and return a JWT token.\n\n- Request Body:\n\n   ```json\n   {\n     \"username\": \"admin\",\n     \"password\": \"admin\"\n   }\n   ```\n\n- Response:\n\n   ```json\n   {\n     \"access_token\": \"your_jwt_token\"\n   }\n   ```\n\n### Get All Books (`GET` /)\n\nGet the list of all books. Requires a valid JWT token.\n\n### Get a Book (`GET` /\u0026lt;id\u0026gt;)\n\nGet a single book by ID. Requires a valid JWT token.\n\n### Create a New Book (`POST` /new)\n\nCreate a new book. Requires a valid JWT token.\n\n- Request Body:\n\n   ```json\n   {\n     \"bookID\": 1,\n     \"bookName\": \"Book Title\",\n     \"author\": \"Author Name\"\n   }\n   ```\n\n### Update a Book (`PATCH` /update/\u0026lt;id\u0026gt;)\n\nUpdate the name of a book by ID. Requires a valid JWT token.\n\n- Request Body:\n\n   ```json\n   {\n     \"bookName\": \"new BookName\"\n   }\n   ```\n\n### Delete a Book (`DELETE` /delete/\u0026lt;id\u0026gt;)\n\nDelete a book by ID. Requires a valid JWT token.\n\n## JWT Authentication\n\nUse the `/login` endpoint to get a JWT token, then pass the token in the `Authorization` header in all endpoints.\\\n```Authorization: Bearer \u003cyour_jwt_token\u003e```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinayakchandra%2Frestful-api-library-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinayakchandra%2Frestful-api-library-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinayakchandra%2Frestful-api-library-jwt/lists"}