WEBVTT

00:05.100 --> 00:05.760
I HAVE ROOM.

00:05.780 --> 00:06.770
Welcome back.

00:06.980 --> 00:11.700
So in this video we're going to be starting to work on a project of.

00:11.880 --> 00:18.320
So so what we've been dealing with Baby Eyes that add subtract divide and multiply numbers and usually

00:18.320 --> 00:19.430
no one would you know.

00:19.430 --> 00:19.730
No.

00:19.760 --> 00:25.260
Most developers wouldn't call and maybe just add two numbers right unless they're like super huge rise

00:25.380 --> 00:32.330
and usually be what people would do is they just use the addition or a division in their in their original

00:33.050 --> 00:36.310
programming language that they're using to develop something right.

00:36.470 --> 00:43.070
And so it doesn't really make our API doesn't really isn't really concrete or is it really practical

00:43.090 --> 00:43.740
person.

00:43.940 --> 00:49.090
But we are now going to start moving into a slightly more flexible API.

00:49.260 --> 00:53.000
So for now we're just going to comment on all of this already.

00:53.000 --> 00:58.820
From now from from from this moment on we're going to comment this on we're going to refences sometime

00:58.820 --> 01:04.580
soon so I don't want to delete it because we might copy some code from here but for now let's just copy

01:04.580 --> 01:06.840
this and we're going to write a new application.

01:06.980 --> 01:11.350
And now like this idea this application is going to be very simple.

01:11.540 --> 01:16.020
So we have a couple of free user requirements if you think about it.

01:16.130 --> 01:20.690
Now the first thing is we have to allow registration off a user.

01:20.690 --> 01:21.140
OK.

01:21.230 --> 01:27.380
So this is one of the most important thing in an API you want to make users be able to register into

01:27.380 --> 01:28.150
your API.

01:28.160 --> 01:28.920
Right.

01:28.940 --> 01:39.620
The second thing is we want the user to have the ability to store a sentence on our database for one

01:39.620 --> 01:40.280
token.

01:40.400 --> 01:48.650
So for starters they each user is going to get 10 tokens so each user say right here each user gets

01:48.890 --> 01:49.780
10 tokens.

01:49.810 --> 01:50.520
OK.

01:50.870 --> 01:58.080
If the user stores a sentence on our database he uses one token and he can also retrieve.

01:58.280 --> 02:07.620
OK so you can retrieve as his short sentence door sentence on our database for one to open.

02:07.670 --> 02:08.330
OK.

02:08.510 --> 02:15.920
So there's two dives right there's 1 1 2 and 4 to store a sentence on the database and one one token

02:15.920 --> 02:23.090
to retrieve Histoires and sentence right so you can store something on our database and in return for

02:23.090 --> 02:24.960
storing something on our database.

02:25.070 --> 02:26.710
I will take a token for him.

02:26.730 --> 02:31.190
And basically you can think of these tokens as something you might be selling right you might be an

02:31.220 --> 02:39.930
API business who is trying to sell to users like OK buy a hundred tokens for maybe $1 or $2 right.

02:40.010 --> 02:46.700
So you're allowing the user to use these and tokens to access your service right to access your API.

02:46.940 --> 02:51.680
So we're going to allow the user to register and that's of course zero tokens right and that's for free

02:52.100 --> 02:54.260
and that each user gets 10 tokens.

02:54.320 --> 03:00.740
So that's tokens over here and store a sentence for one token and retrieve his stored sentence from

03:00.740 --> 03:03.040
our database for one too.

03:03.290 --> 03:08.990
Now a couple of things we're going we're going to be doing password and user name storage.

03:08.990 --> 03:13.910
So we're also going to be talking about a lot of stuff like password hashing and salting and all that

03:13.910 --> 03:15.360
stuff.

03:15.380 --> 03:17.150
So that should be exciting.

03:17.150 --> 03:23.330
And by the way when we're done with this API hopefully should looked similar to an API you might see

03:23.330 --> 03:24.300
in the market right.

03:24.440 --> 03:30.800
Some some you might have heard the name off the database as a service or some services actually offer

03:30.800 --> 03:35.850
you an API just to store stuff on their database and they charge you for some money right.

03:35.900 --> 03:41.870
So this is the same idea but on a much smaller scale so we're only allowing them to store like a string

03:42.050 --> 03:42.710
not a file.

03:42.710 --> 03:46.810
Nothing huge just a tiny string onto our database.

03:46.910 --> 03:49.250
And then he might pay for one too.

03:49.600 --> 03:50.170
OK.

03:50.240 --> 03:52.410
So first of all we're designing an API.

03:52.430 --> 03:56.840
We're designing a brand new API so we want to have a chart protocol on shorts.

03:56.840 --> 03:59.820
Let's go here and start working on join.

03:59.900 --> 04:00.430
OK.

04:00.530 --> 04:07.840
We're going to be drawing the chart that we usually do when we start working on a new API.

04:08.150 --> 04:13.520
OK so we have a couple of them and we have a resource if you remember we have the resource app and then

04:13.520 --> 04:18.440
we have the address of that resource where is going to be at.

04:18.650 --> 04:25.860
And then the type of the source of the protocol and then to prove to CO.

04:25.910 --> 04:26.490
Right.

04:26.690 --> 04:28.830
And then parameters.

04:28.970 --> 04:30.610
What parameters are we going to take.

04:30.740 --> 04:32.220
And then responses.

04:32.240 --> 04:36.820
Okay so how that our response is going to be plus data is good right.

04:36.920 --> 04:38.840
What status codes are we going to use.

04:38.930 --> 04:39.480
Okay.

04:39.890 --> 04:43.970
Okay so let's divide this year as do this line hopefully.

04:44.000 --> 04:48.630
Not too bad of a line right now not to straight.

04:48.790 --> 04:50.720
And then we're dividing this into a table.

04:50.740 --> 04:51.180
Okay.

04:51.220 --> 04:54.090
And then a line over here.

04:54.130 --> 04:59.850
So the first resource that we want to support is we're going to support 3M.

04:59.890 --> 05:04.600
So the first one is to register I user.

05:04.600 --> 05:10.560
Right so this is the first resource that we should have in our API.

05:10.740 --> 05:17.650
And so the actress might be at slash register for example now since the user is going to be sending

05:17.650 --> 05:21.290
us his username and password that he wants to register with.

05:21.420 --> 05:23.590
Then this is going to be post right.

05:23.590 --> 05:31.360
We need to get information from his for his username and his desired password from here from from the

05:31.360 --> 05:32.080
posted data.

05:32.110 --> 05:38.530
Right so we're going to do post because we need the body to sign with his information and we should

05:38.530 --> 05:45.010
expect do things right we should expect a username username and password so I'm just going to write

05:45.010 --> 05:50.230
P.W. and both of them should be strings right strings.

05:50.230 --> 05:51.980
Now what about the response codes.

05:52.000 --> 05:54.940
Well there's Fosco to your mind be 200.

05:54.970 --> 05:55.790
OK.

05:55.870 --> 06:01.150
So that means that you're registered successfully or you might be some other numbers right we want to

06:01.150 --> 06:02.940
make this API very simple.

06:03.070 --> 06:09.940
So you might add here something like 301 which means that his response for example his password was

06:09.940 --> 06:10.680
very weak.

06:10.690 --> 06:11.100
Right.

06:11.140 --> 06:13.230
So you don't hate choose another password.

06:13.540 --> 06:15.240
But for now we're just going to take.

06:15.250 --> 06:20.470
You know I saying that the user is smart enough to choose a good password and not a bad password.

06:20.670 --> 06:23.860
I said we'll just leave the status quo as 200 for now.

06:24.010 --> 06:26.200
OK so that's the first resource.

06:26.470 --> 06:31.930
The second resource we're going to cover is to store a sentence right store sentence.

06:32.110 --> 06:36.660
And as you might have guessed the third one is going to Zola's do a line here.

06:36.850 --> 06:40.840
And the third one is going to be retrieve sentence.

06:40.870 --> 06:41.810
OK.

06:42.630 --> 06:49.730
So a store sentence is going to be at slash or and then they retrieve sentence let's just do it.

06:49.730 --> 06:54.190
Ask lasht get right get Give me my sentence right.

06:54.290 --> 06:57.680
So the storewide So the slash get one should you.

06:57.680 --> 07:03.260
This is it should be obvious from your IT SHOULD BE A get right because we want the information right

07:03.260 --> 07:06.350
where we're telling the server Hey give me my sentence back.

07:06.350 --> 07:08.760
So it's again we're just getting the protocol.

07:08.810 --> 07:11.020
We're just getting the resource.

07:11.150 --> 07:18.200
Whereas in store I'm sending the server my sentence I'm telling you hey I want you to store my sentence.

07:18.230 --> 07:25.310
So this is going to also be a post and for the parameters we are going to need a couple of things right.

07:25.310 --> 07:33.320
We want to make sure that the user sends his username username password and also the sentence right.

07:33.470 --> 07:36.630
Now why does you need to do to send the user name and password.

07:36.650 --> 07:40.580
Well imagine if I am I know that my friend is registered.

07:40.700 --> 07:45.520
So I tell I tell you hey I'm on my friend story for me in this sentence.

07:45.630 --> 07:50.090
And so I ended up using his own tokens even though he didn't use my service.

07:50.180 --> 07:53.580
So I have to make sure that the person who is sent 10s.

07:53.660 --> 07:58.270
So I have to make sure that the person who is requesting my API is actually the correct person right

07:58.280 --> 08:01.030
before I take away one token from him.

08:01.030 --> 08:01.360
Right.

08:01.460 --> 08:05.200
So I have to make sure that they use your name and the passwords match together.

08:05.690 --> 08:08.260
Now what about the response goes What about.

08:08.300 --> 08:09.960
So I might have 200.

08:09.970 --> 08:14.400
OK so everything went fine and you know the whole world is fine.

08:14.420 --> 08:20.980
No problems here or I might have even 301 so 301 might be out of tokens.

08:21.170 --> 08:26.490
So the user might be asking hey please please.

08:26.710 --> 08:27.950
Store for me this sentence.

08:27.950 --> 08:33.020
But he has zero tokens I'm telling him sorry you don't have enough tokens I can't store it for you you

08:33.020 --> 08:34.870
have to buy more before you use it.

08:34.890 --> 08:35.480
Right.

08:35.810 --> 08:39.760
You can also have I'm just going to put it here three and two.

08:39.860 --> 08:47.720
And that's what happens when this user name doesn't match this password right so invalid username or

08:47.720 --> 08:51.530
username password combo combination.

08:51.620 --> 08:57.360
So this username doesn't correspond to this Vaswani So I tell him hey you're not authorized to try to

08:57.490 --> 09:02.430
do it to do something else and put it check your password for example.

09:03.740 --> 09:05.980
Now this is the same thing for the retrieve sentence.

09:05.990 --> 09:09.650
I just need his username and password.

09:09.710 --> 09:12.890
I don't need a sentence right because that's what I'm returning to him.

09:13.220 --> 09:15.360
And then a similar lead might have to do it.

09:15.380 --> 09:16.250
OK.

09:16.520 --> 09:18.450
If it's everything's fine.

09:18.460 --> 09:26.710
My also asked 301 out of token out of tokens so he doesn't have enough tokens to retrieve his aunt.

09:26.720 --> 09:33.830
So I tell him please buy more tokens so you can use my service or 1:57 is username and password are

09:33.830 --> 09:38.640
incorrect so invalid username password.

09:38.720 --> 09:39.210
OK.

09:39.470 --> 09:41.450
So that's my political That's my idea.

09:41.450 --> 09:45.520
That's the API that we will be building in the next video.

09:45.530 --> 09:47.900
But for now let's just stop here.

09:48.140 --> 09:53.750
And in the next video we're going to see how we can start building this API and how we're going to store

09:53.750 --> 09:56.520
the stuff in the database and all that.

09:56.570 --> 10:00.320
So yeah we'll stop here and until the next video happy going.
