APIs often get used by developers to pull data into their website, app, display it or manipulate it – but did you know that we, as marketers, can use this data as well?
If we only find a way to get to it.
In this post, we’re going to show you how you can use API data with the Postman App – without having to learn a new language, getting used to a complicated UI or a new workflow…
I’m gonna show you how you can pull data from an API with the help of Postman App.
What is an API?
Now data is everywhere, but how do you get to it? Well, most of the times, you will go through an API.
Now, APIs have been used by developers quite often to pull data into the app or the website, display it, manipulate it, or change it around in the third party system.
But, we as marketers can actually also use that data, if you just know how to get to it. Now, before you start building an app, try to retrieve that data and mesh it around and maybe send it back into your analytics system, why not try to get the request right first?
What is Postman App?
And this is where Postman App comes in. With it, you can actually test APIs, and without coding, can send in a request with the right parameters and see what data you get back.
Highly useful for us marketers because we can then instruct our developer to pull the right data or help us to build an app to actually take that data and send it onto a marketing script or a marketing tool like Google analytics.
So, today I want to show you how you can use Postman app to retrieve data from an API, send your first request, and also manipulate data in a third party system.
How to Use Postman App to Retrieve Data from an API
Alright, today our journey starts at getpostman.com where you can download the Postman app, previously it was also available just to download it as a Chrome app, but that’s been depreciated, but here you can download it for your Mac, your Windows, or Linux machine.
And once you install it, it should look something like this. Now, the tool in its basis is a free tool, which we can use as marketers just to see APIs, but if you want to take advantage of more of the advanced features, there’s also a pro version and enterprise version. Now, this tool is most often used to develop and test APIs.
It is actually like the Query Explorer for the Google Analytics Core Reporting API. You login here, then you can try out the API, mix and match certain metrics for example, and pull that data directly from the API, get the output right here.
Now, if you actually wanted to integrate this into your app and have the right parameters that you send into the API to get a response, you would probably test this with something like Postman beforehand.
So let’s get started with our first request.
Get JSON Response
Here is an API that gives me some Chuck Norris quotes, and it specifies that I just simply simply need to send a get response to this endpoint, this URL to get my random quote.
So, let’s try this out, let’s copy this URL, go over to Postman, and put in our URL right here, and then we have our different methods of sending that data. We want to go with the get response.
So, pretty easy. In this sense, Postman is almost like a browser. You put in your URL, send it off and get a response. Now, if you do any kind of mistake, so let’s add something to the end here and send it, we see that the status is a 500 internal error. We get a message from the API back.
That’s not always the case, but it helps us debug and maybe find something that we did wrong. Now, this is a very, very easy API, but we can just send in our URL and get a response back. In most cases, it’s it a bit advanced than that.
Get Data from a Weather API
Let’s go to another example, so here we have the weather API, the OpenWeatherMap, and we can actually get a current weather status for a city.
Now, what do we have to do? We have to send in as a query string here in our URL the actual location. So, let’s try this out. Let’s take our API call here and put it into place. Now we have a query string, this is key of Q and the value of the city name, in our case Berlin.
By the way, if you don’t want to type that out in the URL itself, you could also at any time click this Params here at the end and type in the right key. and the value will be added automatically to your request.
Then we can send this off and we get a negative response here of 401, saying that this is an invalid API key. Apparently, we need an API key to get the data from this API, and this is actually something that is required quite often with not as open APIs as the Chuck Norris API.
So, we actually need to sign up to get our API key right here, so let’s copy that, and we actually need to send it in somehow, so let’s see how to do that. We can look up this in our documentation here, and we just need to attach another query parameter, which is the app ID with our API key, so let’s do that. Let’s go back and put in app ID, and then here our API key.
Send this all off, and this time we get a response that right now in Berlin, there are clouds and descriptions, broken clouds. So, quite interesting to see the response data and what data we can actually get out and maybe test that and send it onto a tracking script that sends the data over to Google Analytics, so we would have the data in there, what weather it was at the location of our user, who just visited our website or bought our product.
So far, so good, but we can not only get data from API, but also affect a change in the application itself, and this is done through other requests such as the post request, so let’s take a look at an example of that.
Post Data into the Application Using API, Mailchimp Example
Here we are in our MailChimp account, and MailChimp also has an API, so if we scroll down, we can see here the API docs. I actually need to log in first into my demo account here, and we can look into the API references and see what we would need to make this actually happen. First of all, this would be our URL, so I’m gonna copy that over. We actually need to make sure that we have our data center changed here, in our case, that would be US8. And then we need to authorize our app ID probably.
The authentication this time happens through HTTP basic, so let’s go over to our MailChimp account and look into our account options here under extras, we can get our API key, and here we have our API key that we copy and do some special authorizations, so the basic authorization and the user name in the case of MailChimp can be anything. I’m just gonna put “anything” and the password, our API key.
That is something we want to request with our data, and now it’s been added to the header of our request and we should be able to send over request already. Here, we get our account information back. Now we can look into the developer reference and see how we can, for example, add a user to a list, so let’s go over to list here, and let’s say we wanted to create a new member of that list. What we would need to have is the list ID, and then we can create any member. What do we have to send in? The email address, the status at least. Okay, let’s do that. First of all, let’s find out, what is our list ID?
I need an email address, comma, and then we need the status. Alright, so what do we need to fill out here? The email address is obviously a string, and then the status would be also a string. The possible values would be subscribe, unsubscribe, clean, and so on. So, we’ll go with subscribe.
So, let’s fill that out. And that should be it. Let’s send that data over. And we get a response back that our user was edit. He should be now in the system, so let’s see if this is actually the case.
Let’s go back into our list, and click on here, and look through our requests, and here we go, our new user was added to the system. So, you can not only look for data or get a response from an API, but also post that data into the system.
Now, there’s much more that we can cover right now in this video, different authorizations for example, the OAuth method, which is used quite often for authorization. There are different ways of sending data in, by the header or the body.
There are different methods of sending a request as well, and I hope this gave you a little bit of an idea of how you can use Postman to get a response back, to test APIs, see how they function, what parameters you need to send in, in order to get a correct response back and see how they behave in certain circumstances.
Alright, so there you have it. This is how you can retrieve and send data into an API and get a response back. Now, there’s much more to APIs, but also to Postman, so check out MeasureMasters, where we actually go more into detail on different requests you can send in, different, more examples on APIs, and much more, so check that out at techmarketer.it/postman.