RESTful API Flashcards

1
Q

What are the 6 Architectural Constraints of a RESTful API

A

1) Client - Server Architecture
2) Stateless
3) Cache-ability
4) Layered System
5) Code On Demand (Optional)
6) Uniform Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 4 Constraints of a Uniform Interface

A

1) Resource identification in requests - Individual resources are identified in requests, for example using URIs in Web-based REST systems
2) Resource manipulation through representations - When a client holds a representation of a resource, including any metadata attached, it has enough information to modify or delete the resource
3) Self-descriptive messages - Each message includes enough information to describe how to process the message. For example, which parser to invoke may be specified by a media type
4) Hypermedia as the engine of application state (HATEOAS) - There is no need for the client to be hard-coded with information regarding the structure or dynamics of the REST service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

5 HTTP methods which can be used by RESTful API’s and what do they do

A

1) GET - Get
2) PUT - Replace
3) PATCH - Update
4) POST - Create
5) DELETE - Delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does REST in RESTfull stand for

A

Representational State Transfer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Representational State Transfer (REST)

A

Roy Fielding used term to describe

1) it is a network of Web resources (a virtual state-machine)
2) where the user progresses through the application by selecting links such as /user/tom, and operations such as GET or DELETE (state transitions).
3) This progress resulting in the next resource (representing the next state of the application) being transferred to the user for their use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe the 4 levels of the Richardson Maturity Model

A

0) Swamp of POX - HTTP model is used for remote interactions.
1) Resources - Each resource is mapped to a URI
2) Verbs - Correct HTTP verbs and Status codes are used
3) Hypermedia (HATEOUS) is used

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How could you structure the resource URI for an API which deals with books

A

1) Use Nouns not Verbs / Things not actions
2) Use Hierarchy when naming resources
3) Filters and Sorting are not resources
4) URI’s should remain the same (GUID vs DB field)
5) Pluralize resources
e. g. api/authors/{authorId}/books/{bookId}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the process by which a REST API manages its input and output message format through HTTP.

A

1) Using Content Negotiation
2) Accept Header - What I want the response in
3) Content-Type Header - The format of the message I’ve sent.
4) Return 406 - Not acceptable if the format requested is not available

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is method safety and method indempotency

A

1) A method is considered safe if it does not change the resource representation
2) A method is considered idempotent if it can be run a number of times with the same result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Upserting?

A

The client can generate the URI and use a PUT request to create resource rather than a POST request to an existing URI such a api/authors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain the constraint Client-Server architecture

A

1) The principle behind the client–server constraints is the separation of concerns.
2) Separating the user interface concerns from the data storage concerns improves the portability of the user interface across multiple platforms.
3) It also improves scalability by simplifying the server components. Perhaps most significant to the Web,
4) however, is that the separation allows the components to evolve independently, thus supporting the Internet-scale requirement of multiple organizational domains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Explain the constraint Statelessness

A

1) The client–server communication is constrained by no client context being stored on the server between requests.
2) Each request from any client contains all the information necessary to service the request, and session state is held in the client.
3) The session state can be transferred by the server to another service such as a database to maintain a persistent state for a period and allow authentication.
4) The client begins sending requests when it is ready to make the transition to a new state. While one or more requests are outstanding, the client is considered to be in transition.
5) The representation of each application state contains links that may be used the next time the client chooses to initiate a new state-transition.[11]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain the constraint Cacheability

A

1) As on the World Wide Web, clients and intermediaries can cache responses.
2) Responses must therefore, implicitly or explicitly, define themselves as cacheable or not to prevent clients from getting stale or inappropriate data in response to further requests.
3) Well-managed caching partially or completely eliminates some client–server interactions, further improving scalability and performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain the constraint Layered system

A

1) A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way.
2) Intermediary servers may improve system scalability by enabling load balancing and by providing shared caches. They may also enforce security policies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly