REST Basics Flashcards

1
Q

Why did technologies like SOAP and WSDL come in picture on top of HTTP?

A

Web APIs use HTTP, by definition. In the early days of web APIs, people spent a lot of time and effort
figuring out how to implement the features of previous-generation distributed technologies like CORBA
and DCOM on top of HTTP. This led to technologies like SOAP and WSDL.

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

Why did plain HTTP replace SOAP and WSDL?

A

Experience showed that these
technologies were more complex, heavyweight, and brittle than was useful for most web APIs. The idea
that replaced SOAP and WSDL was that you could use HTTP more directly with much less technology
layered on top.

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

How are modern APIs built as compared to SOAP and WSDL? Have we adopted something from past?

A

Most modern web APIs are much simpler than SOAP or WSDL APIs, but preserve some of
the basic ideas of remote procedure call—which is not native to HTTP—implemented much more lightly
on top of HTTP. These APIs have come to be known as RESTful APIs.

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

Why it pays off to follow HTTP standards in APIs?

A
  • There is value in adhering to standards
  • HTTP specifications are well known and well defined
  • HTTP standards are universally accepted
  • Reinventing an alternative that will serve users better are low
  • Not all users will have in depth knowledge of HTTP specification but it is better investment to make them learn standard HTTP mechanism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

According to HTTP standard if API uses POST to create resource which header should be included in response?

A

Location Header should be included in response that includes the URL of the newly created resource, along with 201 status code.

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

According to HTTP standard if you need to check if two people don’t try to update the same resource simultaneously which header should be used?

A

ETag and If-Match headers should be used, which are part of HTTP standard.

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

According to HTTP which header should be used if your API allows multiple formats

A

Use HTTP Accept-Header to provide client an opportunity to choose the format that the client wants to work with.

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

What is Web API?

A

A web API is the pattern of HTTP requests and responses that is used to acess a website that is specialized for access by arbitrary computer programs, rather than (or as well as) web browsers used by humans.

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

What is REST?

A
  • Architectural style of HTTP itself
  • HTTP is the reality & REST is a set of design ideas that shaped it.
  • The importance of REST is that it helps us understand how to think about HTTP and its use
  • The majority of modern APIs uses some subset of the concepts from HTTP, blended with some concepts from other computing technologies. For example, many web APIs are defined in terms of endpoints that have
    parameters. Endpoint and parameter are not terms or concepts that are native to HTTP or REST—they are
    concepts carried over from Remote Procedure Call (RPC) and related technologies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is RESTful API?

A

The term RESTful has emerged for web APIs that use more of the native concepts and techniques of HTTP than antecedent technologies did, but also blend in other concepts. Many good APIs have been designed this way, and in fact, this blended style is probably the most common API style in use. HTTP and REST are precisely defined, but the term RESTful is not.

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

Antoine de Saint-Exupery quote on perfection

A

“perfection is achieved not

when there is nothing more to add, but when there is nothing more to take away.”

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

What can be said about coupling of clients and servers when designing Web APIs?

A

One of the most important characteristics that designers of distributed APIs strive for is minimizing
coupling between the client and the server. The measure of coupling is how easily either side can be
changed without breaking the other. Minimizing coupling is one of the most difficult things to achieve
in API design.

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

HTTP and REST: A Data-oriented Design Paradigm. Explain this

A

A REST API focuses on the underlying entities of the problem domain it exposes, rather than a set of
functions that manipulate those entities.
For example if we are tracking dogs and their owners. We might expose two endpoints
1) The collection of known dogs
https://dogtracker.com/dogs

2) Individual dogs
https: //dogtracker.com/dogs/id

Similarly for owners

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

REST based API vs Functional based API

A

Consider domain of dogs and owners

Functional based API
In a functional oriented API you have endpoints which are functions like
/getAllDogs, /getAllLeashedLogs
/verifyLocation, /verifyVeterinarianLocation, /feedNeeded, /feedNeededFood, /newDog, /newDogForOwner etc.
There is no uniformity and convention in this web API which makes it difficult to predict and learn. With every new API you have to learn again as there is nothing common from previous APIs.

REST based API
A significant part of the value of basing your API design on HTTP and REST comes from the uniformity
that it brings to your API.
In REST, this idea is called the uniform interface constraint.

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