1
00:00:00,360 --> 00:00:02,280
Memi: The next part in the URL

2
00:00:02,280 --> 00:00:04,260
is the entity.

3
00:00:04,260 --> 00:00:06,750
But first, a quick reminder:

4
00:00:06,750 --> 00:00:08,520
As you probably remember,

5
00:00:08,520 --> 00:00:12,570
REST deals with resources or entities.

6
00:00:12,570 --> 00:00:16,470
So REST API should represent a resource,

7
00:00:16,470 --> 00:00:19,653
and not an action, or a method-ing.

8
00:00:20,610 --> 00:00:23,460
And the main part of REST API

9
00:00:23,460 --> 00:00:27,900
is always the entity that it deals with.

10
00:00:27,900 --> 00:00:29,760
So, with that in mind,

11
00:00:29,760 --> 00:00:31,710
the next part of the URL

12
00:00:31,710 --> 00:00:34,920
is the entity we are going to deal with.

13
00:00:34,920 --> 00:00:36,780
Now, to make the URL

14
00:00:36,780 --> 00:00:38,250
as simple as possible,

15
00:00:38,250 --> 00:00:42,360
we will always strive to use only one word

16
00:00:42,360 --> 00:00:43,710
as the entity name.

17
00:00:43,710 --> 00:00:45,840
We don't want to make it a complicated

18
00:00:45,840 --> 00:00:48,570
and incomprehensible URL,

19
00:00:48,570 --> 00:00:49,920
and we would like the developer

20
00:00:49,920 --> 00:00:51,960
to be able to understand immediately

21
00:00:51,960 --> 00:00:54,990
what entity is the URL dealing with.

22
00:00:54,990 --> 00:00:57,060
Now, another thing to keep in mind,

23
00:00:57,060 --> 00:01:00,180
is that never use a verb

24
00:01:00,180 --> 00:01:01,200
in the URL,

25
00:01:01,200 --> 00:01:02,760
instead of the entity.

26
00:01:02,760 --> 00:01:05,617
So, we don't want to see things like,

27
00:01:05,617 --> 00:01:06,600
"do that"

28
00:01:06,600 --> 00:01:07,980
or "go there"

29
00:01:07,980 --> 00:01:10,020
or "save this".

30
00:01:10,020 --> 00:01:12,210
Only nouns,

31
00:01:12,210 --> 00:01:14,070
entities, resources,

32
00:01:14,070 --> 00:01:15,630
never verb.

33
00:01:15,630 --> 00:01:17,040
And, why is that?

34
00:01:17,040 --> 00:01:20,820
Because, the verb part of the URL

35
00:01:20,820 --> 00:01:23,940
is actually implemented with the HTTP verb,

36
00:01:23,940 --> 00:01:25,650
which we discussed earlier.

37
00:01:25,650 --> 00:01:27,720
So the HTTP verb

38
00:01:27,720 --> 00:01:31,620
provides the action that we want to run,

39
00:01:31,620 --> 00:01:34,440
and the URL provides the entity

40
00:01:34,440 --> 00:01:37,173
that we want to execute the action on.

41
00:01:38,220 --> 00:01:42,240
So, let's see some examples of valid URL.

42
00:01:42,240 --> 00:01:43,803
So, this is the first one,

43
00:01:45,060 --> 00:01:45,900
and what we see here

44
00:01:45,900 --> 00:01:49,050
is "api/v1/order",

45
00:01:49,050 --> 00:01:52,500
so in this case, the entity is "order".

46
00:01:52,500 --> 00:01:57,450
In this example, the entity is "employees".

47
00:01:57,450 --> 00:01:59,640
And also in this example,

48
00:01:59,640 --> 00:02:02,190
the entity is "travel".

49
00:02:02,190 --> 00:02:05,310
Now, notice that in all those examples,

50
00:02:05,310 --> 00:02:08,060
we prefix the entity with the API

51
00:02:08,060 --> 00:02:11,850
in the version just as discussed earlier.

52
00:02:11,850 --> 00:02:12,683
Okay,

53
00:02:12,683 --> 00:02:14,520
so let's add the entity

54
00:02:14,520 --> 00:02:16,353
to the URL we are building.

55
00:02:18,120 --> 00:02:19,980
So here, we are in Beeceptor,

56
00:02:19,980 --> 00:02:23,580
and this is the URL text box;

57
00:02:23,580 --> 00:02:26,220
we already have the API and the version,

58
00:02:26,220 --> 00:02:29,400
and now we will add the entity,

59
00:02:29,400 --> 00:02:32,940
and let's use the "order" entity.

60
00:02:32,940 --> 00:02:36,420
So, when a developer sees this URL,

61
00:02:36,420 --> 00:02:38,010
she immediately understands

62
00:02:38,010 --> 00:02:42,120
that this API deals with the order entity,

63
00:02:42,120 --> 00:02:44,490
and together with the method here,

64
00:02:44,490 --> 00:02:48,030
then she immediately sees that this API

65
00:02:48,030 --> 00:02:50,820
gets an order.

66
00:02:50,820 --> 00:02:54,390
Note how simple and how readable this URL is,

67
00:02:54,390 --> 00:02:57,540
and always try to make your URLs

68
00:02:57,540 --> 00:02:58,833
as simple as that.

