cmda-bt / be-course-17-18

🎓 Backend · 2017-2018 · Curriculum and Syllabus 💾
Other
47 stars 19 forks source link

Transfer assignment #490

Closed RowinVanAmsterdam closed 6 years ago

RowinVanAmsterdam commented 6 years ago

Finished transfer assignment

screen shot 2018-03-05 at 13 29 28

Cheatsheet transfer

API (for movies)

Means: server returns data (In this case: JSON data)

Localhost & curl

Curl: command line app, that can send HTTP requests. More options than browser.

Sending a http request in your webbrowser: localhost(bv: :1901) to reach the server.

curl localhost:1901 in your terminal to get the same response, but in the terminal instead of your webbrowser.

Head

API sends info about the request, aka headers. They don’t display that information, like element in html.

You can get the information with: —verbose

Document starts with: GET = request line *: data

: request <: response

Find out which options are supported for a resource

curl localhost:1901 --verbose --request OPTIONS

Status codes in the range of 4xx = error Status codes in the range of 2xx = everything is ok, but no need for the server to send any data back

HEAD = same as get, without the body. POST = add something to a resource PUT = place a resource somewhere, if it exists or not PATCH = change only a few things

API returns:

JSON data XML data HTML or CSV or other data, based on what the client wants

Client can support some kind of coding, so the server will send compression alsorithm. Gzip is popular compression.

You can authorise a request by using a token.

wooorm commented 6 years ago

SWEEET!