gitmyhub

grpc-gateway

Go ★ 20k updated 1d ago

gRPC to JSON proxy generator following the gRPC HTTP spec

A code generator that reads your gRPC service definition and automatically creates a REST JSON API alongside it, so web browsers and third-party tools can call your backend without a gRPC client.

Goprotobufsetup: hardcomplexity 4/5

gRPC-Gateway is a code generation tool that automatically creates a traditional REST (JSON over HTTP) API from a gRPC service definition, letting you offer both communication styles from the same backend without writing two separate servers.

To understand why this matters: gRPC is a high-performance remote procedure call system developed by Google that uses a compact binary format and generated code for tight client-server contracts. It is fast and efficient but requires clients that speak the gRPC protocol. REST APIs using JSON are the far more universal standard — supported by web browsers, curl, and virtually every HTTP library. Many teams want gRPC internally for speed and type safety, but also need a standard REST interface for external consumers, third-party integrations, or web frontends.

gRPC-Gateway solves this by reading your service's protobuf definition files (the schema files gRPC uses) and generating a reverse-proxy server in Go. You add special HTTP annotations to your protobuf definitions specifying how each gRPC method should map to HTTP endpoints, paths, and query parameters, and the tool generates the proxy code that translates incoming REST calls into gRPC calls and converts gRPC responses back to JSON. It also generates OpenAPI (Swagger) documentation automatically.

The setup involves installing a few code generation plugins and running the protobuf compiler against your service definition. The generated proxy can then run alongside your gRPC server. This is a Go project used by organizations serving millions of API requests per day that want to maintain both a high-performance internal gRPC interface and a broadly compatible REST API without duplicating server logic.

Where it fits