Skip to content

ullenius/forverkliga-book-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Book Database API Backend

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.

👷 Installation

This is a Maven project.

To build the project run:

./mvnw install

📌 API Summary

  1. The API has a high likelihood of failing. On every operation.
  2. The API returns HTTP 200 on every operation
  3. The API accepts only query-parameters.
  4. Only GET is used.

ℹ️ Technical API Documentation

Text by David Andersson.

This API simulates a book database. There are 4 operations available:

  1. Add data to database
  2. View data in database
  3. Modify data in database
  4. Delete data

🔑 API key

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 data

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
}

👓 View 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
	}]
}

📝 Modify data

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 data

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"
}

💩 Errors

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
}

About

Book Database API for use as practice by client-side developers. Mocks a poorly designed API with CRUD-functionality. Randomly fails ~80% of operations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published