Books Mock API
This is a mock api to use for frontend applications that simulates a simple book system.
;const users = await api;const books = await api;const book = books0;bookchecked_out = users3id;api;booktitle = 'New title';const newBook = await api;// newBook.id === new_title
If you want to play around with the api, open the
index.html file in your browser and open the devtools console and run commands like above,
api is already available on the
api.getUsers() returns a list of all users api.getBooks() returns a list of all books api.createBook(book) creates and returns a new book api.updateBook(book) updates an existing book
api.updateBook is like a
PUT operation and you must pass all keys in the book object.
A book can only be
checked_out by one user, but a user can check out many books. Updating and adding reviews is not supported (you can modify the field on the book object, but it won't update the corresponding user object references and there is no api for reviews retrieval).
User example data:
ryan_florence:id: 'ryan_florence'name: 'Ryan Florence'avatarURL: ''reviews:checked_out: 'console_wars' 'american_kingpin'
Book example data:
console_wars:id: 'console_wars'title: 'Console Wars: Sega, Nintendo, and the Battle that Defined a Generation'author: 'Harris J. Blake'image:''checked_out: 'ryan_florence'reviews:id: 5user: nullrating: 4book: 'console_wars'id: 6user: nullrating: 2book: 'console_wars'id: 7user: nullrating: 4book: 'console_wars'id: 8user: 'kent_dodds'rating: 5book: 'console_wars'description:'Following the success of The Accidental Billionaires and Moneyball comes Console Wars a mesmerizing, behind-the-scenes business thriller that chronicles how Sega, a small, scrappy gaming company led by an unlikely visionary and a team of rebels, took on the juggernaut Nintendo and revolutionized the video game industry. In 1990, Nintendo had a virtual monopoly on the video game industry. Sega, on the other hand, was just a faltering arcade company with big aspirations and even bigger personalities. But that would all change with the arrival of Tom Kalinske, a man who knew nothing about videogames and everything about fighting uphill battles. His unconventional tactics, combined with the blood, sweat and bold ideas of his renegade employees, transformed Sega and eventually led to a ruthless David-and-Goliath showdown with rival Nintendo. The battle was vicious, relentless, and highly profitable, eventually sparking a global corporate war that would be fought on several fronts: from living rooms and schoolyards to boardrooms and Congress. It was a once-in-a-lifetime, no-holds-barred conflict that pitted brother against brother, kid against adult, Sonic against Mario, and the US against Japan. Based on over two hundred interviews with former Sega and Nintendo employees, Console Wars is the underdog tale of how Kalinske miraculously turned an industry punchline into a market leader. Its the story of how a humble family man, with an extraordinary imagination and a gift for turning problems into competitive advantages, inspired a team of underdogs to slay a giant and, as a result, birth a $60 billion dollar industry.'