Giter Site home page Giter Site logo

crud_book_api's Introduction

CRUD BOOK API

CRUD book API is a task assigned to me by AFTJDIGITAL as a second level of the screening process. The API has the following features

  • Register a user
  • Login a user
  • A user can add a book to a database
  • Get all books from a database
  • Get a single book from a database
  • Delete a book from a database

API Endpoints

  • Register a user

POST https://{domain}/api/v1/users/create

Payload
	{
		"first_name" : "micheal",
		"last_name" : "smith",
		"email" : "[email protected]",
		"password_confirmation" : "secret@_Password",
		"password" : "secret@_Password"
	}
Response
	{
		  "status": "success",
		  "message": "User Account Successfully created",
		  "data": {
			"first_name": "micheal",
			"last_name": "smith",
			"email": "[email protected]",
			"_token": "1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K"
	  	}
	}

  • Login a user

POST https://{domain}/api/v1/users/login

Payload
{
    "email" : "[email protected]",
    "password" : "secret@_Password",
}
Response
{
      "status": "success",
      "message": "User Successfully Authenticated",
      "data": {
        "first_name": "michael",
        "last_name": "smith",
        "email": "[email protected]",
        "_token": "1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K"
      }
}

  • Create a book

POST https://{domain}/api/v1/books

Headers: Bearer 1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K
Payload
{
    "title" : "The Key to Success",
    "author" : "Bola Akintomide",
    "description" : "An inspirational book ..."
}
Response
{
      "status": "success",
      "message": "Book creation was successful",
      "data": {
        "id": "4dd9555fbeffd727805d77a9b33c14d2",
        "title": "The Key to Success",
        "author": "Bola Akintomide",
        "description": "An inspirational book ...",
        "creation_date": "2021-02-06 23:05:21",
        "created_by": "[email protected]"
      }
}

  • Retrieve all books

GET https://{domain}/api/v1/books

Headers: Bearer 1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K
Optional Filters
    [email protected]
    &order=asc
    &title=Give%20me%20
    &created_at=2021-02-06`
Response
{
      "status": "success",
      "message": "Books retrieved successfully",
      "data": [
        {
          "id": "ba080edcd4d7287c91506fe303b119ca",
          "title": "The Key to Success",
          "author": "Bola Akintomide",
          "description": "An inspirational book ...",
          "creation_date": "2021-02-06 23:05:06",
          "created_by": "[email protected]"
        },
        {
          "id": "4dd9555fbeffd727805d77a9b33c14d2",
          "title": "Give me the key",
          "author": "Roland Great",
          "description": "",
          "creation_date": "2021-02-06 23:05:21",
          "created_by": "[email protected]"
        }
      ]
}

  • Find a book

GET https://{domain}/api/v1/books/{id}

Headers: Bearer 1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K
Response
{
      "status": "success",
      "message": "Found a book with your id",
      "data": {
        "id": "ba080edcd4d7287c91506fe303b119ca",
        "title": "The Key to Success",
        "author": "Bola Akintomide",
        "description": "An inspirational book ...",
        "creation_date": "2021-02-06 23:05:06",
        "created_by": "[email protected]"
      }
}

  • Delete a book

DELETE https://{domain}/api/v1/books/{id}

Headers: Bearer 1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K
Response
{
  "status": "success",
  "message": "Book deleted successfully",
  "data": {}
}

  • Update a book

PATCH https://{domain}/api/v1/books/{id}

Headers: Bearer 1|5bfPsdWcztwVSOksyyKcyklaCobhiezUHecU5X0K
Payload
{
    "title" : "The Key to Greatness",
    "author" : "Bola Akintomide",
    "description" : "An inspirational book ..."
}
Response
{
      "status": "success",
      "message": "Book update was successful",
      "data": {
            "id": "ba080edcd4d7287c91506fe303b119ca",
            "title": "The Key to Greatness",
            "author": "Bola Akintomide",
            "description": "An inspirational book ...",
            "creation_date": "2021-02-06 23:05:06",
            "created_by": "[email protected]"
      }
}

crud_book_api's People

Contributors

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