📺 Develpreneur YouTube Episode

Video + transcript

How Do I Use PostMan To Test An API?

2023-08-01 •Youtube

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
0.42

foreign

18.89

[Music]

27.42

well welcome back we are continuing

30.9

going through some questions and answers

33.059

and right now we're in the middle of an

35.219

application where we're doing a URL

36.719

shortener and we have gotten an API put

39.6

together but we're looking at testing an

41.46

API and really what we're going to focus

43.079

on this time is what's a great way to

44.94

test an API call and the answer is

47.879

actually going to be Postman so we're

49.32

going to talk about how do I download

50.7

Postman

52.079

so we're gonna go out here and let's

53.64

just do download

55.32

Postman

57.539

so you can see it

59.1

I can get started for free they do have

61.44

some paid stuff but it's basically if

63.6

you look at it it's around you get a

66.42

basic you can actually get to team up

67.92

the free version

70.22

uh is just basically go sign up and

73.799

you're ready to go which is what you're

75.119

going to see here there's some other

77.1

stuff you can do but if you go back uh

79.5

here whoops I guess it went all the way

81.06

back

82.14

uh we're gonna come in here you can

83.82

download uh it's going to tell you

85.32

whatever you are so for mine I've got a

87.299

Mac it's going to say hey download it

88.979

I'm not going to worry about that right

90.36

now because I've already downloaded it

93.54

and I have it firing so what I have is I

96.9

have my API running

99.54

and I'm going to come oops that's not

102

the one I wanted

103.74

here we go

105.18

and so this is what Postman looks like

107.82

when you run you're going to have

111.479

uh it's gonna probably come up like this

113.34

the first time is talk about your

114.6

workspace

116.34

and basically what you're going to do is

118.259

you're going to come in and you're going

119.939

to have a series of you're going to

122.34

create a new one is you're going to

124.079

create a call

125.46

and if you remember what we were working

127.259

on last time is we had this curl thing

130.259

we were calling and we're calling this

132.599

sort of complex URL now we can take that

137.099

and we can actually run it right here

139.739

and we can run it with an HTTP or not

142.56

and if we send it boom this is this is

145.2

the results that we get down here that's

147.06

a pretty version here's the raw version

149.36

uh not a whole lot and there's a lot you

151.739

can do but if you see

154.08

the nice thing about this

156.42

is when we went and pasted our curl call

160.02

in it said here's what the query is but

163.379

also here's the parameter so I could

164.819

come in here and I could change

165.959

parameters you'll see it changing up at

167.76

the top if I do that send it

170.819

I can result back and this is a get if I

173.4

change that to a post

176.04

not implemented yet

178.2

so it's real easy to wheel and deal our

181.62

way through calls so this is a postman

184.56

it's an awesome way to do that now if

187.08

you wanted to do a so this is our get

191.76

let's do something a little more

194.58

complicated because we're working on as

196.86

we're working on our API calls so let's

198.72

do a post

200.22

and actually put some data into it so

202.56

we're going to create a new one here

204.84

and we're going to just paste our little

206.819

thing again by the way

208.8

the nice thing is based on this if I

210.959

wanted to see what the curl call is boom

213.06

that's what the curl call is I can see

215.34

that exact same thing but I could also

217.019

do it if I wanted to see like uh using

220.86

it in PHP

222.54

or if I want to see my code in Python

225.36

uh let's do requests so I could write

228.659

this little script that is going to do

231.9

the exact same call and it's it's copy

234.239

and paste so if I come in here

236.819

and I'm going to create

240.06

a new file and I'm just going to call it

242.4

test

243.959

Dot py

246.36

go paste that

248.28

look it's and you notice here it's hard

250.08

coded so now if I come over here

254.42

and put that into shorty and then I do

257.88

python three what did I call it test

261.78

boom

263.28

I just made that call in that's how fast

265.86

and that's the one of the big values of

268.5

Postman is you can come in and you can

269.94

do a lot of work with your API and then

272.04

if you want to come back and say how did

273.6

I how would I do that in whatever

276

language you know what if how would I do

277.5

that in using a wget how would I do that

280.44

using Ruby

282.24

and it gives you a lot I want to do an

285.18

HTTP boom so

288.3

python python Postman

291.3

is a very powerful tool

293.759

when we want to start working on our API

296.82

now what we had before we did a git and

299.52

a post so I'm gonna have two different

300.6

calls I'm going to work from so if you

302.699

remember I do my post and it's not

304.979

implemented so let's flip back over to

309.12

are actual well uh API now what we want

313.74

to do is we're going to do something

314.759

with our post now one of the things we

317.22

want to do is we want to try to get the

319.82

values that come out of it so let's do

327.18

we're going to do it most simply like

329.1

this is we're going to look at the

330.78

request itself

335.539

so now

337.62

oh and we need to do it here

342.919

and oh and it's going to return it so

345.3

now if we run it and we do our post

348.06

then

349.44

that's basically what it gets us now

351

let's go into our body and let's add

352.94

form data

355.08

and we're going to add a because it's

357.84

going to go back and look at our let's

359.28

go look at our

360.979

uh shorty

363.18

shorty needs

366.479

when we do give me a URL then all it

369.78

needs is

371.82

the actual URL

374.4

so we're just going to do it from the

376.919

create

380.22

we're gonna say same thing so we're

382.199

going to do URL

383.58

and let's do

386.18

uh let's just pick one so let's try

391.139

this thing

394.919

this is going to be this big long thing

399.66

and now if we send it and we're posting

401.94

that

403.94

and then it's not really giving us much

406.5

out of that but what we do want is we

408.479

want to be able to get the body out of

410.639

that now if we go back to our flash

412.56

stuff

414.12

is we do have

417

a form that we can work with

421.62

you can send like a see like apis with

424.86

Json

425.88

and so you can come in here and I think

430.139

you need a oh you may not need a Json

433.139

so I may be able to do two Json so let's

436.08

change that

437.819

let's go here

440.16

and let's go to our API let's close oh

442.74

cancel this let's see if I just do

447.539

to underscore Json I don't think it's

450.06

that simple I think it doesn't recognize

452.039

it but we're going to find out in a

453.06

second uh whatever it does there

456.24

so now

458.16

let's look at our two

459.96

before we got this oh

464.22

because that was off of the get

466.68

there we go that's the pretty here's the

469.02

Raw

470.46

oh because we did something we didn't

472.919

get

475.02

ah there you go so

480.9

the return value

486.72

oh do this I want to save that

491.4

up here

493.259

come back over here now let's see if

495.24

that works boom okay so we got Raw

498.419

didn't really do a whole lot with this

499.979

but we're gonna do that anyways if we

502.5

run this

504.18

there we go there we go okay so let's go

506.879

back over to here one of the things we

508.08

wanted to do is over here

511.5

we want to post

515.399

so we have that oh it is it's form okay

526.74

too many things and if we do that there

529.92

we go uh mutable dictionary or multiple

533.279

dictionary so now we have a URL so now

538.62

uh if we do just reform uh form

542.76

I think we can do it this way because we

544.26

did it lowercase

546.3

to come in here

552.42

boom we've got that so now

555.48

what we can do

557.399

is we can take

559.74

if we do

561.66

import

564.06

ant shorty

570

except for what I'm going to do is we're

571.32

going to do shortener

572.75

[Music]

578.76

so let's try that

580.74

I'm going to sort of hook this together

582.959

so

584.58

from shorty

586.56

import

589.2

I could shorter yeah shortener

592.98

and then here

597.24

short let's do s

599.94

it called shortener

602.399

actually let's look at it here I'll just

604.26

do it right here

605.459

uh where we did yeah

609

oh so well that's what we did before so

610.98

then we're gonna do

614.58

foreign

616.76

take that short to nourish if I do that

620.459

right so you got that so I'm going to do

622.74

this

624.42

um

627.66

I'm gonna probably take the URL itself

633.66

and then return value equals

637.62

did we I think we hit oh

640.74

it's gonna be new URL

643.08

equals that

646.8

we're going to do your

649.38

new URL

652.68

is going to be post new URL

657

and let's see what that does

662.22

whoop

664.2

oh

665.519

we can't do that because now that does

667.8

this thing we don't want that

669.54

this needs to be cleaned up because now

672.36

when we import it it tries to run it we

674.82

don't want to do that

676.98

so now

681.6

now if it runs

684.3

and we post

686.519

your new URL is going to be short and

689.519

it's going to be a zero because I think

691.32

we didn't hook it up anything did we

694.86

um shorty oh yeah it just worked off the

697.14

counter but if we do it again

698.82

I think it's going to give us another

699.959

one

702.06

oh no because it's within

705.24

uh it's within the um

708.12

the class itself and we're not keeping

710.579

it up at a higher level so it's gonna

713.22

just every time it's going to generate

714.779

this which is fine by us uh here you

718.2

would keep that same class what you'd

720.12

have to do with the API is you'd have to

722.519

actually do it if we do it like this

726.24

and we have S is our shortener

730.019

and then we break it here let's go back

733.56

and run it

734.94

then I think now what we will see is if

737.579

we send it

738.839

to see one two again three so now we're

743.7

keeping that shortener there which is

745.26

probably what we'd want to do anyways

747.959

but we have now put this together

750.899

and we have a real cool way to easily

753.18

grab that stuff if we come in here

756.44

uh our get

759.06

then of course we've got that we can

761.1

test that at any time if we wanted to do

763.44

something with it we could take

766.92

uh same shorty and we're gonna do what

769.92

was that navigate

773.24

uh uh yeah so we're gonna do navigate

776.7

it's just gonna look like this it's

778.26

gonna be s.navigate whatever our URL is

783.66

and so suddenly we're going to have

784.98

something let's look at so that's a post

786.36

if it's a get

788.1

then what I want to do is

792.66

probably do that

797.519

so that's what you sent and then

804.42

oh that's still going to be result

805.86

because result

808.62

is going to be equal to this

812.399

so now

814.2

let's see let's pull this up now this

816.899

will only run as long as we're going so

818.339

what we'll do is if we come in here

821.82

and we post

824.279

this big long thing

826.56

so that means if we send it zero

829.68

that's our new that's our new URL so if

832.38

we send that back in from a get we

834.3

should get this nasty thing

838.079

and uh so this is our value

842.399

change that over

843.959

if we do a get

845.94

boom

847.079

we have a working API and this is a

850.74

great way you can go back and forth and

852.66

very easily do your testing you can

855.3

change up your uh let's see where'd that

857.76

go if I go here to my post

860.88

and I can even save the name I mean this

862.62

I don't want to get too crazy on this

864.48

but if I come in here

867.3

oh wait is that what I want uh

872.779

uh where oh

877.98

it doesn't want me to

881.16

comment mode okay

883.26

there's a way to do this

889.44

I forget how anyways oh maybe it's if I

892.079

save there we go

893.639

so I'm going to save this is going to be

896.279

a

898.04

shorty get

903.959

and I don't really need anything so

906.24

there

910.44

oh I didn't really want to put that

912.12

there but okay

914.04

um

917.639

well we'll do that anyways that's oh

921.18

this actually needs to be

923.88

a shorty post

930.72

and then

932.04

I can go here and we save that and it's

935.459

going to be

938.76

sure to get

942.839

new folder let's do Shorty

948.12

save

949.62

so now here and I think I can just take

952.32

that and put that there so there we go

953.699

so I have this this is a nice way that I

955.44

can work from this I can have a get a

957.12

post we can do some other stuff that we

958.92

want to do with it but that's some basic

960.42

things you can jump into with Postman

963.42

and I would say that counts us as whoop

969.24

that counts us as far as

973.32

being able to test an API call and where

976.079

do we download Postman

977.699

and so we're going to play around with

979.38

some of this other stuff we have

981.66

actually answered a few other questions

983.16

along the way but

984.899

that's okay we're going to continue to

987.72

look at a few of these as we go so that

990.18

being said let you get back to your day

991.98

hope you have a good one and we will

993.779

talk to you next time

1006.04

thank you

1012.98

hello this is Rob with developmentor

1015.32

also known as building better developers

1017.42

wanted to announce that we have

1019.779

school.developmentor.com feel free to

1022.04

check it out if you like any of this

1024.26

information any of the content that

1026.24

we've sent and you would like to see

1027.439

more you can come out you can enroll for

1029.54

free we have free courses we've got

1031.819

places for you to get better at just

1034.459

learning a technology our how to's you

1037.1

can work on your business skills we can

1039.199

help you with becoming a better

1040.64

developer as in coding and things like

1043.04

that a lot of the stuff you've seen on

1044.72

YouTube we also have out at

1047.079

school.developmentor we just have it a

1049.16

little more of a educational format and

1051.679

a way for you to track your progress as

1054.14

you move forward becoming a better

1056.36

developer