Here is an overview of the APIs:
Method | URL | Link |
---|---|---|
GET | /authors | Jump |
GET | /authors/authorId |
Jump |
GET | /authors/authorId /books |
Jump |
GET | /authors/authorId /books/bookId |
Jump |
GET | /authors?name=name |
Jump |
GET | /books | Jump |
GET | /books?name=name |
Jump |
POST | /authors | Jump |
POST | /authors/authorId /books |
Jump |
PUT | /authors/authorId |
Jump |
PUT | /authors/authorId /books/bookId |
Jump |
DELETE | /authors/authorId |
Jump |
DELETE | /authors/authorId /books/bookId |
Jump |
All handled errors return an error Json in following format:
{
"code": 400,
"error": "some-error-type",
"message": "A human readable description of the error",
"details": {
"key": "value"
}
}
with an HTTP status same as code
field.
All successful responses will have 200 OK
status unless explicitly mentioned below.
Below are more details about each endpoint.
Returns a list of all authors as a Json array
[
{
"id": "UUID-1",
"name": "Author 1"
},
{
"id": "UUID-2",
"name": "Author 2"
}
]
Returns an author as a Json object
{
"id": "UUID-1",
"name": "Author 1"
}
What | When |
---|---|
Not found | There is no author with given id |
TODO: This is not implemented yet!
Returns a list of books of an author as a Json array
[
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
},
{
"id": "UUID-2",
"isbn": "ISBN-2",
"name": "Book 2",
"author": "Author 1",
"price": 200
}
]
What | When |
---|---|
Not found | There is no author with given id |
Returns a book of an author as a Json object
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
}
What | When |
---|---|
Not found | There is no author with given id, no book with given id or no book whose author has given id |
Returns authors with matching names as a Json array
[
{
"id": "UUID-1",
"name": "Author 1"
},
{
"id": "UUID-2",
"name": "Author 2"
}
]
Returns a list of all books as a Json array
[
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
},
{
"id": "UUID-2",
"isbn": "ISBN-2",
"name": "Book 2",
"author": "Author 2",
"price": 200
}
]
Returns books with matching names as a Json array
[
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
},
{
"id": "UUID-2",
"isbn": "ISBN-2",
"name": "Book 2",
"author": "Author 2",
"price": 200
}
]
Creates a new author with given data and returns created author
{
"name": "Author 1"
}
201 Created
with following body
{
"id": "UUID-1",
"name": "Author 1"
}
What | When |
---|---|
Already exists | There is already an author with given name |
Creates a new book of an author with given data and returns created book
{
"isbn": "ISBN-1",
"name": "Book 1",
"price": 100
}
201 Created
with following body
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
}
What | When |
---|---|
Required | There is no author with given id |
Already exists | There is already a book with given isbn |
Updates an author with given data and returns updated author
{
"name": "Author 1"
}
{
"id": "UUID-1",
"name": "Author 1"
}
What | When |
---|---|
Unexpected action | There is no author with given id |
Already exists | There is already an author with given name |
Updates a book of an author with given data and returns updated book
{
"isbn": "ISBN-1",
"name": "Book 1",
"price": 100
}
{
"id": "UUID-1",
"isbn": "ISBN-1",
"name": "Book 1",
"author": "Author 1",
"price": 100
}
What | When |
---|---|
Unexpected action | There is no author with given id, no book with given id or no book whose author has given id |
Deletes an author
200 OK
with no body
What | When |
---|---|
Unexpected action | There is no author with given id |
In use | There are books assigned to the author |
Deletes a book of an author
200 OK
with no body
What | When |
---|---|
Unexpected action | There is no author with given id, no book with given id or no book whose author has given id |