WEBVTT

00:05.210 --> 00:05.940
By everyone.

00:05.940 --> 00:06.970
Welcome back.

00:07.410 --> 00:14.520
So in this video we're going to be talking about what a restful API is so we always hear that term restful

00:16.430 --> 00:17.250
API.

00:17.510 --> 00:23.000
So we're going to be talking about what is a restful API before we build one.

00:23.270 --> 00:26.610
Again this is not going to be you know comprehensive sense.

00:26.630 --> 00:31.040
There are like even books about what restfully be I should be.

00:31.160 --> 00:38.540
And we can't possibly cover everything in the scope of course but we will be talking about what really

00:38.540 --> 00:41.960
constitutes arrest for what is what is it.

00:42.050 --> 00:44.190
What it basically is in this video.

00:44.320 --> 00:44.660
OK.

00:44.690 --> 00:45.850
So let's get started.

00:46.160 --> 00:55.520
So to begin with just to give you know a definition it's basically an architectural style architecture.

00:57.640 --> 01:01.910
Style upbuilding API.

01:03.330 --> 01:09.450
So that's simply a definition and you might not even know you are not sure what that really means.

01:09.450 --> 01:12.250
Let's let's let's break it down part by part.

01:12.300 --> 01:14.030
So what is an API.

01:14.250 --> 01:18.600
An API is basically code that allows you to take a request

01:22.330 --> 01:29.980
and then this code takes the request and then it does some process for you and prepares a response.

01:32.220 --> 01:39.350
And returns this response you know it eyes are not nothing fancy or nothing you can think of a library.

01:39.360 --> 01:39.870
Right.

01:39.990 --> 01:47.230
When you For example in any in Python when you do you know important and then some library library right

01:47.730 --> 01:53.760
library as you know something let's say non-P as an MP.

01:53.790 --> 01:54.590
Right.

01:54.600 --> 01:58.830
So we're importing non-P here as an IP.

01:59.080 --> 02:05.720
Now you can think of Numby really as an API non-P offers you lots of functions right.

02:05.730 --> 02:14.010
You have no and pede array and then you have you know all these hundreds of functions and you can think

02:14.010 --> 02:17.640
that Numby takes in your request is made you do.

02:17.650 --> 02:23.470
And Peter arrays so you're telling them hey I want an array that does this function.

02:24.030 --> 02:30.480
And then non-P does under the hood does some computation and then it returns you a response which is

02:30.480 --> 02:32.830
your array that you want to write.

02:33.240 --> 02:35.120
Similarly for all these functions.

02:35.140 --> 02:35.470
No.

02:35.510 --> 02:41.970
He's basically offering you all its API so that you can use your give it a request and then you get

02:41.970 --> 02:42.710
the responses.

02:42.720 --> 02:46.770
And that's what most of our programming is really using API.

02:46.770 --> 02:49.890
So you guys are nothing new now.

02:50.190 --> 02:56.760
So define what an API mean is there's a very classical example where I think when you're in a restaurant

02:56.760 --> 02:57.190
right.

02:57.330 --> 03:04.890
So there is you know you and maybe you know your girlfriend maybe you or your wife and then think here

03:04.950 --> 03:06.530
is the waiter.

03:07.050 --> 03:08.360
And then here is the kitchen.

03:08.410 --> 03:09.230
Right.

03:09.780 --> 03:15.690
So in this context here the waiter acts as an API and the waiter takes in your request.

03:15.690 --> 03:21.190
He says OK you want this chicken or vegetables or whatever.

03:21.390 --> 03:27.900
And then it takes that request and then sends it over to the kitchen where and where sometimes the waiter

03:27.900 --> 03:30.330
would cook but that's not what happens right.

03:30.610 --> 03:32.790
You know the kitchen is where cooks.

03:32.790 --> 03:38.910
And then once the cooking has happened then the waiter takes the response which is your dish dish that

03:38.910 --> 03:44.570
you ordered foie gras and then takes it back and gives it back to you.

03:44.580 --> 03:48.450
So in a way the waiter is acting really is an API.

03:48.910 --> 03:54.630
So yeah that's just you know our classical example of what a weather API is.

03:54.630 --> 03:58.930
So we're saying that a restful API is a method of designing API.

03:59.110 --> 04:01.890
It's an architectural style it's one way of doing it.

04:01.880 --> 04:03.050
Not the only way.

04:03.150 --> 04:04.870
Style of building an API.

04:04.890 --> 04:06.500
But it's one way.

04:07.110 --> 04:11.610
And if you feel like this request response here is very familiar.

04:11.620 --> 04:19.260
Well it's because when we were talking about the Web how the web was working and how DTP was working

04:19.260 --> 04:24.010
we always said that you always do a request and then you get a response back.

04:24.390 --> 04:25.900
Well that's the idea here.

04:25.900 --> 04:33.480
The idea is the communication in arrest for API uses the web.

04:33.510 --> 04:36.900
So rest for API really it's just an API right.

04:37.090 --> 04:38.790
We're just a normal API.

04:39.060 --> 04:47.520
But instead of using you know the on and off line version of the code you're actually using HTP or the

04:47.520 --> 04:52.550
web to communicate with with this kitchen.

04:52.630 --> 04:53.310
So.

04:53.370 --> 04:55.760
So instead of having this kitchen locally.

04:55.770 --> 04:56.280
Right.

04:56.430 --> 04:59.780
This kitchen is in the cloud or on the web.

05:00.210 --> 05:03.940
And then your waiter here is HTP right.

05:04.040 --> 05:11.040
You're preparing a request to go to the kitchen using as you can be and that she gives you the response

05:11.040 --> 05:14.000
back using a to keep your response.

05:14.160 --> 05:19.800
So this request response pattern is basically what an API is expected to do.

05:20.070 --> 05:29.920
And the means of communication between you and your girlfriend or wife and the kitchen is using HTP.

05:30.240 --> 05:31.200
Right.

05:31.740 --> 05:39.090
So in other words really a restful AB is nothing more than just a normal API just a normal library that

05:39.090 --> 05:46.310
offers a bunch of functions for you but these functions can be consumed or can be used right.

05:46.320 --> 05:49.770
So here I can just consume them by calling the function right.

05:49.950 --> 05:53.160
But here in this case they're not a local library.

05:53.160 --> 06:01.560
In this case what I do is I use HTP over the web to send a response to send a request to this API over

06:01.560 --> 06:09.400
the web make the API do some stuff for me and then get their response back to my web application or

06:09.460 --> 06:12.180
it or get their response back in general.

06:12.210 --> 06:18.520
So that's basically the whole idea of a restful API restful API is you have your own server.

06:18.570 --> 06:19.430
Right.

06:20.040 --> 06:22.350
Let's say you're building a restful API.

06:22.530 --> 06:25.860
So you have your server and then you open a few and boy.

06:25.860 --> 06:33.720
So just like we did previously it is like Slash by Slash add two nuns you know slash the other.

06:33.740 --> 06:34.610
And so on.

06:34.610 --> 06:42.060
So you open a bunch of you know and points on your server and you say to people hey these are my points.

06:42.290 --> 06:43.850
This is my API here.

06:43.850 --> 06:45.400
So this is my API.

06:45.590 --> 06:49.930
All these functions you can use by just accessing this endpoint.

06:50.180 --> 06:52.130
So a user or a developer.

06:52.130 --> 06:55.430
Most people who use Abiah eyes are really developers.

06:55.490 --> 06:58.090
So let's say you're making a mobile app right.

06:58.790 --> 07:03.700
And then the more about how you want to add you know to numbers right.

07:03.740 --> 07:07.030
You could just add you know be calls a plus one.

07:07.030 --> 07:07.320
Right.

07:07.320 --> 07:08.660
It's simple.

07:08.860 --> 07:14.970
Let's say you're using like a really crappy crappy programming language that doesn't support too.

07:15.020 --> 07:22.340
Adding two numbers right or say even a more realistic example is let's say your function here adds really

07:22.340 --> 07:23.200
huge numbers.

07:23.240 --> 07:27.380
So let's say you do be equal a times two here.

07:27.410 --> 07:31.940
This would lead to an overflow and you don't want to handle all the overflow stuff.

07:31.940 --> 07:36.300
So you're going to leave it up to that API to add two numbers safely.

07:36.320 --> 07:44.120
So what you do is instead of doing it because times do what you do as you do every request to that end

07:44.120 --> 07:52.560
point and slash add two numbers and you send you know a and a right to A's so be equals daytime's two

07:52.610 --> 07:54.940
is the same as me call a plus a right.

07:55.010 --> 08:03.350
So you send a twice and you posted to the API twice and then that API adds it for you no matter how

08:03.350 --> 08:04.610
big your numbers are right.

08:04.610 --> 08:06.870
Because it handles this safely.

08:07.130 --> 08:11.720
And then once the API is done it replies you response.

08:12.110 --> 08:16.970
And then you just take the response and store it and b whether it's a B or you know just a training

08:16.970 --> 08:19.100
representation of B or whatever.

08:19.310 --> 08:19.890
Right.

08:19.910 --> 08:26.770
So in a way instead of you know handling instead of doing for example NPE not peanuts.

08:27.000 --> 08:35.120
And then a in a right instead if you're doing it locally you're using HGT be here to access this API

08:35.120 --> 08:42.200
server that has a bunch of end points that act as functions and these functions do some operations for

08:42.200 --> 08:44.490
you and return the response for you.

08:44.780 --> 08:46.750
So this is your request going.

08:46.850 --> 08:52.670
And then this is the response that you're receiving back and this is exactly what a KPI server is.

08:52.850 --> 08:56.260
We are building a product for developers to use.

08:56.270 --> 09:04.790
So let's say developers usually you know in most languages have relatively good overflow handy.

09:04.810 --> 09:11.930
Right but one of the one of the projects we'll do in this course is we're going to build our image recognition

09:12.860 --> 09:13.390
API.

09:13.400 --> 09:20.220
So we're going to build that API which is made off you know slash recognize.

09:20.320 --> 09:21.080
Right.

09:21.560 --> 09:29.000
And then the user here is going to send us an image and we're going to apply a machine learning model

09:29.320 --> 09:34.940
or a pre trained machine learning model and we're going to recognize or say the user sends us an image

09:34.940 --> 09:35.710
of a panda.

09:35.720 --> 09:36.310
Right.

09:36.590 --> 09:44.930
So we want to get recognize it and then we're going to say going to reply to the user image with a Jason

09:45.170 --> 09:46.320
image.

09:46.380 --> 09:50.010
Kanda and so on.

09:50.210 --> 09:56.200
And then the user would get this request and you know instant instead of him having to you know implement

09:56.530 --> 10:04.000
locally all these machine learning algorithms and image recognition all the stuff with just one call

10:04.000 --> 10:07.110
to slash recognize and giving us the photo.

10:07.180 --> 10:09.930
He's essentially got going back.

10:09.940 --> 10:17.850
The result of panda in which we used here the the in our server we did the computation work for him

10:17.860 --> 10:23.620
we figured out what this photo is and we're blind to him as as a panda.

10:23.710 --> 10:30.130
So this is the power off of API and this is why many people nowadays nobody you know does very heavy

10:30.130 --> 10:36.610
computations like image recognition and all the stuff no one does it locally because if you do it locally

10:36.640 --> 10:41.950
then it's really you're doing for example a mobile application then you're running this on the mobile

10:42.250 --> 10:45.750
and mobile capabilities are nowhere near as powerful as a server.

10:45.770 --> 10:51.120
You know it's a really bad idea to run a machine learning model on a mobo.

10:51.210 --> 10:52.200
You know it will crash.

10:52.210 --> 10:53.610
Oh most definitely.

10:53.620 --> 11:01.120
So what users end up doing or what developers end up doing is they offload this this huge you know recognizer

11:01.120 --> 11:11.080
or this huge computation required and they offloaded from the mobile app and then they offloaded to

11:11.080 --> 11:17.120
a server a dedicated server which does all this computation for them and then replies Their response

11:17.120 --> 11:18.610
that they need.

11:18.610 --> 11:24.750
And this is basically what you know and a restful API here this this here is not only the API.

11:24.770 --> 11:27.370
This is actually a restful API.

11:27.580 --> 11:31.740
So this is basically what it restfully be eyes into the normal API.

11:31.900 --> 11:34.400
That just supports HGP.

11:34.450 --> 11:43.000
It's implemented using the communication means from one end to the other is just using HTP.

11:43.060 --> 11:47.470
So yeah that's basically what a restful API is.

11:47.470 --> 11:52.830
One last point to talk about is you know this is very very useful for developers right.

11:53.020 --> 11:59.030
Before if you wanted to build a mobile application for example which which you know you would you would

11:59.050 --> 12:03.490
implement some machine learning algorithms and you would have to implement this from scratch.

12:03.490 --> 12:05.400
And this is a really bad idea.

12:05.410 --> 12:06.020
Right.

12:06.040 --> 12:08.780
Again you're going to be running it on a mobile phone.

12:08.880 --> 12:15.220
Superslow you're on you're you know you're going to be doing everything offline even if you use library

12:15.370 --> 12:15.880
libraries.

12:15.880 --> 12:22.210
It's still going to be on the phone but now with the idea or restful API is is is that you can think

12:22.210 --> 12:22.550
of.

12:22.690 --> 12:29.530
So as the developer has so many API eyes on the cloud right mean not only this API but so many clouds.

12:29.680 --> 12:35.660
And then now you can just click with one or one request he says hey give me that time.

12:35.710 --> 12:40.750
And then this this you know maybe I convert the time for him and then he does another request.

12:40.840 --> 12:49.570
Hey you know convert that timeframe from UTC to PSTN for example and then you convert the time for him

12:49.840 --> 12:55.500
and then all these guys are basically like services to the developer which she can.

12:55.500 --> 12:56.490
It's like a dream.

12:56.500 --> 12:57.080
Right.

12:57.100 --> 12:59.270
You have an API for everything.

12:59.310 --> 13:06.670
So you want to numbers use an API you know even though it's it's it's not that you know doesn't make

13:06.670 --> 13:13.810
sense to add to a numbers using an API but the you get the idea is like that you have you know machine

13:13.810 --> 13:20.920
learning API and you have time you have you know prices let's say you want to get the prices the current

13:20.920 --> 13:29.440
prices in in in in for example for the stocks you can get at an API for Stop prices.

13:29.440 --> 13:31.140
So the ideas are limitless.

13:31.150 --> 13:39.670
And in exchange for the developer for accessing this this model here this API here then the API I would

13:39.750 --> 13:42.630
would make the developer pay a little bit of money right.

13:42.630 --> 13:50.020
Or maybe most guys are like zero point zero zero zero one dollars per hour per call right.

13:50.200 --> 13:57.290
So in that way the rest for API builder gets a little bit of money for the server that is running right

13:57.300 --> 14:04.600
because this costs money race running Serbin costs money and in response the developer can code a super

14:04.600 --> 14:11.470
hard machine learning application and just a few hours using all these you know are by offloading all

14:11.470 --> 14:16.160
the heavy work or heavy lifting to these restful API.

14:16.540 --> 14:21.970
So for me the idea was clear here and we're going to be discussing more about how to build restful Adrianne's

14:22.060 --> 14:23.350
in the next video.

14:23.500 --> 14:25.420
So until the next thing you have Piccoli.
