http and api Flashcards

1
Q

what does HTTP stand for

A

hypertext transfer protocol

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

what does API stand for

A

application programming interface

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

what are the RESTful HTTP methods?

A

GET, POST, PATCH, PUT, DELETE

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

which HTTP methods are safe? and what does safe mean?

A

GET – safe means that you are only viewing the resource, not changing it

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

which methods are idempotent? what does this mean?

A

everything except POST – idempotent means that no matter how many times you call the method, it returns the same result. for everything except POST, you are operating on the same resource every time. POST creates something new every time you call it.

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

what is statelessness?

A

REST communication is always stateless. this means that each request from client to server always carries all info needed. the server does not need to remember previous info.

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

what is REST?

A

representational state transfer. set of architectural design principles for HTTP APIs.

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

anatomy of a request

A

HTTP method, resource/url, headers, body

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

anatomy of a response

A

status code, headers, body

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

what code is an informational response?

A

1xx

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

which codes indicate success? creation?

A

2xx. 200 = request succeeded, 201 = resource created successfully.

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

which codes indicate that the client needs to take additional action?

A

3xx. 301 moved permanently. 302 found, resource at diff url temporarily. 307, temp redirect.

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

which codes indicate problems with a client’s request?

A

4xx. 400 invalid syntax or params, 404 not found, 422 unprocessable content, 403 forbidden.

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

which code indicates server error?

A

500

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

dynamic vs static path parts

A

static -> /users/. dynamic -> {user_id}.

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

good design conventions for paths and queries

A

paths:
* use nouns
* plural nouns for collections
* be consistent with plurals
* don’t nest too deeply (too long of a path) but use nesting for hierarchies
* use kebab-case or lowercase
* ids belong in paths not queries
queries:
* use for filtering. ? indicates start of query.

17
Q

body

A

used for POST and PUT methods that need more complex data. not visible in url.

18
Q

headers

A

carry additional metadata. authorization, content-type, accept. accept = what date type client expects. content-type = data type being sent or received.

19
Q

general format of API method decorator and function

A
@app.[METHOD] ("/route")
def function_name() -> returnType

you might also have {id} if it’s GET, PATCH, PUT, or DELETE in the route