The following image displays the most common architectural styles for APIs.
🔹 1. REST REST, which was proposed in 2000, is the most widely used style for APIs. It is often utilized between front-end clients and back-end services, and it adheres to six architectural constraints. The payload format may be JSON, XML, HTML, or plain text.
🔹 2. GraphQL Meta proposed GraphQL in 2015. It provides a schema and type system that is ideal for complicated systems where entities' relationships are graph-like. In the diagram below, GraphQL can retrieve user and order information in one call, while REST necessitates multiple calls.
GraphQL does not replace REST but can be built upon existing REST services.
🔹 3. Web socket Web socket is a protocol that enables full-duplex communications over TCP. Clients create web sockets to receive real-time updates from back-end services. Unlike REST, which always "pulls" data, web socket allows data to be "pushed".
🔹 4. Webhook Webhooks are frequently used for third-party asynchronous API calls. In the diagram below, Stripe or Paypal is used for payment channels, and a webhook for payment results is registered. When a third-party payment service is completed, it notifies the payment service if the payment was successful or failed. Webhook calls are usually part of the system's state machine.
🔹 5. gRPC gRPC, which was released in 2016, is used for communications among microservices. The gRPC library handles encoding/decoding and data transmission.
🔹 6. SOAP SOAP stands for Simple Object Access Protocol, and its payload is only XML, making it suitable for internal system communications.
Comments
Post a Comment