HTTP and all the REST - 401-advanced-javascript-aimurphy/seattle-javascript-401n13 GitHub Wiki

HTTP-how clients and servers "talk"

HyperText Transfer Protocol - supports a mixture of network configurations and allows communication between a variety of hosts and clients by assuming very little about the systems and not keeping state between different message exchanges--it's stateless!

note: comms usually over TCP/IP, default port 80

API-the messenger

App Program Interface - one software says "gimme info in a certain format and i'll give you a response with info" request response

Think of a ramen restaurant: you are the customer, the API is the ordering machine, the kitchen is the server.

To place an order you need to use the correct format, the machine takes formatted requests. Based on the request the kitchen sends you the ramen you are looking for.

REST-lets us use http to format messages

REpresentational State Transfer is an architectural style for designing network apps by relying on stateless client server comms call - http. Every time you load a webpage an http request is being made to a server somewhere. http provides the delivery methods. treats objects on server-side as resources we can CRUD (Create(post), Read(get), Update, Delete). can be used by any programming language because all languages are capable of http.

HTTP methods aka request verbs:

GET - retrieve data from specified form

POST - submit data for processing by specific resource

above methods can be done by webform alone (action and method), get from forms is not secure and data can be see by anyone

UPDATE - send request to URI endpoint with a specific id so the server knows exactly which one you are updating

DELETE - delete a specified resource (needs id) from the server

Lesser Verbs

HEAD - like get but doesn't return a body just head info

OPTIONS see supported method of a server

PATH - update partial resources

Status Codes

1xx psa
2xx success!
3xx redirect
4xx you messed up
5xx the server messed up

Endpoints

URI or URL that http reqs are sent to.

Authentication

using endpoints without aunthetication means it's a public or open API, otherwise keys and tokens, like oauth(request with an access token).

when in doubt, check the docs! They're super helpful--sometimes! they will have enpoint info, verbs, pagination, and more!

More on http

swagger api docs