REST API vs gRPC
People think gRPC is just a faster REST, and it is not. REST gives each thing an address and uses HTTP methods on it, with JSON most people can read. gRPC calls named functions and sends packed bytes. It is faster between services, but a browser cannot call it without help.
REST API
A web API where each thing has its own address, and HTTP methods act on it.
A REST API gives each thing, called a resource, its own web address. You act on them with the normal HTTP methods: GET to read, POST to create, PUT or PATCH to change and DELETE to remove. Each request carries everything the server needs, so the server keeps no memory between requests. Answers are usually JSON. REST was described by Roy Fielding in 2000 and is the most common style of web API.
gRPC
A fast way for one service to call another. Its messages are small.
gRPC is a fast way for services to call each other's functions. Google made it and opened it to everyone in 2015. You describe each service and its messages in a .proto file. Tools turn that file into ready code for many languages. Messages are sent in a small binary format called Protocol Buffers, over HTTP/2. It is fast and strict, so firms use it between their own services.
In one line
- REST API
- A web API where each thing has its own address, and HTTP methods act on it.
- gRPC
- A fast way for one service to call another. Its messages are small.