Good REST CRUD APIs_WS45

16
Good REST CRUD APIs WS45

Transcript of Good REST CRUD APIs_WS45

Page 1: Good REST CRUD APIs_WS45

Good REST CRUD APIs

WS45

Page 2: Good REST CRUD APIs_WS45

Woolery, Matthew A Govindu, Madanamohan R

Carstensen,Robert L Bhogireddy, Chandu Karri, Venkatesh

Page 3: Good REST CRUD APIs_WS45

CONTENTS

What is REST? What makes a good REST API? CRUD HTTP METHODS CRUD IN REST CRUD at User Interface Level Summary Resources

Page 4: Good REST CRUD APIs_WS45

What is REST?• REST == “REpresentational State Transfer”• It is an architectural style for designing

distributed systems, an approach to communication that is often used in the development of web services.

• The use of REST is often preferred over the more heavyweight SOAP.

• REST permits different data formats such as JSON,XML,HTML etc.

• Resource-based• Representations

Page 5: Good REST CRUD APIs_WS45

Web

Ser

ver

HTTP POST URL 3PO(HTML/XML)

HTTP GET request URL 1

HTTP responseURL to submitted PO

PartsList

PartData

PO

HTTP responseResponse(HTML/XML doc)

HTTP responseResponse(HTML/XML doc)

HTTP GET request URL 2

5Reference from RESTANDSOAP_WS63

Page 6: Good REST CRUD APIs_WS45

Resource-based

• Things vs, actions• Nouns vs. verbs• Resources are identified by URIs

RepresentationsExample:• Resource: Student• Service: Student information• Representation: Student name, GPA,

Student major, address, contact number.

Page 7: Good REST CRUD APIs_WS45

What makes a good REST API?The REST architectural style describes 6 constraints:

1. Uniform interface2. Stateless3. Client-server4. Cacheable5. Layered system6. Code on demand

• Following all these constraints means service is strictly RESTful.• Violating anyone of these will not give strict RESTful service

Page 8: Good REST CRUD APIs_WS45
Page 9: Good REST CRUD APIs_WS45

CRUD The acronym CRUD refers to all of the

major functions that are implemented in relational database applications. Each letter in the acronym can map to a standard SQL statement, HTTP method (this is typically used to build RESTful APIs)

Page 10: Good REST CRUD APIs_WS45

Operation SQL HTTP DDS

Create INSERT PUT / POST write

Read (Retrieve) SELECT GET read / take

Update (Modify) UPDATE POST / PUT/ PATCH write

Delete (Destroy) DELETE DELETE dispose

CRUD Operation HTTP MethodCreate POSTRead GETUpdate PUT and/or PATCHDelete DELETE

Page 11: Good REST CRUD APIs_WS45

HTTP METHODS – CRUD IN REST

• Both PUT and POST can create resources; the key difference is that POST leaves it for the server to decide at what URI to make the new resource available.

• PUT dictates what URI to use; The significant point about PUT is that it will replace whatever resource the URI was previously referring to with a brand new version, hence the PUT method being listed for Update as well.

CRUD Operation HTTP MethodCreate POST

Read GET

Update PUT and/or PATCH

Delete DELETE

Page 13: Good REST CRUD APIs_WS45

CRUD at User Interface level• CRUD is also relevant at the user interface level of most applications.• For example consider your phonebook. The software of phonebook must

allow the user to:

a) Create or add new entriesb) Read, retrieve, search, or view existing entriesc) Update or edit existing entriesd) Delete/deactivate/remove existing entries

• Without at least these four operations, the software cannot be considered complete.

Page 14: Good REST CRUD APIs_WS45

SUMMARY:

• Violating any constraint other than Code on Demand means service is not strictly RESTful

• Many HTTP services model CRUD operations through REST or REST-like APIs .

• With all the four CRUD operations, an application is said to be complete.

Page 16: Good REST CRUD APIs_WS45

Sai Venkat Poorna Chandu Bhogireddy Govindu, Madanamohan R

Karri Venkatesh Carstensen,Robert L Woolery,Matthew A