We can see what the response data looks like, and understand the structure of requests & responses.īut what about when we want to iterate through a number of users and pull only a specific few statistics? Or maybe we need a way to take a list of user information, and automatically upload or convert that data into another system.įor use cases like that, we'll jump over to Python. We're able to quickly & visually test out an API call.
If we needed to find a user's phone number, this could be an easy way to quickly filter our data & get to what we need. So as we can see above - now our JSON response only contains the data for a single user. We would append ?username=Delphine to our URL: Let's say we want to find information for a user named Delphine.
What if we only wanted to get data for one specific user? Well, our test API site supports using query parameters to filter our response. The mock data offered by this API provides us with a list of 10 different users, along with the data that's been entered for each user. I already sent the GET request, so in the screenshot you'll also notice that we have our JSON response from the API. Next, we just click the big Send button on the right side. In the screenshot above, you'll see in the highlighted box that we entered our URL. We'll use the users endpoint offered by JSON Placeholder, which is located at: In order to create our first request, we'll just need to enter our API endpoint URL. If we expand the request type dropdown, we'll see a handful of options - but we'll only be using a GET request for now: What we'll need to pay attention to first, is what type of HTTP request we're sending - as well as the URL we want to send our request to. Let's go ahead and start up Postman, and we'll see a blank workspace: We'll accomplish this using a free website called JSON Placeholder. In this example, we'll keep things simple & use a non-authenticated API endpoint. So first, let's start off with an example of using Postman for a simple GET request. Therefore, it should not be used in a production network.
#POSTMAN DOWNLOAD IMAGE CODE#
Note: Much of the code below is minimal and does not contain any error handling. If you don't have Postman yet, go ahead and snag the download here. This isn't going to be a complete run-down of all the capabilities of both tools - but rather a few examples of simple GET requests using both methods.
#POSTMAN DOWNLOAD IMAGE HOW TO#
So the purpose of this post is to explore how to get beyond just Postman, and into using Python for REST API calls. In this particular example - learning Python allows you to move beyond one-off API calls in Postman, and into being able to accomplish much more complex automation.
#POSTMAN DOWNLOAD IMAGE FULL#
Network automation isn't usually accomplished with just one tool - it's a whole storage closet full of different tools & utilities, each with their own use cases or specializations. I've seen some engineers who hear these statements and feel like Postman is being pushed on them - even when they're perfectly happy with an SSH-based CLI. We might mention Python as an advanced method of using our APIs, or maybe we talk about how "if APIs are the new CLI, Postman is the new PuTTY".
That being said, often times I've seen that we stop there. Postman is a very easy to use platform for running API calls against REST endpoints & see the nicely formatted output. Maybe it's just me - but I feel like when we want to demonstrate product APIs to someone, we usually jump into Postman first.