--- url: "https://grpc.io/docs/guides/reflection/" titulek: "Reflection | gRPC" h1: "Reflection" popis: "Explains how reflection can be used to improve the transparency and interpretability of RPCs." jazyk: "en" kanonicka: "https://grpc.io/docs/guides/reflection/" drobecky: ["Docs", "Guides", "Reflection"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:01:10" znaku: 4951 slov: 517 kodovani: "utf-8" sha256: "ad87277fb94f5e80730a3deedc768745f05a23896ebbb1d810a7aecff2fcdc88" --- # Reflection Explains how reflection can be used to improve the transparency and interpretability of RPCs. Contents # Reflection Explains how reflection can be used to improve the transparency and interpretability of RPCs. ### Overview Reflection is [a protocol](https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto) that gRPC servers can use to declare the protobuf-defined APIs they export over a standardized RPC service, including all types referenced by the request and response messages. Clients can then use this information to encode requests and decode responses in a human-readable manner. Reflection is used heavily by debugging tools such as [`grpcurl`](https://github.com/fullstorydev/grpcurl) and [Postman](https://learning.postman.com/docs/sending-requests/grpc/grpc-client-overview/). One coming from the REST world might compare the gRPC reflection API to serving an OpenAPI document on the HTTP server presenting the REST API being described. ### Transparency and Interpretability A big contributor to gRPC’s stellar performance is the use of Protobuf for serialization – a *binary* non-human-readable protocol. While this greatly speeds up an RPC, it can also make it more difficult to manually interact with a server. Hypothetically, in order to manually send a gRPC request to a server over HTTP/2 using `curl`, you would have to: 1. Know which RPC services the server exposed. 2. Know the protobuf definition of the request message and all the types *it* references. 3. Know the protobuf definition of the response message and all the types *it* references. Then, you’d have to use that knowledge to hand-craft your request message(s) into binary and painstakingly decode the response message(s). This would be time consuming, frustrating, and error prone. Instead, the reflection protocol enables tools to automate this whole process, making it invisible. ### Enabling Reflection on a gRPC Server Reflection is *not* automatically enabled on a gRPC server. The server author must call a few additional functions to add a reflection service. These API calls differ slightly from language to language and, in some languages, require adding a dependency on a separate package, named something like `grpc-reflection` Follow these links below for details on your specific language: | Language | Guide | | --- | --- | | Java | [Java example](https://github.com/grpc/grpc-java/tree/master/examples/example-reflection) | | Go | [Go example](https://github.com/grpc/grpc-go/tree/master/examples/features/reflection) | | C++ | [C++ example](https://github.com/grpc/grpc/tree/master/examples/cpp/reflection) | | Python | [Python example](https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_server_with_reflection.py) | | Javascript | [Javascript example](https://github.com/grpc/grpc-node/blob/master/examples/reflection/server.js) | ### Tips Reflection works so seamlessly with tools such as `grpcurl` that oftentimes, people aren’t even aware that it’s happening under the hood. However, if reflection isn’t exposed, things won’t work seamlessly at all. Instead, the client will fail with nasty errors. People often run into this when writing the routing configuration for a gRPC service. The *reflection* service must be routed to the appropriate backend as well as the application’s main RPC service. If your gRPC API is accessible to public users, you may *not* want to expose the reflection service, as you may consider this a security issue. Ultimately, you will need to make a call here that strikes the best balance between security and ease-of-use for you and your users. Last modified May 11, 2026: [Fix grammar in reflection documentation (#1500) (ae642d5)](https://github.com/grpc/grpc.io/commit/ae642d514f797b0f0a616bb126955114ca2046b1) [View page source](https://github.com/grpc/grpc.io/tree/main/content/en/docs/guides/reflection.md) [Edit this page](https://github.com/grpc/grpc.io/edit/main/content/en/docs/guides/reflection.md) [Create child page](https://github.com/grpc/grpc.io/new/main/content/en/docs/guides/reflection.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A) [Create documentation issue](https://github.com/grpc/grpc.io/issues/new?title=Reflection) [Create project issue](https://github.com/grpc/grpc.io/issues/new)