Placeholder Image

字幕表 動画を再生する

  • What is a REST API?

  • What are the benefits

  • - and how are they fundamental to your cloud application development?

  • I'm Nathan Heckman from IBM Cloud,

  • and I'm going to answer that for you today,

  • but before i do please hit that subscribe button.

  • Let's jump in with an example.

  • Let's say that you work for an ice cream shop

  • and you're trying to build a web application

  • to show the flavors of ice cream that are in stock that day

  • and allow the workers to actually make updates to those flavors.

  • How do you do this?

  • Well, with a REST API.

  • You have your web app or web page communicate with a cloud-based server

  • via a REST API. Great!

  • So, let's jump into what exactly a REST API is.

  • Starting out with: what does "REST" stand for?

  • So, REST stands for Representational State Transfer.

  • So it's "REST".

  • Those words might not meanwhole lot to you

  • but, basically, it's a standardized software architecture style,

  • a specific type of API that's industry known and used.

  • So, the first thing that you should really know about  REST APIs

  • is they're all about communication.

  • So, client with server and vice versa - that's how they talk,

  • and also you may have heard the term "restful".

  • So, "restful web service", right, that's a service that uses REST APIs to communicate.  

  • So, what are some of the benefits of REST APIs?

  • First of all, they're a simple and standardized approach to communication.

  • You don't have to worry about how to format your data,

  • or how to format your request each time -

  • it's all standardized and industry used.

  • Second of all, REST APIs are scalable and stateless.

  • So, as your service grows in complexity you can easily make modifications  

  • and just the fact that they're stateless means you don't have to worry about

  • what data is in which state and keep track of that across client and server.

  • It's truly stateless.

  • Great, and then finally

  • they have high performance

  • in large part due to the fact that they support caching.

  • So, that's all all good stuff - as your service gets more complex

  • the performance stays very high.

  • Great! So, let's go back to our example.

  • So, for the ice cream shop, what would the REST API look like?

  • So, you have an endpoint which might look something like this:

  • "icecream.com/api/flavors"

  • Right? So, let's break that apartbit.

  • So, "api" this just signifies that this is the API portion of the endpoint.

  • Right? So, pretty straightforward there.

  • "Flavors" is actually what's known as a "resource".

  • So, this signifies that we're working with the flavors resource in this this REST API.

  • Great!

  • So, in our example,

  • the main building blocks, or parts, of the REST API are:

  • the "request", that is sent from the client to the server,

  • and the "response", that is received back from the the server.

  • So, let's let's break those apart a little bit.

  • Over here, let's put a big old box for request,

  • and what are the type of things that you might want to do with a REST API?

  • What actions or verbs would you want to make when you're working with one?

  • You may have heard of "CRUD" - what does CRUD stand for?

  • So, CRUD is "Create, Read, Update, and Delete".

  • These are some of the main things that you might want to do

  • when you're communicating with your client and server.

  • On a REST API, the equivalent of those are are actually HTTP "methods"

  • or "operations".

  • So, what's the equivalent of "create" in an HTTP method?

  • Well, it's "post".

  • And how about "read"?

  • So, read is actually called "get".

  • Update or replace is "put",

  • ... and delete? Guess what it is: "delete".

  • Not too creative there.

  • So, how about a request itself?

  • What are some of the pieces of it?

  • So, first of all, you might have an operation,

  • that's kind of what we just talked about here with the HTTP methods,

  • you might have an endpoint,

  • which is what we just talked about over here -

  • this is your REST API endpoint,

  • and then you might also have parameters or body,

  • which is some data that you might send in the request,  

  • and we'll see some examples in a moment,

  • and finally are the headers.

  • So, this is a special part of an REST API request   

  • which might have things like an API key or some authentication data.

  • Great - and then, in return, from the server, you'll receive a response, right?

  • So, we'll put a nice box here for response

  • and this is typically in the form of JSON data.

  • Great, so let's jump into our example,

  • and let's look at a few different scenarios that might happen with your ice cream shop, right?

  • So, first of all,

  • let's say that you want to display what's currently in stock, right?

  • So, we want to get the flavors that are in stock.

  • So, what does our rest API request look like?

  • Well, you have a "get" as the operation,

  • because you're actually wanting to get those flavors,

  • and then the end point is "/api/flavors",

  • and, in response, you'll get an array of those flavor resources, right?

  • So, we see strawberries in stock, as well as mint chocolate ... yummy!

  • but then, uh oh, mint chocolate is so popular

  • that it actually runs out for the day,

  • and the store is scrambling and they want to replace that flavor with another one.

  • They choose chocolate. Which is a great choice!

  • So, let's say they want to update the flavors, right?

  • So, you want to update or replace that mint chocolate with just chocolate.  

  • So, what does our request look like?

  • It's a "put" operation, so that updates or replaces.

  • The end point is "/api/flavors/1" to indicate the the ID of "1" you want to replace

  • and then parameter body you actually specify  the flavor of chocolate,

  • which is going to be the new flavor that's replaced.

  • And, in responsewe see indeed acknowledging that the ID of "1"

  • is replaced with a flavor of chocolate. Great!

  • Good news: the store just received a shipment of a brand new experimental flavor

  • called "restful raspberry",

  • and you want to actually load this new ice cream up into your website, right?

  • So, we want to create a new flavor.

  • How do we do that with the REST API?

  • Well, in our operation it's a "post" operation,

  • so that actually will create a new flavor,

  • the endpoint is once again "/api/flavors",

  • and we included in the body the flavor that we want to create,

  • which is "restful raspberry",

  • and in response we see ... yep, this new ID of "2" was created,

  • the flavor is restful raspberry.

  • Great! So, hopefully this clarifies what exactly isREST API?

  • What are some of the benefits? What's a real world example look like?

  • ... and how are REST APIs fundamental to your cloud application development?

  • Thank you.

  • If you have questions please drop us a line below.

  • If you want to see more videos like this in the future please "like" and subscribe,

  • - and don't forget:

  • you can grow your skills and earn a badge with IBM Cloud labs,

  • which are free browser-based interactive Kubernetes labs.

What is a REST API?

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

What is a REST API?

  • 10 2
    林宜悉 に公開 2022 年 05 月 11 日
動画の中の単語