Alrighty friends, we are slowly demystifying APIs. Let's talk about the most
common architectural style
and this is the REST API. Now notice the actual terminology I happen to use it.
I mentioned this
was an architectural style. This is really what we're talking about. REST is a
type of architecture.
So let's talk about how this particular API style is implemented then, okay?
Now the first thing to
state is that REST APIs are super, super common in the world of web services
and the way the REST WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and the way the REST
API happens to operate is utilizing what is known as a client server model. So
the server is pretty much
where the data is actually stored and the client is the one making requests to
that particular server.
So let's just draw out for a bit, okay? Here is our server over here and over
here this can be your
client. This is just me on my laptop, let's just say, okay? So let's imagine
that the type of API
available is a REST API. So essentially I as the client want to make a
connection with this
particular server and the transport that I'm going to use is going to be HTTP WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
particular server and the transport that I'm going to use is going to be HTTP
or more specifically
what you really want to be using is HTTPS which is the secure version utilizing
encryption.
Now one thing to state about our actual requests is that the requests happen to
be what are known as
stateless. So what does stateless actually mean in this particular context?
What I'm talking about
is that the server and the client do not have to remember anything about any
previous requests. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
previous requests.
So let's imagine this was request number one and then after we want to make a
second request,
now the success or failure of this particular request has nothing to do with
the previous request
that came before it. We don't have to remember the information each individual
request is going to be
evaluated on its own merit. Has the request been formatted correctly? Is it
requesting valid
information? Do we have permission to get the information so on so forth? So
long as we actually
pass all that criteria, then each message on their own is going to return a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
pass all that criteria, then each message on their own is going to return a
successful response.
Now I just mentioned the fact that we are utilizing HTTP, the hypertext
transfer protocol to
transport our information or to transport our request and facilitate the
responses. And this
is actually pretty handy because what we actually do is we make use of what are
known as HTTP
methods and we'll talk about these in a little bit more detail in the upcoming
video. But ultimately,
these methods allow us to specify the type of communication that we are
creating or the type of
information we are requesting that type of thing. Okay, so what type of WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
information we are requesting that type of thing. Okay, so what type of
requests are we actually
talking about here? Well, as you can imagine, that completely depends on your
intent. Let's
maybe say that the server over here happens to be storing some really
interesting information
about the vacation destinations such as the Bahamas. Well, in that case, what
you might want to be
doing is just simply reading the information from that particular server. Okay,
we're not trying to
modify anything. We just want to ask what information do you have? Send it back
to me, please. And
actually going to see that actually is a very particular HTTP method to perform WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
actually going to see that actually is a very particular HTTP method to perform
that action.
Whereas, maybe you would like to insert new information into the server itself.
I don't know,
let's maybe say you wanted to create a booking on this particular server so
that server was storing
your details such as when you want to go. The fact that you have paid your
money, what your name
measure age is that type of thing. Well, that is a completely different
operation that you can
once again specify with a very particular HTTP method. Similarly, maybe you
want to perhaps update WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
want to perhaps update
existing information that already exists on the server. Maybe just use a little
modification that
is another way you can do that via another HTTP method. And similar, let's
maybe say you wanted to
perhaps know that it's delete information from the server. Then you guessed
that once again,
we do actually have a particular method to perform this action. Now in a
similar way with
rest APIs, we're also going to make use of something known as headers. Again,
we'll talk about this
in a little bit more detail very, very shortly. Now these headers ultimately
allow to specify the
type of information that we are wanting to receive or perhaps specifying the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
type of information that we are wanting to receive or perhaps specifying the
type of information we
want to be sending. So let's maybe say we want to make a request to the server
and we want to
receive the information back formatted in JSON. We can essentially utilize our
headers to specify
that particular preference. Similar to let's maybe say we want to be updating a
server. And for
whatever reason, we're going to be using some type of XML based payload, well,
we can specify to
the server that we're going to be sending XML type data. Okay, so we know that WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the server that we're going to be sending XML type data. Okay, so we know that
rest is going to be
utilizing HTTP or HTTPS. We have HTTP methods that we can use to specify the
type of operation that we
want to use. Are we getting information? Are we deleting information? That type
of thing? We have
these headers to specify the type of information we want or the type of
information we want to send.
All of these well integrated into the rest architecture, but perhaps the most,
well, I don't want
to say the most important one because they're all very, very important, but one
real core fundamental
thing with respect to rest APIs is the understanding that you arise. These WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
thing with respect to rest APIs is the understanding that you arise. These
actually point to very
particular resources. Now what an earth am I talking about? Let me show you
what I mean here. Okay,
here I am on my browser right here. And let's maybe say I wanted to access the
CBT Nuggets server.
Well, what I can do is enter CBT Nuggets.com and as we can see here, this
actually takes me to the
CBT Nuggets homepage. Now let's maybe say I wanted to access a very particular
resource on the server WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
resource on the server
itself. What would I actually do? If I modify my URL request, that is going to
correlate to a different
resource on the server and serve up a different page to me. So say, for example
, once again, if I just
zoom in a little bit, if I modify the URL to be forward slash blog and now hit
enter, look at this
right here. We actually get a different resource on the CBT Nuggets server. Now
we're getting the
blog information. See that correlation? The actual URL path actually pulls a
different piece of
information from the server itself. Now this is basically what I'm talking WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
information from the server itself. Now this is basically what I'm talking
about with respect to
REST APIs. Let's imagine you've got a Cisco WebEx application. Okay, now Cisco
WebEx is basically
just Cisco's collaboration platform for being able to send messages, create
chat channels,
video meetings, that type of thing. But Cisco WebEx also has a REST API. Okay,
so let's imagine
me over here on my little laptop and also let's say, for example, it had a
little home network here.
These can be three routers all connected. Okay, R1, R2 and R3. Now suppose, for WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
These can be three routers all connected. Okay, R1, R2 and R3. Now suppose, for
example, I was using my
Python script to effectively go out to my network, connect to all my devices
and run some particular
tests. Let's imagine that I was testing that all my OSPF adjacencies were in
the full state.
And every time I ran this script, I wanted to send a message into Cisco WebEx
so that everyone
using the chat channel could ultimately see the result of this particular test.
Well, my Python
script, after running this particular test against my network, would then have
to craft an HTTP WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to craft an HTTP
request, or HTTPS should I say, to the WebEx REST API. Now the crucial thing
here is if I want to
access a particular resource on this particular server, say, for example, I
want to be able to,
oh, I don't know, let's maybe say I wanted to send a message programmatically.
Then this particular
functionality, the ability to send a message will actually correlate to a
particular URL.
Now what you would do before actually writing the Python script is you would go
to say, for example,
the WebEx documentation, find out about its REST API, and then find out, hey, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the WebEx documentation, find out about its REST API, and then find out, hey,
if I want to send a
message, which URL would I have to use in order to be able to send that message
? So let me show you
what I mean once again. If you search for WebEx REST API, let's click this here
. Now if you get in
the left hand side, we can see the full API reference. So if I just scroll to
the documentation and
find the page for messages, which we can see right here, let's click this. What
it actually tells me
here is the actual URLs I would have to use in order to be able to, you know,
either list the messages
I've already created or create a brand new message, that type of thing. So in WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I've already created or create a brand new message, that type of thing. So in
my case here, I would use
this particular URL and then I could create a message resource on the actual
server itself. Whereas,
say, for example, I wanted to create a brand new room utilizing Python. We can
indeed see here that
to create a room, the actual endpoints here are completely different. This one
here is forward/rooms
as opposed to forward/messages. This is how we determine what it is we want to
do on the server.
So now we are beginning to tease out more information about how REST APIs WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So now we are beginning to tease out more information about how REST APIs
actually operate. Let's now take
a little bit more time talking about these HTTP methods.