Set the addresses of a gRPC API. A .proto file has no place for them: it describes services, methods, and messages, but not where the API runs.
The overview page of the API reference lists the servers in a Servers panel. The request panel of each method shows the servers in a dropdown next to the method name, as it does for OpenAPI operations. The code samples (grpcurl, Node.js, Python, and Go) connect to the picked server. The picked server stays selected across the pages of the API.
Without servers, the overview page has no Servers panel, and the code samples connect to localhost:50051 without TLS.
Add the servers list to the grpc configuration of an API:
apis:
cafe:
root: ./apis/cafe/cafe.proto
grpc:
servers:
- url: grpcs://grpc.cafe.example.com:443
description: Production
- url: grpc://localhost:50051
description: Local
| Option | Type | Description |
|---|---|---|
| servers | [Server object] | List of servers for the Servers panel and the code samples. A list in an API entry replaces the list under the root grpc key. |
| Option | Type | Description |
|---|---|---|
| url | string | REQUIRED. Host and port of the server, with an optional scheme that sets the connection type. The port is required: grpcs:// for a TLS connection, grpc:// or no scheme for a plaintext connection. For example, grpcs://grpc.example.com:443 or localhost:50051. The Servers panel and the dropdown show a URL without a scheme as grpc://host:port. Other schemes and paths are not allowed. |
| description | string | Name of the server in the Servers panel and in the dropdown. Without a description, both show only the URL. |
The following example adds a production and a sandbox server to every gRPC API in the project:
grpc:
servers:
- url: grpcs://grpc.example.com:443
description: Production
- url: grpcs://sandbox.example.com:443
description: Sandbox
The following example sets a local server that the samples connect to without TLS. The grpcurl sample passes -plaintext, and the other samples open an insecure channel:
apis:
cafe:
root: ./apis/cafe/cafe.proto
grpc:
servers:
- url: grpc://localhost:50051
description: Local
- gRPC - Official gRPC documentation
- info - Set the title, version, and description of a gRPC API
- Configuration options - All the other options for your project