Using Postman for API testing

Postman is a service that helps developers test APIs before going live. There are a multitude of use cases for which it is helpful. I’ll highlight a few examples — I do not work for them, by the way — where it is a valuable resource for developers.

So you want your app to connect to an external API and receive data? Perhaps, you would like your users to be able to play back their favorite YouTube content. Ok, well, after registering your project and getting an API key from Google, it’s good to make sure that key works the way you think it does.

My weekly reminder to hide your API keys: Hide your API keys, please.

Before going through the process of securing your application, setting up environment variables, and making sure gitignore knows to prevent your .env file (and its secret contents) from appearing on GitHub, and before creating an interface for users to search for content, you can make a sample request to Postman to simply verify that your key works and a search successfully completes.

Postman allows you to make REST, SOAP, and http requests.

For the purposes of our discussion, it will be useful to make a GET request to the YouTube Data API. If all goes well with your key, you now have a working example of how your request should function and how the authorization headers will operate.

It is highly unlikely Google would send a non-working key, but it’s a good exercise in understanding authorization headers, perhaps for when you aren’t working with one of the world’s largest companies.

Another GET request test could verify the functionality of your Sign In process. You could, for example, go to localhost:3000/signin and see the responses you get both with and without authentication headers. Essentially, you can test your login methods prior to styling a UI. Before you have the sleek login page, you know the login functionality works on the server side.

In addition to your standard GET request, Postman allows you to make PATCH, PUT, POST, and DELETE requests. This means you can test all of your applications’ routes ahead of time.

This is useful to test that you are communicating effectively with your backend. Are you receiving the responses you expect? Are your posts being saved according to your intentions? Make a POST request and see that your data appears as it should in the database. Are the objects organized how you would like, or should you do some redesigning.

These are just a few useful cases for bringing Postman into the development of your next project.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store