API Design Flashcards

1
Q

What REST stands for?

A
  • REST stands for Representational State Transfer which is a web standards based architecture and uses HTTP Protocol for data communication.
  • It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods.
  • REST uses various representations to represent a resource like text, JSON and XML. Now a days JSON is the most popular format being used in web services.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Mention some key characteristics of REST?

A

REST is stateless, therefore the SERVER has no state (or session data)

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

Explain the architectural style for creating web API?

A
  • HTTP for client server communication
  • XML/JSON as formatting language
  • Simple URI as the address for the services
  • Stateless communication
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are resources in a REST architecture?

A
  • REST architecture treats every content as a resource. These resources can be Text Files, Html Pages, Images, Videos or Dynamic Business Data. REST Server simply provides access to resources and REST client accesses and modifies the resources.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are advantages of REST web services?

A
  • Learning curve is easy since it works on HTTP protocol
  • Supports multiple technologies for data transfer such as text, xml, json, image etc.
  • No contract defined between server and client, so loosely coupled implementation.
  • REST methods can be tested easily over browser.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the core components of a HTTP Request?

A

A HTTP Request has five major parts −

  • Verb− Indicate HTTP methods such as GET, POST, DELETE, PUT etc.
  • URI− Uniform Resource Identifier (URI) to identify the resource on server.
  • HTTP Version− Indicate HTTP version, for example HTTP v1.1 .
  • Request Header− Contains metadata for the HTTP Request message as key-value pairs. For example, client ( or browser) type, format supported by client, format of message body, cache settings etc.
  • Request Body− Message content or Resource representation.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the core components of a HTTP response?

A

Status / Response Code- Indicate Server status for the requested resource. For example 404 means resource not found and 200 means response is ok.

HTTP Version- Indicate HTTP version, for example HTTP v1.3

Response Header- Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type etc.

Response Body- Response message content or Resource representation.

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

What are the best practices to create a standard URI for a web service?

A

Following are important points to be considered while designing a URI −

  • Use Plural Noun− Use plural noun to define resources. For example, we’ve used users to identify users as a resource.
  • Avoid using spaces− Use underscore(_) or hyphen(-) when using a long resource name, for example, use authorized_users instead of authorized%20users.
  • Use lowercase letters− Although URI is case-insensitive, it is good practice to keep url in lower case letters only.
  • Maintain Backward Compatibility− As Web Service is a public service, a URI once made public should always be available. In case, URI gets updated, redirect the older URI to new URI using HTTP Status code, 300.
  • Use HTTP Verb− Always use HTTP Verb like GET, PUT, and DELETE to do the operations on the resource. It is not good to use operations names in URI.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly