A reverse-engineered Java ☕ version of the Book Database API. The original was written by David Andersson using PHP.
This is an intentionally poorly designed API that simulates a Book Database. Its purpose is for client-side developers to practice working with a flaky and badly designed API.
Databases automatically expire after 30 minutes of non-use.
This is the server code For the client-web app see book-api-js.
This is a Maven project.
To build the project run:
./mvnw install
- The API has a high likelihood of failing. On every operation.
- The API returns
HTTP 200
on every operation - The API accepts only query-parameters.
- Only
GET
is used.
Text by David Andersson.
This API simulates a book database. There are 4 operations available:
- Add data to database
- View data in database
- Modify data in database
- Delete data
In order to use the database you need an API key. Request a key by an GET
request with requestKey
in the query string. You must use that key in all
subsequent requests.
Example: localhost:8080/?requestKey
Add book information to the database. Query string parameters:
op=insert
key - an API key that identifies the request
title - the book title
author - the name of the author
This request will output a JSON
object of the following form if successful:
{
"status": "success",
"id": an id generated for the inserted data
}
Get all book information in database. Query string parameters:
op=select
key - an API key that identifies the request
This request will output a JSON
object of the following form if successful:
{
"status": "success",
"data": [{
"id": a unique id that identifies a book,
"title": book title,
"author": author name,
"updated": when the data was last updated
}]
}
Change the entry for a specific book. Query string parameters:
op=update
key - an API key that identifies the request
id - identifies what book you want to update
title - new title
author - new author
This request will output a JSON
object of the following form if successful:
{
"status": "success"
}
Delete the information for a specific book in the database. Query string parameters:
op=delete
key - an API key that identifies the request
id - identifies what book you want to remove
This request will output a JSON
object of the following form if successful:
{
"status": "success"
}
Every operation may fail! If an error occurs, the request will output a JSON
object that describes the error:
{
"status": "error",
"message": a descriptive message
}