Placeholder Image

字幕列表 影片播放

  • What's an API?

  • What's an SDK?

  • And how are the two related?

  • How can APIs and SDKs help streamline my cloud app development workflows?

  • I'm Nathan Hekman from IBM Cloud

  • and before I jump in and answer that for you,

  • please hit that subscribe button.

  • Alright, let's get started with an example.

  • Let's say you're developing a mobile app for a veterinarian clinic,

  • and the idea is for this mobile app to actually

  • allow a receptionist to take a picture of a pet as it enters the clinic

  • and the app will communicate with a visual recognition service

  • that's running on the cloud.  

  • And the idea is for the service to return the pet's name and bring up their file.  

  • So, how do we do this? How do we communicate  between the mobile app and this cloud-based  service?

  • Well, that's where APIs and SDKs come in.

  • Let's get started by talking about APIs,

  • and we'll actually be comparing the two.

  • So, first of all, APIs are all about communication.

  • So, there are a set of definitions and protocols

  • for apps or services to talk to other apps or services.

  • So, you can kind of think of them likebridge between your app

  • and, say, this cloud-based visual recognition service.

  • So, what does "API" stand for anyway?

  • Well, it's Application Programming interface - A.P.I.

  • And what are some of the aspects of APIs that make them useful?

  • Well, like I said they're they're all about communication.

  • So, communicating between a service and another service, an app and another app,

  • it's it's how they talk to each other.

  • Next, they're all about abstraction.

  • What does "abstraction" mean?

  • So, inside the VR service, up in the cloud,

  • there's probably potentially thousands of lines of code running up there,  right?

  • And you as a developer of a mobile app you don't want to have to worry about,

  • "OK, which method in this service do I call to get the pet's name?"

  • You don't want to have to worry about that.

  • So, what an API does is it abstracts away all that complicated logic

  • so you just have to worry about getting just the  data you need.

  • It simplifies the process.

  • And third, APIs are standardized.

  • Meaning, there's industry-defined standards  for how to define an API

  • and there's a few formats that are popular for APIs.

  • You may have heard of SOAP, GraphQL, or REST,

  • - which, fun fact, stands for "Representational State  Transfer",

  • and that's what we'll focus on for this video.

  • So, what are some of the building blocks of APIs?

  • First of all, to actually send data, or send what's called a "request"

  • from the mobile app to the VR service on the cloud

  • you need to have a few different pieces.

  • Sofor a REST API call request you need to have

  • what's called an operation.

  • So this is this could be HTTP methods like POSTPUT, GET, DELETE.

  • In this case it would be a POST method

  • because you're sending a request over to the service

  • which might include something like maybe the file name

  • of the image you took of the pet.

  • Next, would be parameters, this is optional.

  • So, this, in this case, might be the file name of the image you took.

  • So maybe cat.jpeg - if it's a cat that you took a picture of.

  • And finally, would be the endpoint.

  • So, that's the URLbasically,

  • of the visual recognition service that you're trying to talk to.

  • So, maybe that's, you know, it's some URL-slash-analyze.

  • Great, so that's your request, right?

  • So, this is what makes up a request.

  • How about a response?

  • What might a REST API response call that you receive back

  • from the visual recognition service look like?

  • Typically it's it's some form of raw data, maybe JSON.  

  • So, a request might look something like,

  • or sorry, a RESPONSE, might look something like this.

  • So, you have sort of this this data object that might include

  • you know, the result, the type which is a cat,

  • and maybe the name -

  • which, in this case may be "Mittens" just walked into the  clinic.

  • Great, so that's sort of the building blocks of what an API is.

  • As a developer though, how do you actually call an API in your code?

  • You don't want to have to worry about

  • setting up your request with all these building blocks of operations, parameters, endpoints,

  • and dealing with raw JSON objects, right?

  • So that's where SDKs come in and really shine.

  • So, let's talk about SDKs, what does that stand for?

  • Well it is Software Development Kit, S.D.K.

  • Pretty straightforwardright?

  • So, SDKs, you can really think of liketoolbox

  • of tools, or code that actually call APIs for you.

  • Pretty cool, right?

  • So, you may be specialized in one programming language over the other,  

  • you know, there's SDKs in a variety of languages.

  • So, there's maybe an SDK in Java, in Node,

  • maybe Go,

  • or Python -

  • whichever language that is your specialty there's probably an SDK for you.

  • Perfect. So, back to our example over here,

  • what might an SDK look like in this example?

  • So, with an SDK, let's let's go ahead and put our little SDK toolbox

  • within the mobile app

  • and, for this case, since it's a mobile app,

  • saywe'll use the Java SDK. Great!

  • So, in this Java SDK,

  • rather than having to configure

  • your request manually with all these building blocks, you might actually call

  • just a method, that's maybe called, I don't know, "Get Result",

  • that will actually call these various building blocks -

  • the operation, the parameters,

  • and the request for you,

  • it'll make it for you and it'll make that API request for you with code.

  • In response, you'll get a response but it won't be necessarily a JSON object,

  • it might be some code,

  • maybe a native model object in Java called an "Analyze Response Object".

  • So, the code might look something like this.

  • So, you have an Analyze Response Object

  • that you call the "Visual Recognition Analyze and Get Results" method.

  • You pass in a parameter, which is "cat.jpg", which is the name of the file

  • that you sent over the visual recognition service

  • and, in response, you can actually go ahead and set

  • a label in your mobile app to be "Mittens".

  • So, that's the data you received in the form of an analyze response model object in Java,

  • via your SDK, and you're able to see Mittens has entered the building.

  • So, hopefully, this kind of summarizes what's an API, what's an SDK,

  • what are both used for,

  • and how they are truly fundamental tools in your cloud app development toolbox.

  • 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 CloudLabs,

  • which are free browser-based interactive Kubernetes labs.

What's an API?

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級 美國腔

API Essentials - 06 API vs. SDK(API vs. SDK: What's the difference?)

  • 4 1
    林宜悉 發佈於 2022 年 05 月 11 日
影片單字