gRPC

API - Application Programming Interface

2 min read

Published Sep 24 2025


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 message
message GetUserRequest {
  int32 id = 1;
}

// Response message
message 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.

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact