Dr. Greg Bernstein
Updated October 31st, 2021
What are they?
From Understanding RPC, REST and GraphQL
RPC is the earliest, simplest form of API interaction. It is about executing a block of code on another server
An API is built by defining public methods; then, the methods are called with arguments. RPC is just a bunch of functions…
Some well known RPC implementations
JSON-RPC: Wikipedia JSON-RPC, JSON-RPC v2. Lightweight easy to understand.
SOAP:Wikipedia SOAP “a messaging protocol specification for exchanging structured information in the implementation of web services in computer networks.”. Very heavy designed for multiple different transports including HTTP.
gRPC: gRPC website Open source from Google. “gRPC is a modern open source high performance RPC framework that can run in any environment.”
From Wikipedia
{"jsonrpc": "2.0", "method": "subtract",
"params": {"minuend": 42, "subtrahend": 23}, "id": 3}
{"jsonrpc": "2.0", "result": 19, "id": 3}
jsonrpc
fieldid
fieldGraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn’t tied to any specific database or storage engine and is instead backed by your existing code and data.
REST API Tutorial: This will be our main reference as it is fairly complete, shorter than an entire book on RESTful APIs (of which there are a number), and it is up to date with current practices, e.g., JSON for data transfer rather than XML.
My very high and low level views
Representational State Transfer – Guiding Principles –
Representational State Transfer – Guiding Principles –
Cacheable: Or better as cache sensitive via explicit or implicit cache control. This can be an important optimization, but we will not cover it.
Layered Systems: This is a common architectural technique we won’t cover it explicitly.
Code on demand (optional): We won’t cover this. Note dynamic JavaScript module loading seems to do this.
From REST Resource Naming Guide
http://api.example.com/user-management/users
http://api.example.com/user-management/users/{id}
Document: a singular thing, use a singular noun for it.
Collection: “A collection resource is a server-managed directory of resources. Clients may propose new resources to be added to a collection.” Use a plural noun.
Store: “A store is a client-managed resource repository. A store resource lets an API client put resources in, get them back out, and decide when to delete them.” Think shopping cart…
Our ficticious multi-user assignment/peer review site
/users
/users/{userID}
/assignments
/assignments/{assignmentID}
/assignments/{assignmentID}/submissions
From REST Resource Naming Guide
From REST Resource Naming Guide
Use the POST method to create a new resource into a collection of resources.
Use the PUT method primarily to update existing resource.
Use the DELETE method for deleting resources