REST API Flashcards

1
Q

What does REST stand for?

A

Representational State Transfer

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

How many principles are there for creating a REST API?

A

5

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

Name the principles for creating REST APIs

A
  1. Separate the API into logical resources,
  2. Provide resources based on URLs,
  3. Never add an HTTP method in the name of an endpoint,
  4. Only send and receive data in JSON format
  5. The API should always be stateless
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain the first principle ‘Separate the API into logical resources’

A

Divide your API into distinct resources that the client can interact with individually, each resource should be named using a noun. NEVER use a verb to name a resource

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

Explain the second principle ‘Provide resources based on URLs’

A

Resources should be accessible through a URL of the format: main_url/endpoint

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

Explain the third principle ‘Never add an HTTP method in the name of an endpoint’

A

There should never be HTTP methods for an endpoint or resources, regardless of the method for that resource the endpoint should always have the same name

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

Explain the fourth principle ‘Only send and receive data in JSON format’

A

It is self-explanatory, sending JSON should be of the format {status: ‘success/failed’, data/message: {data}/’error_message’}

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

Explain the fifth principle ‘The API should always be stateless’

A

It means the server should never have to keep track of anything on the client to send back a response, all the information needed for a response should be provided by the client in the request

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