grpcurl curl for gRPC

Version 1.9.4 · source

Start here

grpcurl -plaintext <host:port> list
List services
grpcurl -plaintext <host:port> list <service>
List methods
grpcurl -plaintext <host:port> describe <symbol>
Show a schema
grpcurl -plaintext <host:port> <service>/<method>
Call, empty body
grpcurl -plaintext -d '<json>' <host:port> <service>/<method>
Call with data
grpcurl -H '<name>: <value>' ...
Add metadata
grpcurl -proto <file> ...
No reflection
grpcurl -v ...
Show headers

Concepts

  1. grpcurl flags + JSON
  2. gRPC server host:port
  3. Reflection or -proto / -protoset

Discover

grpcurl <host:port> list
List services via reflection
grpcurl <host:port> list <service>
List a service's methods
grpcurl <host:port> describe
Describe every service
grpcurl <host:port> describe <service>
Describe a service
grpcurl <host:port> describe <service>.<method>
Describe one method
grpcurl <host:port> describe <message>
Describe a message type
grpcurl -msg-template <host:port> describe <message>
Show a JSON template for a message
grpcurl -protoset <file> list
List from a descriptor set
grpcurl -import-path <dir> -proto <file> list
List from a .proto file

Call

grpcurl <host:port> <service>/<method>
Call with an empty request
grpcurl -d '<json>' <host:port> <service>/<method>
Call with a JSON body
grpcurl -d @ <host:port> <service>/<method>
Read the body from stdin
Streams: send several JSON objects on stdin, one per request message.
grpcurl -format text -d '<text>' <host:port> <service>/<method>
Use protobuf text format
grpcurl -emit-defaults ...
Print zero-valued fields
grpcurl -allow-unknown-fields ...
Ignore unknown request fields
grpcurl -max-time <secs> ...
Limit total time
grpcurl -connect-timeout <secs> ...
Limit connect time
grpcurl -max-msg-sz <bytes> ...
Raise response size limit
grpcurl -format-error ...
Format error details as the response
grpcurl -version
Print the version

Connection and TLS

grpcurl -plaintext <host:port> ...
Connect without TLS
grpcurl -insecure <host:port> ...
Skip server cert verification
grpcurl -cacert <file> <host:port> ...
Trust a custom CA
grpcurl -cert <file> -key <file> <host:port> ...
Present a client certificate (mTLS)
grpcurl -authority <name> ...
Set :authority and TLS name
grpcurl -servername <name> ...
Override the TLS server name
grpcurl -keepalive-time <secs> ...
Send keepalive probes when idle
grpcurl -user-agent <value> ...
Add to the User-Agent

Metadata

grpcurl -H '<name>: <value>' ...
Send a header (repeatable)
grpcurl -rpc-header '<name>: <value>' ...
Header for the call only
grpcurl -reflect-header '<name>: <value>' ...
Header for reflection only
grpcurl -expand-headers -H 'authorization: Bearer ${TOKEN}' ...
Expand env vars in headers
grpcurl -v ...
Show headers, trailers and details
grpcurl -vv ...
Also show timing data

Schema sources

grpcurl -proto <file> -import-path <dir> ...
Use .proto source (repeatable)
grpcurl -protoset <file> ...
Use a compiled descriptor set
grpcurl -use-reflection=false ...
Force no reflection
grpcurl -protoset-out <file> <host:port> describe <service>
Save a descriptor set
grpcurl -proto-out-dir <dir> <host:port> describe <service>
Write .proto files
protoc --descriptor_set_out=<file> --include_imports <proto>
Build a protoset with protoc

Recipes

Explore an unknown plaintext server
grpcurl -plaintext localhost:50051 listgrpcurl -plaintext localhost:50051 list my.pkg.Greetergrpcurl -plaintext localhost:50051 describe my.pkg.HelloRequest
Authenticated call over TLS
grpcurl -H "authorization: Bearer $TOKEN" \  -d '{"name":"world"}' \  api.example.com:443 my.pkg.Greeter/SayHello
Pipe a response through jq
grpcurl -plaintext -d '{"id":1}' localhost:50051 \  my.pkg.Items/Get | jq '.name'
Call from a local .proto with a JSON file
grpcurl -import-path ./protos -proto items.proto \  -d @ localhost:50051 my.pkg.Items/Create < req.json