REST API Basics Module #63 Flashcards

1
Q

Generally speaking, what are the 2 main categories of API’s?

A

REST and GraphQL.

SOAP is another but not very popular in the JS world.

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

In REST what is an endpoint?

A

An endpoint is a place where a client can access data (most often JSON) from a server.

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

What method signals to the server that we want to read data?

A

This is the GET Method
Example
GET /people returns a list of people
GET /person/1 returns data for that person

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

What method signals that we want to provide data to the endpoint?

A

POST

The endpoint is the same but another action takes place.

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

What methods can we use to update or even remove data?

A

PUT or PATCH can update data
DELETE is used to remove a chunk of data

Sometimes however, POST is used for everything that isn’t reading.

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

What’s considered a best practice when naming endpoints

A

Use a noun to describe what kind of data is being exchanged.

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

What does it mean to say, “A REST API is stateless”?

A

It means that the API retains no memory from one request to another.

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

What mechanisms are used to monitor useage and force limits?

A

API Keys identify API consumers as well as login/password methods and session tokens.

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

What two response forms are provided to the user as a way to understand the status of a request?

A

Status codes and response bodies. For example:

Status code 200 OK means everything worked fine
A 404 NOT FOUND is obviously an error that occurred. But there are many more:

201 Created: Typically a response to a POST request. The request has been completed, and a new resource has been created.

400 Bad Request Due to a request error that was generated on the client, the server cannot process the request. Errors can include a malformed request, size too large to be handled, or others

401 Unauthorized Sent when authentication is required and the client is not authorized

403 Forbidden The resource is not available for various reasons. If the reason is authentication, prefer the 401 Unauthorized status code.

405 Method Not Allowed The resource is not available through that HTTP method, but might be with another.

500 Internal Server Error A generic server error message, given when an unexpected condition was encountered and no more specific message is suitable.

Full List: https://flaviocopes.com/http-status-codes/

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

Response codes are one thing but, what exactly is the response body?

A

Typically it’s the JSON that gets returned or in the case of an error, that is the response body.

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