REST/RPC/GraphQL
REST
Pros
Good for exposing CRUD operations.
Easiest to maintain compared to others.
Standard method names, arguments and status codes.
Utilizes HTTP features.
Cons
Payload is big
JSON which is human readable.
Getting the entire User entity while I need the user's first and last name only.
Multiple HTTP roundtrips.
If you want to get a resource and its sub resource, you need to make a call for the resource and then another call for the sub resource. There is no way to combine the two calls into one in a RESTful way.
RPC
Notes
It’s all about actions
Example slack.
Usually supports GET for read only requests and POST for everything else.
Very popular among API providers recently.
gRPC.
Pros
Good for exposing several actions.
Small Payload
Because it’s in binary.
Payload is associated with the action itself, so only the required data is transmitted.
High performance because they are action oriented.
Easy to understand as the action is usually the part of the request.
Github.
Cons
Difficult to discover.
Limited standardization. Referencing documentation is important.
Function explosion.
GraphQL
Notes
Developed by Facebook.
Expose a single endpoint as an entry point.
Client then specifies what they need.
Pros
Good when the client needs filtering/flexibility.
Small payload because the response contains only the data client needs.
Clients can request multiple nested levels of data.
Don’t need versioning.
Cons
Complexity on the server.
Optimizing performance can be difficult.
Working with external users, it becomes difficult to identify different use cases.
Too complicated for simple APIs.