Testing gRPC APIs with Postman Appurva Murawat August 10, 2022 Testing an API ensures that it consistently delivers the necessary functionality, performance, reliability, and security you need. It gives you the confidence to develop and ship faster, speeding up discoverability by API consumers. But it can be tedious, inefficient, and, more importantly, unreliable to manually test each time you add a new feature or fix a bug in your APIs. That’s what we’ve worked to solve for Postman’s gRPC support. Postman announced first-class support for gRPC at the beginning of this year and followed it up with loads of improvements based on some truly fantastic feedback we received from our gRPC community on GitHub. And now, with the latest release, we’ve supercharged our gRPC support by adding the capability of writing test specifications for all your use cases. We hope these improvements will make your workflow even more efficient by allowing easier development and testing of your APIs. New yet familiar Postman strives to provide the most straightforward and powerful user interfaces so that you can focus on the actual task without thinking too hard about navigating new territory. We bring this philosophy to the new gRPC testing interface as well. If you have ever used Postman to debug and write tests for your REST APIs, guess what, those are the same concepts you need to know for writing tests for your gRPC requests in Postman. If you’re a newcomer, don’t worry about it, we’ve got you covered: check out the Postman Learning Center to get started. To add a test, open your gRPC request and switch to the Scripts tab. You can use Postman’s robust Javascript-based scripting environment to author test suites. You can add two different scripts: Before invoke: executes before invoking the method and establishing a connection with the server After response: executes once the current transaction is complete (i.e., connection with the server is closed) Navigating to scripts in the gRPC request Once you’ve written the tests (more on that in a moment), you can observe the test assertions summary beside your response(s) under the Test results tab: Invoking a gRPC request with tests Get off the blocks in no time Let’s start by writing our first test, so you can quickly see things in action: Go to the After response script of your gRPC request. From the list of Snippets on the right, choose Status code is 0. Click Invoke. There you have it, your first test! Both before invoke and after response scripts come with pre-curated lists of commonly used code snippets that get added to your scripts when selected, helping you start quickly. Authoring after response script using a snippet Speed and accuracy superpower Snippets are excellent for primary use cases, but as you can imagine, there might be more complex and custom scenarios that you want to test. For that, you can use the complete range of pm.* APIs to craft your scripts. Check out the below tests to get a taste of all the things that you can do: pm.test('Response time is below 200ms', function () { pm.response.to.have.responseTime.below(200); }); pm.test('Correct user details are received', function () { pm.response.to.have.message({ id: "123", name: "John" }); }); You can even validate the messages against a given JSON schema, allowing you to enforce a number of custom rules: const schema = { type: "object", properties: { name: { type: "string", pattern: "^[a-zA-Z0-9_]*$", maxLength: 64 } }, required: ['name'] }; pm.test('All response messages have valid name', function () { pm.response.messages.to.have.jsonSchema(schema); }); As engineers, we understand that it might not always be efficient for you to refer to the documentation—that’s where the autocompletion for Javascript and the pm.* APIs in our script editor comes in, empowering you with all the information you need to author your scripts swiftly and accurately. Hopefully, this saves you some trips to Stack Overflow as well. Autocompletion in action Leave nothing to chance All the features and workflows mentioned above extend to unary, client streaming, server streaming, and bidirectional streaming gRPC methods alike. This makes it easier to have test specifications for all your gRPC APIs in a single place—Postman! More to come The ability to test your gRPC APIs is a powerful addition to the Postman API Platform, and it’s another way we’re working to help users throughout the API lifecycle. And gRPC support continues to evolve. Keep an eye out for more upcoming releases, including: Saving examples for gRPC request Automatic mock servers for all imported Protobuf APIs Automating your gRPC testing workflows using Postman’s Collection Runner Stay tuned to the Postman blog for more updates. Watch and learn Try Postman now In this post Tags: API-First gRPC Product Updates Testing Appurva Murawat Appurva Murawat is a technical lead at Postman. View all posts by Appurva Murawat → What do you think about this feature? Tell us in a comment below. You can also give product feedback through our Community forum and GitHub repository. Comment Cancel replyYour email address will not be published. Required fields are marked *Your name Your email Write a public comment Δ This site uses Akismet to reduce spam. Learn how your comment data is processed. 8 thoughts on “Testing gRPC APIs with Postman” John Long August 15, 2022 Is this supported to run via Newman? If not, is that on the timeline? Appurva Murawat August 17, 2022 Hey John! Newman doesn’t support gRPC yet. You can follow the thread here for further updates on this. stevie August 22, 2022 any timelines on when gRPC can be used with collection runner? Appurva Murawat August 24, 2022 We don’t have an exact timeline, but we have this on our upcoming roadmap, and you should hear some updates on this soon 🙂. Can you also raise a feature request for the same here with your use-case, if possible? Zoltán November 9, 2022 How can I export the grpc requests ‘collection’? Dimple January 5, 2023 Can we run grpc api support collection runner using postman . Dimple jhajhra January 6, 2023 Is grpc support collection runner and execution vis jenkins Marc van 't Veer May 18, 2023 I like to use the runner and performance test option for a gRPC collection, but don’t see that option. Is the runner and performance function not available for gRPC API’s? You might also like Types of APIs: A Complete Guide to API Architectures The Postman Team Quick answer: What are the main types of APIs? The five foundational types of APIs define how systems communicate and exchange data… Read more → Coming to Postman in March: AI-native capabilities, a new API Catalog, and updated plans and pricing The Postman Team Postman is used today by millions of developers, from individuals building APIs for personal projects to teams inside large, global companies scaling… Read more → What is GraphQL and how does it work? The Postman Team What is GraphQL? GraphQL is a query language for APIs that enables clients to interact with a single endpoint to get the… Read more →