# Rest vs GraphQL vs gRPC

Research Paper: <https://journals.pan.pl/dlibra/publication/149562/edition/131803/content>

This is the big confusion you get when you design a system architecture. API selection can make or break your architecture.&#x20;

Assume three API protocols as three people working to the bar

* **REST** orders everything on the menu because it doesn't know what the client wants.
* **GraphQL** asks the bartender for a custom cocktail, listing every ingredient.
* **gRPC** whispers a binary message and gets the drink instantly.

Choosing between the API Protocol is not about maintaining the latest trends its about the performance and scalability.&#x20;

* **REST** follows a standard request-response model over HTTP. It’s easy to use, but responses often include unnecessary data.
* **GraphQL** allows clients to request exactly what they need in a single query. It reduces over-fetching but can add processing overhead.
* **gRPC** uses Protocol Buffers over HTTP/2, making it highly efficient for service-to-service communication, but it comes with a learning curve.

&#x20;But how do we know when to use what ?&#x20;

* **REST** when simplicity and broad compatibility are the priority.
* **GraphQL** when optimizing data fetching matters.
* **gRPC** when performance and low-latency communication are critical.

Every choice has trade-offs, but making the right decision upfront can save time and complexity in the long run.

Practice here at System design studio to understand more about the API Protocols.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.mastersystemdesign.com/vs/rest-vs-graphql-vs-grpc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
