1
00:00:00,780 --> 00:00:05,580
Memi: The next topic we will discuss is the HTTP verbs.

2
00:00:05,580 --> 00:00:10,530
So what are actually the HTTP verbs in REST API?

3
00:00:10,530 --> 00:00:14,670
So the verbs set the action to be performed.

4
00:00:14,670 --> 00:00:18,120
So when REST API receives a request,

5
00:00:18,120 --> 00:00:22,350
it first looks at the verb and can decide

6
00:00:22,350 --> 00:00:24,360
what is the actual action

7
00:00:24,360 --> 00:00:27,450
that should be performed with the resource.

8
00:00:27,450 --> 00:00:29,190
Now, when talking about actions,

9
00:00:29,190 --> 00:00:32,250
there are usually four types of actions

10
00:00:32,250 --> 00:00:35,580
that are made or executed in REST API.

11
00:00:35,580 --> 00:00:40,440
These actions are retrieve a resource,

12
00:00:40,440 --> 00:00:44,700
add a resource, update a resource,

13
00:00:44,700 --> 00:00:47,820
and delete a resource.

14
00:00:47,820 --> 00:00:50,490
Now these four actions are so common

15
00:00:50,490 --> 00:00:52,380
in data-oriented applications

16
00:00:52,380 --> 00:00:56,790
that they have their own acronym, which is CRUD.

17
00:00:56,790 --> 00:01:01,790
And CRUD stands for create, read, update, and delete.

18
00:01:02,670 --> 00:01:06,000
These are the four actions that you will usually execute

19
00:01:06,000 --> 00:01:09,720
on data or information in information systems,

20
00:01:09,720 --> 00:01:14,310
and you will probably stumble across this acronym, the CRUD.

21
00:01:14,310 --> 00:01:17,370
So if you do, then simply remember what it means.

22
00:01:17,370 --> 00:01:21,123
Again, create, read, update, and delete.

23
00:01:22,170 --> 00:01:25,920
Now, HTTP verbs are not an invention

24
00:01:25,920 --> 00:01:28,290
made specifically for REST API.

25
00:01:28,290 --> 00:01:30,930
It's actually part of the HTTP standard.

26
00:01:30,930 --> 00:01:32,460
You can take a look here,

27
00:01:32,460 --> 00:01:34,440
and I know it's quite a long paragraph

28
00:01:34,440 --> 00:01:36,150
and a little bit complicated,

29
00:01:36,150 --> 00:01:38,520
but you can look here at the HTTP standard,

30
00:01:38,520 --> 00:01:41,820
and you can find it at the URL at the bottom of the page.

31
00:01:41,820 --> 00:01:42,990
And in this case,

32
00:01:42,990 --> 00:01:46,860
this is the paragraph that deals with the GET verb.

33
00:01:46,860 --> 00:01:48,720
There are actually a lot more verbs,

34
00:01:48,720 --> 00:01:51,420
although GET is the most common one.

35
00:01:51,420 --> 00:01:53,280
So you can see that the verbs

36
00:01:53,280 --> 00:01:55,800
are actually part of the HTTP standard,

37
00:01:55,800 --> 00:01:59,160
and this is actually one of the design goals of the REST

38
00:01:59,160 --> 00:02:01,080
because REST, from the start,

39
00:02:01,080 --> 00:02:03,810
tried to take advantage of existing standards

40
00:02:03,810 --> 00:02:05,700
and not invent new ones.

41
00:02:05,700 --> 00:02:08,610
So it uses the HTTP verb as a sign

42
00:02:08,610 --> 00:02:11,160
of the action that should be made.

43
00:02:11,160 --> 00:02:14,130
Now HTTP verbs are extremely important

44
00:02:14,130 --> 00:02:18,270
and you should always, always use the correct verb.

45
00:02:18,270 --> 00:02:21,360
One of the most common mistakes of Juno developers

46
00:02:21,360 --> 00:02:24,690
is to always use the GET verb,

47
00:02:24,690 --> 00:02:26,190
even when it's not relevant

48
00:02:26,190 --> 00:02:29,550
and completely misses the mark on the specific action

49
00:02:29,550 --> 00:02:30,930
that should be made.

50
00:02:30,930 --> 00:02:35,370
So when creating REST API, always use the correct verb,

51
00:02:35,370 --> 00:02:38,880
and we will explore those verbs later in this section.

52
00:02:38,880 --> 00:02:43,140
Now also remember that HTTP verbs improve readability.

53
00:02:43,140 --> 00:02:46,530
For example, if you look at URL in REST API,

54
00:02:46,530 --> 00:02:49,320
and you note the verb at the beginning of it,

55
00:02:49,320 --> 00:02:52,890
then you have a general idea of what this API should do.

56
00:02:52,890 --> 00:02:55,800
So for example, if you see a REST API beginning

57
00:02:55,800 --> 00:02:58,440
with GET as the HTTP verb,

58
00:02:58,440 --> 00:03:00,780
then you already know without looking at the code

59
00:03:00,780 --> 00:03:03,090
what this specific API is expected to do.

60
00:03:03,090 --> 00:03:08,090
And that will be probably retrieving or getting a resource.

61
00:03:08,250 --> 00:03:12,150
So HTTP verb must be treated as part of the URL.

62
00:03:12,150 --> 00:03:16,380
It's not some bizarre detail that no one is talking about.

63
00:03:16,380 --> 00:03:19,470
It is an extremely important part of the URL

64
00:03:19,470 --> 00:03:21,600
and should be treated like that.

65
00:03:21,600 --> 00:03:23,310
So with that in mind,

66
00:03:23,310 --> 00:03:25,410
let's deep dive into the various verbs

67
00:03:25,410 --> 00:03:27,090
that we will use in REST,

68
00:03:27,090 --> 00:03:29,373
and we will begin with the GET verb.

