Book Buddy (1.1.1)

Book Buddy is a platform where users can browse a wide selection of books. Anyone is welcome to peruse our shelves, but if you log in, you can also reserve a book to borrow!

API Usage

The URL to access a resource from this API is structured as follows:

  • The base URL is https://fsa-book-buddy-b6e748d1380d.herokuapp.com/api
  • The next segment is based on the resource you want to access e.g. /books

For example, the URL for all books would be:

https://fsa-book-buddy-b6e748d1380d.herokuapp.com/api/books

Authentication

When using the API, many calls are made in the context of a registered user. The API protects itself by requiring a token string passed in the header for requests made in that context.

The Authorization header should be a string with the format Bearer token; the token is received either by registering or logging in. Deviating from this format will cause the API to not recognize the token and will result in an error.

If the token is malformed, missing, or has been revoked, you will get a response specific to that.

Users

Users need an account in order to access many of the endpoints on this API.

Register

Request Body schema: application/json
required
firstname
string

the first name of the user

lastname
string

the last name of the user

email
required
string

the email of the user

password
required
string

the password of the user

Responses

Response Schema: application/json
message
string

the success message

token
string

the JSON Web Token used to authenticate the user for any future requests

object

Request samples

Content type
application/json
{
  • "firstname": "Naomi",
  • "lastname": "Nagata",
  • "email": "naomi@roci.io",
  • "password": "krypt0n0rbust"
}

Response samples

Content type
application/json
{
  • "message": "Success!",
  • "token": "abcdefghijklmnopqrstuvwxyz",
  • "user": {
    }
}

Login

Request Body schema: application/json
required
email
required
string

the email of the user

password
required
string

the password of the user

Responses

Response Schema: application/json
message
string

the success message

token
string

the JSON Web Token used to authenticate the user for any future requests

Request samples

Content type
application/json
{
  • "email": "naomi@roci.io",
  • "password": "krypt0n0rbust"
}

Response samples

Content type
application/json
{
  • "message": "Success!",
  • "token": "abcdefghijklmnopqrstuvwxyz"
}

Get your account details

Authorizations:
token

Responses

Response Schema: application/json
firstname
string

the first name of the user

lastname
string

the last name of the user

email
string

the email of the user

id
number

the database identifier of the user

Array of objects

Response samples

Content type
application/json
{}

Books

Lots of words!

Get all books

Responses

Response Schema: application/json
Array
id
number

the ID of the book

title
string

the title of the book

author
string

the author of the book

description
string

a brief overview of the book

coverimage
string

a URL to the cover image of the book

available
boolean

whether the book is available to reserve

Response samples

Content type
application/json
[]

Get book details

path Parameters
id
required
number
Example: 37

the ID of the book to retrieve

Responses

Response Schema: application/json
id
number

the ID of the book

title
string

the title of the book

author
string

the author of the book

description
string

a brief overview of the book

coverimage
string

a URL to the cover image of the book

available
boolean

whether the book is available to reserve

Response samples

Content type
application/json
{}

Reservations

Users can reserve a book if it is available.

Get your reservations

Authorizations:
token

Responses

Response Schema: application/json
Array
id
number

the ID of the reservation

bookid
number

the ID of the reserved book

title
string

the title of the book

author
string

the author of the book

description
string

a brief overview of the book

coverimage
string

a URL to the cover image of the book

Response samples

Content type
application/json
[]

Reserve a book

Authorizations:
token
Request Body schema: application/json
required
bookId
required
number

the ID of the book to reserve

Responses

Request samples

Content type
application/json
{
  • "bookId": 37
}

Response samples

Content type
application/json
{
  • "id": 65,
  • "bookid": 37,
  • "userid": 1
}

Return a book

Authorizations:
token
path Parameters
id
required
number
Example: 65

the ID of the reservation to delete

Responses