Rest APIs Flashcards

1
Q

What does REST stand for ?

A

Representation State Transfer

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

Define your ressource in 4 steps

A
  1. Decide what resource(s) need to be available
  2. Assign URLs to the resources
  3. Decide what actions the client should be allowed to perform on those resources
  4. Figure out what pieces of data are required for each action and what format they should be in.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name 3 best practicies for REST

A
  1. Use nouns not verbs
  2. Get and query should not alter the state
  3. Use plurals nouns
  4. Use sub-ressources for relations
  5. Provide Filter, Sort, Paging for all ressources
  6. Version your API
  7. Handle errors with HTTP status messages (200 = ok, 304 not modified
    400 error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does a filter look like ?

A

GET /cars?color=red Returns a list of red cars

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

How does a sort look like ?

A

GET /cars?sort=-manufactorer,+model

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

What is the basic authentication ?

A
  1. URL
  2. Method
  3. Header
  4. Payload
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a version look like ?

A

/blog/api/v1

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

Handle errors with HTTP status messages

A

200 – OK – Eyerything is working
201 – OK – New resource has been created
204 – OK – The resource was successfully deleted

304 – Not Modified – The client can use cached data

400 – Bad Request – The request was invalid or cannot be served. The exact error should be explained in the error payload. E.g. „The JSON is not valid“
401 – Unauthorized – The request requires an user authentication
403 – Forbidden – The server understood the request, but is refusing it or the access is not allowed.
404 – Not found – There is no resource behind the URI.
422 – Unprocessable Entity – Should be used if the server cannot process the

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

What headers do you have ?

A

Get (read)
Post (Create)
PUT (update)
Delete

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