REST vs SOAP vs GraphQL
Introduction
In the late 1990s and early 2000s, two different design models became the norm in exposing data publicly.
-
SOAP (Simple Object Access Protocol) is an actual protocol that provides you with stricter detail about what an API does. This design model is suitable within most enterprise environment due to its solid, reliable pattern.
-
REST (REpresentational State Transfer) is used for public APIs and is ideal for fetching data from the web. It’s much lighter and closer to the HTTP specification than SOAP. REST style of delivering APIs is relying on the HTTP specifications the web is built upon.
There’s a new design model in town called GraphQL which is created by Facebook. GraphQL is very flexible query language for APIs, where the clients decide exactly what they want to fetch from the server instead of the server deciding what to send. This model starts with building a schema which is hard as it requires strong typing in the Schema Definition Language.
Comparison
SOAP is troublesome but its rich security features remain irreplaceable for billing operations, booking systems, and payments.
REST has the highest abstraction and best modeling of the API but a downside is if you’re working on mobile.
GraphQL is a big step forward in terms of data fetching but not everyone has enough time and effort to building schema.
Four major API styles compared:
Check out the video about the comparison if prefer watching:
See also: