gRPC

API - Application Programming Interface

2 min read

Published Sep 24 2025, updated Aug 17 2026


8
0
0
0

API

gRPC is a high-performance RPC framework developed by Google. It uses HTTP/2 for transport and Protocol Buffers (Protobuf) for compact, binary data serialisation.




Key Features

  • RPC model → Call methods like local functions (GetUser(id)).
  • HTTP/2-based → Supports multiplexing, compression, streaming.
  • Strongly typed contracts → Defined with Protobuf .proto files.
  • Supports bi-directional streaming.



Advantages

  • Very fast & efficient (binary messages).
  • Cross-language support (many SDKs).
  • Excellent for microservices.
  • Streaming support → Real-time communication.



Disadvantages

  • Requires tooling (Protobuf compilation).
  • Less human-readable than JSON.
  • Not always best for public APIs (steeper adoption curve).
  • Browser support limited (needs gRPC-Web for JS apps).



Common Use Cases

  • Microservices communication.
  • High-performance backend systems.
  • Real-time apps (chat, video, IoT).
  • Internal APIs where speed matters.



Security

gRPC also doesn’t have built-in auth — it uses transport-level or metadata-based auth:

  • TLS / mTLS → Mutual authentication using certificates.
  • JWT or OAuth 2.0 tokens → Sent as metadata in each RPC call.




Example request

Before making requests, you define a service in a .proto file:

syntax = "proto3";package user;service UserService {  // Get user by ID  rpc GetUser (GetUserRequest) returns (GetUserResponse);}// Request messagemessage GetUserRequest {  int32 id = 1;}// Response messagemessage GetUserResponse {  int32 id = 1;  string name = 2;  string email = 3;}

Explanation:

  • rpc GetUser defines a remote procedure.
  • GetUserRequest and GetUserResponse define the request and response messages.
  • The client calls GetUser like a local function.
  • gRPC handles serialisation, transport, and deserialisation automatically.
  • The server will return a binary Protobuf message, which the client automatically decodes.
  • Internally, this is transmitted in compact binary format over HTTP/2, not plain text.
  • You don’t see raw JSON unless you use gRPC-Web or a debugging tool.
© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
API - Application Programming Interface | gRPC | SimpleSteps.guide