rest Flashcards

1
Q

what is rest

A

REST (representational state transfer) can essentially be seen as a set of constraints, which should be ad-
hered when designing an API. The restraints should improve scalability,
remixability, usability and accessibility of the program

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

what 5 constraints define REST?

A
  1. Resource Identification (RI): Every resource that can be accessed
    should be named. This also means that anything that can be named
    is a resource. In the web URIs provide a way global addressing space
    for resource and service discovery.
  2. Uniform Interface (UI): There should be a small set of operations
    (GET, POST, DELETE,…) that can be applied to all resources.
    This results in a small set of verbs and a large set of nouns. Verbs
    can be expanded if needed. Operations should adhere to the CRUD
    (Create, Retrieve, Update, Delete) principle.
  3. Self-describing Messages (SDM): Resources are abstract entities, they
    cannot be accessed directly, we identify them (RI) and access them
    (UI). The resources are accessed by accessing a representation of the
    resource. Which representation is used (e.g. JSON, XML, CSV,
    XHTML, SVG, RDF,…) is made clear, then this is sufficient.
  4. Hypermedia as the Engine of Application State (HATEOAS): The re-
    source representation (SDM) contains a link to the identifiable re-
    source (RI). Now the resources and their representations can be ac-
    cessed through link navigation. RESTful applications navigate with
    traversal paths contained in the resource representation. Link se-
    mantics determine the navigation to the next resource.
  5. Stateless Interactions (SI): States on the server side of the application
    should be avoided. No history of requests is kept the server should
    treat every request like a new one. The resource state can be managed
    by the server it is the same for all clients and can be changed by the
    client. Client state managed by the client itself. Each client manages
    its own state.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How are the REST style constraints related to its goals?

A
  1. Scalability: By making the system stateless, it is easy to scale the
    systems user base. Also by the UI it is easy to add new resources
    since they only have to interact with a few words.
  2. Simplicity: RESTful desing adheres to well established stadards. This
    simplifies the design and implementation process.
  3. Data independence: Because of the SDM a plethora of users can ac-
    cess the resources in a way that suites their needs. Each resource can
    be represented in multiple ways.
  4. Performance: The usage of lightweight message formats like JSON
    (SDM) allows for better performance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what’s richardson’s model?

A

it is a model that classifies Web APIs based on their adherence and conformity to each of the model’s four levels.

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

What are the maturity levels in Richardson’s model? Which

REST principles are they related to?

A

Level 0: POX (Plain old XML)
HTTP is used as a transport system for remote interactions. No
web mechanics are used, HTML is a tunneling mechanism for RPC.
Resources are identifiable and can be represented in any way. Data
and meta-data is contained in the message body

Level 1: Resources (RI)
In this level all resources are uniquely identifiable. For example doc-
tors or appointment slots. This directly corresponds to the resource
identification restraint.

Level 2: HTTP verbs (UI & SDM)
This level adds the usage of HTTP verbs. This means that resources
are called with a verb based on how the user wants to interact with
the resource. Responses always carry a status code telling the user
about success or failure of the request. Meta-data is used to identify
the resource in URI. This corresponds to the uniform interface and
self describing messages restraints.

Level 3: Hypermedia Controls (HATEOAS & SI)
This level introduces hypermedia controls. This means that it pro-
vides the representation (link) to the next valid state change opera-
tions of the resource. It also provides the URI of the resource in the
response. This allows for dynamic adjustment of links to resources.
This corresponds to the Hypermedia as the Engine of Application
State and Stateless Interactions restraints.

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

what are 5 best practices according to Masse’s book?

A
  1. Hierarchical relationships should be represented by a /.
    http://localhost:8080/Category/Subcategory/Products
    Here a category contains a subcategory which in turn contains prod-
    ucts.
  2. Plural nouns should be used when appropriate.
    http://localhost:8080/Organization/Departments/1
    This indicates that an organization has many departments.
  3. Design should improve readability. This means to use lower case let-
    ters, - instead of , and avoid special characters.
    http://localhost:8080/House/number-of-rooms
    instead of
    http://localhost:8080/House/#ofRooms
  4. File extensions should not be used (.html, .asp,…)
  5. Query parameters should be used for filtering.
    http://localhost:8080/Organization/Departments?name=HR
    Here the query paramenter is ?name=HR
  6. URIs should not be used wiht CRUD operations.
    Do not use
    http://localhost:8080/Organization/get-Departments/1
    but rather
    http://localhost:8080/Organization/Departments/1 coupled with a GET
    request
How well did you know this?
1
Not at all
2
3
4
5
Perfectly