One Pager Cheat Sheet
- We can learn about HTTP request and response by deconstructing each of its components, such as the verb (a.k.a. method) with associated headers and an optional body, and understanding web server behavior, which is stateless.
- An "Unauthorized" request error can occur when the client does not include an
Authorization header
in the HTTP request, resulting in an error with a status code in the range 400-499, indicating a client error. - RPC and REST are two prominent approaches to distributed API design over the past few decades.
- RPC (
Remote Procedure Call
) is a way to call a function on a remote server, which usesGET
to fetch data andPOST
for everything else, and is good fit for APIs that are based on actions. - The RPC protocol uses
POST
for all calls that make updates to the server, while REST generally follows the conventions of usingGET
,PUT
,PATCH
, andDELETE
for modifications. - REST is an architecture style for creating stateless, cacheable, HTTP-semantic client-server APIs that enable
CRUD
operations on resources, expressed with uniqueURL
s and HTTP verbs. - No, REST and RPC are not interchangeable, as the HTTP verb used for each of them has a different purpose with regards to the type of operation.
- When deciding between
RPC
andREST
for an API, consider if it's mostly actions or structured data - and if it's both, it's OK to use both styles! - RPC APIs, such as
PlaceOrder
, are used to perform a certain action when a specific event occurs.