← Lessons

quiz vs the machine

Gold1480

Networking

REST versus gRPC

Compare two API styles by transport, payload, and use case.

5 min read · core · beat Gold to climb

Two Styles of API

REST models resources accessed with HTTP methods and usually JSON over HTTP1 one or HTTP2. gRPC is a remote procedure call framework using Protocol Buffers over HTTP2.

How They Differ

  • Payload: REST commonly sends human readable JSON, while gRPC sends compact binary Protocol Buffers that are faster to encode and smaller on the wire.
  • Contract: gRPC defines services in a strict schema that generates client and server stubs, while REST contracts are looser and often documented separately.
  • Streaming: gRPC supports client, server, and bidirectional streaming natively, while REST typically does request and response.
  • Reach: REST works everywhere including browsers, while gRPC needs special support in browsers through a proxy.

Choosing Between Them

  • Use REST for public APIs, broad client reach, and easy debugging with simple tools.
  • Use gRPC for internal service to service calls where low latency, strong typing, and streaming matter.

Both can coexist, with gRPC inside the cluster and REST at the public edge.

Key idea

REST favors broad reach and readable JSON, while gRPC favors compact binary payloads, strict schemas, and native streaming for internal services.

Check yourself

Answer to earn rating on the learn ladder.

1. Which serialization does gRPC use by default?

2. Why might a public web facing API choose REST over gRPC?