We've seen how Postman helps with
testing of APIs, but Postman also
provides its own API that we can use.
We've been learning a lot about APIs,
and if we want to we can use that
knowledge to run Postman itself through
an API. So we might want to do this if we
want to integrate Postman into existing
build processes, or if we want to share
data with some other tools that were
using. So the first thing that we'll need
to do is get an API key, this will allow
us to access the API. So I've logged into
the web Postman Co here, I'll go to my
workspace and integrations,
and we'll go to the Postman API here, the
Postman API integration, and then click
on get an API key. So it's created this
API key for us, and I'll just copy this
so that we have it available for use
later. And now at this point we'll get I
guess a little meta, and we'll use
Postman itself to call the Postman API.
So let's go over to Postman and let's
create a collection here, we'll call it
Postman API, create that, and for the
Postman API we'll put a request in there,
and let's call this get collections, save
that. And then let's go open that request,
and here we can put in the URL to the
Postman API. So API dot, in this case
we'll say get Postman comm slash
collections. And now we can't quite send
this yet, we need to authorize it, so we
need to let Postman know that we are who
we say we are, and we can do that by
passing this header to it, so X API key.
And this header is in the documentation
it tells you that this is what you need
to do to authenticate the API. And we'll
paste in our API key, and then we can
send that request off and get back a
list of all the collections that we have
in Postman. Now you wouldn't really want
to do this obviously and Postman
itself because you already have that
data, but if you were calling this from
another tool that might be helpful for
you. There are also a number of other
endpoints available in the Postman API
documentation, you can see here's the
collection one, and there's whole number
of other endpoints that are available in
the documentation, you can read through
that and see if there's any that you
need or that are useful for you there. So
that covers the Postman API and at least
get you started with it, it's the same as
a lot of the other APIs that we've been
talking about along the way, so you
should be able to pretty easily figure
out how to use the particular commands
that you want from there. In the next
section we'll be looking at how we can
use Postman for data driven testing, see
you there.