Detailed Notes
This video gives a quick introduction into using Postman to connect to an API and how it can help with testing and development. Check out the product at https://www.postman.com/downloads/ to get started.
You can find out more through our online classes at https://school.develpreneur.com and register for free. Registration will add you to our email list and you will periodically receive coupons for courses as well as notifications of the latest releases.
Transcript Text
foreign [Music] well welcome back we are continuing going through some questions and answers and right now we're in the middle of an application where we're doing a URL shortener and we have gotten an API put together but we're looking at testing an API and really what we're going to focus on this time is what's a great way to test an API call and the answer is actually going to be Postman so we're going to talk about how do I download Postman so we're gonna go out here and let's just do download Postman so you can see it I can get started for free they do have some paid stuff but it's basically if you look at it it's around you get a basic you can actually get to team up the free version uh is just basically go sign up and you're ready to go which is what you're going to see here there's some other stuff you can do but if you go back uh here whoops I guess it went all the way back uh we're gonna come in here you can download uh it's going to tell you whatever you are so for mine I've got a Mac it's going to say hey download it I'm not going to worry about that right now because I've already downloaded it and I have it firing so what I have is I have my API running and I'm going to come oops that's not the one I wanted here we go and so this is what Postman looks like when you run you're going to have uh it's gonna probably come up like this the first time is talk about your workspace and basically what you're going to do is you're going to come in and you're going to have a series of you're going to create a new one is you're going to create a call and if you remember what we were working on last time is we had this curl thing we were calling and we're calling this sort of complex URL now we can take that and we can actually run it right here and we can run it with an HTTP or not and if we send it boom this is this is the results that we get down here that's a pretty version here's the raw version uh not a whole lot and there's a lot you can do but if you see the nice thing about this is when we went and pasted our curl call in it said here's what the query is but also here's the parameter so I could come in here and I could change parameters you'll see it changing up at the top if I do that send it I can result back and this is a get if I change that to a post not implemented yet so it's real easy to wheel and deal our way through calls so this is a postman it's an awesome way to do that now if you wanted to do a so this is our get let's do something a little more complicated because we're working on as we're working on our API calls so let's do a post and actually put some data into it so we're going to create a new one here and we're going to just paste our little thing again by the way the nice thing is based on this if I wanted to see what the curl call is boom that's what the curl call is I can see that exact same thing but I could also do it if I wanted to see like uh using it in PHP or if I want to see my code in Python uh let's do requests so I could write this little script that is going to do the exact same call and it's it's copy and paste so if I come in here and I'm going to create a new file and I'm just going to call it test Dot py go paste that look it's and you notice here it's hard coded so now if I come over here and put that into shorty and then I do python three what did I call it test boom I just made that call in that's how fast and that's the one of the big values of Postman is you can come in and you can do a lot of work with your API and then if you want to come back and say how did I how would I do that in whatever language you know what if how would I do that in using a wget how would I do that using Ruby and it gives you a lot I want to do an HTTP boom so python python Postman is a very powerful tool when we want to start working on our API now what we had before we did a git and a post so I'm gonna have two different calls I'm going to work from so if you remember I do my post and it's not implemented so let's flip back over to are actual well uh API now what we want to do is we're going to do something with our post now one of the things we want to do is we want to try to get the values that come out of it so let's do we're going to do it most simply like this is we're going to look at the request itself so now oh and we need to do it here and oh and it's going to return it so now if we run it and we do our post then that's basically what it gets us now let's go into our body and let's add form data and we're going to add a because it's going to go back and look at our let's go look at our uh shorty shorty needs when we do give me a URL then all it needs is the actual URL so we're just going to do it from the create we're gonna say same thing so we're going to do URL and let's do uh let's just pick one so let's try this thing this is going to be this big long thing and now if we send it and we're posting that and then it's not really giving us much out of that but what we do want is we want to be able to get the body out of that now if we go back to our flash stuff is we do have a form that we can work with you can send like a see like apis with Json and so you can come in here and I think you need a oh you may not need a Json so I may be able to do two Json so let's change that let's go here and let's go to our API let's close oh cancel this let's see if I just do to underscore Json I don't think it's that simple I think it doesn't recognize it but we're going to find out in a second uh whatever it does there so now let's look at our two before we got this oh because that was off of the get there we go that's the pretty here's the Raw oh because we did something we didn't get ah there you go so the return value oh do this I want to save that up here come back over here now let's see if that works boom okay so we got Raw didn't really do a whole lot with this but we're gonna do that anyways if we run this there we go there we go okay so let's go back over to here one of the things we wanted to do is over here we want to post so we have that oh it is it's form okay too many things and if we do that there we go uh mutable dictionary or multiple dictionary so now we have a URL so now uh if we do just reform uh form I think we can do it this way because we did it lowercase to come in here boom we've got that so now what we can do is we can take if we do import ant shorty except for what I'm going to do is we're going to do shortener [Music] so let's try that I'm going to sort of hook this together so from shorty import I could shorter yeah shortener and then here short let's do s it called shortener actually let's look at it here I'll just do it right here uh where we did yeah oh so well that's what we did before so then we're gonna do foreign take that short to nourish if I do that right so you got that so I'm going to do this um I'm gonna probably take the URL itself and then return value equals did we I think we hit oh it's gonna be new URL equals that we're going to do your new URL is going to be post new URL and let's see what that does whoop oh we can't do that because now that does this thing we don't want that this needs to be cleaned up because now when we import it it tries to run it we don't want to do that so now now if it runs and we post your new URL is going to be short and it's going to be a zero because I think we didn't hook it up anything did we um shorty oh yeah it just worked off the counter but if we do it again I think it's going to give us another one oh no because it's within uh it's within the um the class itself and we're not keeping it up at a higher level so it's gonna just every time it's going to generate this which is fine by us uh here you would keep that same class what you'd have to do with the API is you'd have to actually do it if we do it like this and we have S is our shortener and then we break it here let's go back and run it then I think now what we will see is if we send it to see one two again three so now we're keeping that shortener there which is probably what we'd want to do anyways but we have now put this together and we have a real cool way to easily grab that stuff if we come in here uh our get then of course we've got that we can test that at any time if we wanted to do something with it we could take uh same shorty and we're gonna do what was that navigate uh uh yeah so we're gonna do navigate it's just gonna look like this it's gonna be s.navigate whatever our URL is and so suddenly we're going to have something let's look at so that's a post if it's a get then what I want to do is probably do that so that's what you sent and then oh that's still going to be result because result is going to be equal to this so now let's see let's pull this up now this will only run as long as we're going so what we'll do is if we come in here and we post this big long thing so that means if we send it zero that's our new that's our new URL so if we send that back in from a get we should get this nasty thing and uh so this is our value change that over if we do a get boom we have a working API and this is a great way you can go back and forth and very easily do your testing you can change up your uh let's see where'd that go if I go here to my post and I can even save the name I mean this I don't want to get too crazy on this but if I come in here oh wait is that what I want uh uh where oh it doesn't want me to comment mode okay there's a way to do this I forget how anyways oh maybe it's if I save there we go so I'm going to save this is going to be a shorty get and I don't really need anything so there oh I didn't really want to put that there but okay um well we'll do that anyways that's oh this actually needs to be a shorty post and then I can go here and we save that and it's going to be sure to get new folder let's do Shorty save so now here and I think I can just take that and put that there so there we go so I have this this is a nice way that I can work from this I can have a get a post we can do some other stuff that we want to do with it but that's some basic things you can jump into with Postman and I would say that counts us as whoop that counts us as far as being able to test an API call and where do we download Postman and so we're going to play around with some of this other stuff we have actually answered a few other questions along the way but that's okay we're going to continue to look at a few of these as we go so that being said let you get back to your day hope you have a good one and we will talk to you next time thank you hello this is Rob with developmentor also known as building better developers wanted to announce that we have school.developmentor.com feel free to check it out if you like any of this information any of the content that we've sent and you would like to see more you can come out you can enroll for free we have free courses we've got places for you to get better at just learning a technology our how to's you can work on your business skills we can help you with becoming a better developer as in coding and things like that a lot of the stuff you've seen on YouTube we also have out at school.developmentor we just have it a little more of a educational format and a way for you to track your progress as you move forward becoming a better developer
Transcript Segments
foreign
[Music]
well welcome back we are continuing
going through some questions and answers
and right now we're in the middle of an
application where we're doing a URL
shortener and we have gotten an API put
together but we're looking at testing an
API and really what we're going to focus
on this time is what's a great way to
test an API call and the answer is
actually going to be Postman so we're
going to talk about how do I download
Postman
so we're gonna go out here and let's
just do download
Postman
so you can see it
I can get started for free they do have
some paid stuff but it's basically if
you look at it it's around you get a
basic you can actually get to team up
the free version
uh is just basically go sign up and
you're ready to go which is what you're
going to see here there's some other
stuff you can do but if you go back uh
here whoops I guess it went all the way
back
uh we're gonna come in here you can
download uh it's going to tell you
whatever you are so for mine I've got a
Mac it's going to say hey download it
I'm not going to worry about that right
now because I've already downloaded it
and I have it firing so what I have is I
have my API running
and I'm going to come oops that's not
the one I wanted
here we go
and so this is what Postman looks like
when you run you're going to have
uh it's gonna probably come up like this
the first time is talk about your
workspace
and basically what you're going to do is
you're going to come in and you're going
to have a series of you're going to
create a new one is you're going to
create a call
and if you remember what we were working
on last time is we had this curl thing
we were calling and we're calling this
sort of complex URL now we can take that
and we can actually run it right here
and we can run it with an HTTP or not
and if we send it boom this is this is
the results that we get down here that's
a pretty version here's the raw version
uh not a whole lot and there's a lot you
can do but if you see
the nice thing about this
is when we went and pasted our curl call
in it said here's what the query is but
also here's the parameter so I could
come in here and I could change
parameters you'll see it changing up at
the top if I do that send it
I can result back and this is a get if I
change that to a post
not implemented yet
so it's real easy to wheel and deal our
way through calls so this is a postman
it's an awesome way to do that now if
you wanted to do a so this is our get
let's do something a little more
complicated because we're working on as
we're working on our API calls so let's
do a post
and actually put some data into it so
we're going to create a new one here
and we're going to just paste our little
thing again by the way
the nice thing is based on this if I
wanted to see what the curl call is boom
that's what the curl call is I can see
that exact same thing but I could also
do it if I wanted to see like uh using
it in PHP
or if I want to see my code in Python
uh let's do requests so I could write
this little script that is going to do
the exact same call and it's it's copy
and paste so if I come in here
and I'm going to create
a new file and I'm just going to call it
test
Dot py
go paste that
look it's and you notice here it's hard
coded so now if I come over here
and put that into shorty and then I do
python three what did I call it test
boom
I just made that call in that's how fast
and that's the one of the big values of
Postman is you can come in and you can
do a lot of work with your API and then
if you want to come back and say how did
I how would I do that in whatever
language you know what if how would I do
that in using a wget how would I do that
using Ruby
and it gives you a lot I want to do an
HTTP boom so
python python Postman
is a very powerful tool
when we want to start working on our API
now what we had before we did a git and
a post so I'm gonna have two different
calls I'm going to work from so if you
remember I do my post and it's not
implemented so let's flip back over to
are actual well uh API now what we want
to do is we're going to do something
with our post now one of the things we
want to do is we want to try to get the
values that come out of it so let's do
we're going to do it most simply like
this is we're going to look at the
request itself
so now
oh and we need to do it here
and oh and it's going to return it so
now if we run it and we do our post
then
that's basically what it gets us now
let's go into our body and let's add
form data
and we're going to add a because it's
going to go back and look at our let's
go look at our
uh shorty
shorty needs
when we do give me a URL then all it
needs is
the actual URL
so we're just going to do it from the
create
we're gonna say same thing so we're
going to do URL
and let's do
uh let's just pick one so let's try
this thing
this is going to be this big long thing
and now if we send it and we're posting
that
and then it's not really giving us much
out of that but what we do want is we
want to be able to get the body out of
that now if we go back to our flash
stuff
is we do have
a form that we can work with
you can send like a see like apis with
Json
and so you can come in here and I think
you need a oh you may not need a Json
so I may be able to do two Json so let's
change that
let's go here
and let's go to our API let's close oh
cancel this let's see if I just do
to underscore Json I don't think it's
that simple I think it doesn't recognize
it but we're going to find out in a
second uh whatever it does there
so now
let's look at our two
before we got this oh
because that was off of the get
there we go that's the pretty here's the
Raw
oh because we did something we didn't
get
ah there you go so
the return value
oh do this I want to save that
up here
come back over here now let's see if
that works boom okay so we got Raw
didn't really do a whole lot with this
but we're gonna do that anyways if we
run this
there we go there we go okay so let's go
back over to here one of the things we
wanted to do is over here
we want to post
so we have that oh it is it's form okay
too many things and if we do that there
we go uh mutable dictionary or multiple
dictionary so now we have a URL so now
uh if we do just reform uh form
I think we can do it this way because we
did it lowercase
to come in here
boom we've got that so now
what we can do
is we can take
if we do
import
ant shorty
except for what I'm going to do is we're
going to do shortener
[Music]
so let's try that
I'm going to sort of hook this together
so
from shorty
import
I could shorter yeah shortener
and then here
short let's do s
it called shortener
actually let's look at it here I'll just
do it right here
uh where we did yeah
oh so well that's what we did before so
then we're gonna do
foreign
take that short to nourish if I do that
right so you got that so I'm going to do
this
um
I'm gonna probably take the URL itself
and then return value equals
did we I think we hit oh
it's gonna be new URL
equals that
we're going to do your
new URL
is going to be post new URL
and let's see what that does
whoop
oh
we can't do that because now that does
this thing we don't want that
this needs to be cleaned up because now
when we import it it tries to run it we
don't want to do that
so now
now if it runs
and we post
your new URL is going to be short and
it's going to be a zero because I think
we didn't hook it up anything did we
um shorty oh yeah it just worked off the
counter but if we do it again
I think it's going to give us another
one
oh no because it's within
uh it's within the um
the class itself and we're not keeping
it up at a higher level so it's gonna
just every time it's going to generate
this which is fine by us uh here you
would keep that same class what you'd
have to do with the API is you'd have to
actually do it if we do it like this
and we have S is our shortener
and then we break it here let's go back
and run it
then I think now what we will see is if
we send it
to see one two again three so now we're
keeping that shortener there which is
probably what we'd want to do anyways
but we have now put this together
and we have a real cool way to easily
grab that stuff if we come in here
uh our get
then of course we've got that we can
test that at any time if we wanted to do
something with it we could take
uh same shorty and we're gonna do what
was that navigate
uh uh yeah so we're gonna do navigate
it's just gonna look like this it's
gonna be s.navigate whatever our URL is
and so suddenly we're going to have
something let's look at so that's a post
if it's a get
then what I want to do is
probably do that
so that's what you sent and then
oh that's still going to be result
because result
is going to be equal to this
so now
let's see let's pull this up now this
will only run as long as we're going so
what we'll do is if we come in here
and we post
this big long thing
so that means if we send it zero
that's our new that's our new URL so if
we send that back in from a get we
should get this nasty thing
and uh so this is our value
change that over
if we do a get
boom
we have a working API and this is a
great way you can go back and forth and
very easily do your testing you can
change up your uh let's see where'd that
go if I go here to my post
and I can even save the name I mean this
I don't want to get too crazy on this
but if I come in here
oh wait is that what I want uh
uh where oh
it doesn't want me to
comment mode okay
there's a way to do this
I forget how anyways oh maybe it's if I
save there we go
so I'm going to save this is going to be
a
shorty get
and I don't really need anything so
there
oh I didn't really want to put that
there but okay
um
well we'll do that anyways that's oh
this actually needs to be
a shorty post
and then
I can go here and we save that and it's
going to be
sure to get
new folder let's do Shorty
save
so now here and I think I can just take
that and put that there so there we go
so I have this this is a nice way that I
can work from this I can have a get a
post we can do some other stuff that we
want to do with it but that's some basic
things you can jump into with Postman
and I would say that counts us as whoop
that counts us as far as
being able to test an API call and where
do we download Postman
and so we're going to play around with
some of this other stuff we have
actually answered a few other questions
along the way but
that's okay we're going to continue to
look at a few of these as we go so that
being said let you get back to your day
hope you have a good one and we will
talk to you next time
thank you
hello this is Rob with developmentor
also known as building better developers
wanted to announce that we have
school.developmentor.com feel free to
check it out if you like any of this
information any of the content that
we've sent and you would like to see
more you can come out you can enroll for
free we have free courses we've got
places for you to get better at just
learning a technology our how to's you
can work on your business skills we can
help you with becoming a better
developer as in coding and things like
that a lot of the stuff you've seen on
YouTube we also have out at
school.developmentor we just have it a
little more of a educational format and
a way for you to track your progress as
you move forward becoming a better
developer