API Design and REST Flashcards

1
Q

What does API stands for?

A

Application Program Interface

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

What does REST stands for?

A

REpresentational State Transfer

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

What is the purpuse of REST?

A

Create standards for communication between two servers that are located anywhere in the world

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

What do you understand by RESTful Web Services?

A

RESTful web services are services that follow REST architecture. REST stands for Representational State Transfer and uses HTTP protocol (web protocol) for implementation. These services are lightweight, provide maintainability, scalability, support communication among multiple applications that are developed using different programming languages. They provide means of accessing resources present at server required for the client via the web browser by means of request headers, request body, response body, status codes, etc.

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

What is a URI (Uniform Resource Identifier)?

A

Is used for identifying each resource of the REST architecture. There are two types URL and URN.

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

Mention 3 features of a RESTful service:

A

The service is based on the Client-Server model.
The service uses HTTP Protocol for fetching data/resources, query execution, or any other functions.
The medium of communication between the client and server is called “Messaging”.
Resources are accessible to the service by means of URIs.
It follows the statelessness concept where the client request and response are not dependent on others and thereby provides total assurance of getting the required data.
These services also use the concept of caching to minimize the server calls for the same type of repeated requests.
These services can also use SOAP services as implementation protocol to REST architectural pattern.

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

Mention 3 status codes and their meaning:

A

200 - success/OK
201 - CREATED - used in POST or PUT methods.
304 - NOT MODIFIED - used in conditional GET requests to reduce the bandwidth use of the network. Here, the body of the response sent should be empty.
400 - BAD REQUEST - This can be due to validation errors or missing input data.
401- UNAUTHORIZED - This is returned when there is no valid authentication credentials sent along with the request.
403 - FORBIDDEN - sent when the user does not have access (or is forbidden) to the resource.
404 - NOT FOUND - Resource method is not available.
500 - INTERNAL SERVER ERROR - server threw some exceptions while running the method.
502 - BAD GATEWAY - Server was not able to get the response from another upstream server.

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

Mention 3 http Methods:

A

GET: This is used for fetching details from the server and is basically a read-only operation.
POST: This method is used for the creation of new resources on the server.
PUT: This method is used to update the old/existing resource on the server or to replace the resource.
DELETE: This method is used to delete the resource on the server.
PATCH: This is used for modifying the resource on the server.
OPTIONS: This fetches the list of supported options of resources present on the server.

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

Can you describe your process for designing REST APIs?

A

1.Determine what resources or services you want to expose and what actions clients can perform
2.Design the URL structure and decide what methods to use.
3.Consider how versioning will be handled in your API design.
4.Define mechanisms for authenticating and authorizing API requests.
5. Define error handling mechanisms. Use status codes.
6. API deals with large datasets, consider incorporating mechanisms for pagination and filtering to improve performance and usability.
7. Documentation
8. Test

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

What is a payload?

A

Payload refers to the data passes in the request body. It is not the same as the request parameters. The payload can be sent only in POST methods as part of the request body.

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

When is it better to use REST over GraphQL?

A
  1. If caching is a crucial requirement for your application
  2. If your API primarily focuses on basic CRUD
  3. Compatibility with existing tools and systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When is it better to use GraphQL over REST?

A
  1. GraphQL excels when you need to fetch data with complex and flexible requirements.
  2. GraphQL allows clients to retrieve multiple resources in a single request, reducing the number of round-trips to the server.
  3. Aggregating data from multiple sources.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly