cassieopia / book-club

An online book club
0 stars 0 forks source link

Design REST api #5

Open cassieopia opened 6 years ago

cassieopia commented 6 years ago

What's a REST api?

Not great at giving definition, but we wan't to design a protocol that our frontend knows how to get data and update data from the backend. We will use built in javascript tools to issue the http requests. The body of the requests will sometimes contain json, a way of formatting javascript objects. Our REST api will also return these json objects (we'll use a java library called jackson with immutables to take care of this for us -- it's less complicated than it sounds).

Getting Started

Follow this if you like videos and this if you don't.

Example

GET /books returns:

[
   {
      "id": 1,
      "title": "The Goldfinch",
      "author", "Donna Tart",
      "yearPublished": "2014",
      "properties": {}
   },
   {
      "id": 2,
      "title": "Harry Potter and the Sorcerer's Stone",
      "author", "J.K. Rolling",
      "yearPublished": "1997",
      "properties": {}
   }
]

You would get this data by running curl http://our.site.hostname/books

cassieopia commented 6 years ago

@Nickwang3 take a look at this for book id's

cassieopia commented 6 years ago

@Nickwang3 here's an api that we'll want to use to search for books. we might want to model our book class after the information they provide.