1
00:00:00,240 --> 00:00:05,240
-: Our next topic is the URL structure of the API.

2
00:00:05,430 --> 00:00:08,160
So a quick reminder, if you remember

3
00:00:08,160 --> 00:00:11,850
this is how a typical API request looks like.

4
00:00:11,850 --> 00:00:14,010
We have the method which we discussed

5
00:00:14,010 --> 00:00:15,900
in the previous section,

6
00:00:15,900 --> 00:00:18,813
we have the headers, and we have the URL,

7
00:00:19,740 --> 00:00:21,480
and the URL is the part

8
00:00:21,480 --> 00:00:23,613
we are going to discuss in this section.

9
00:00:24,990 --> 00:00:28,440
So when talking about URL structure,

10
00:00:28,440 --> 00:00:31,560
we actually talking about the definition

11
00:00:31,560 --> 00:00:34,739
of the structure of the API's URL

12
00:00:34,739 --> 00:00:39,450
meaning what data should it contain, and in which order,

13
00:00:39,450 --> 00:00:41,823
and what is the importance of all this?

14
00:00:42,840 --> 00:00:47,613
So actually the URL is the most important part of the API.

15
00:00:47,613 --> 00:00:51,950
This is the first thing a developer using your API will see.

16
00:00:51,950 --> 00:00:55,830
And it will often be used to judge your API

17
00:00:55,830 --> 00:00:57,645
and it will be a major factor

18
00:00:57,645 --> 00:01:01,110
in the decision of whether to use it or not.

19
00:01:01,110 --> 00:01:05,880
So for these reasons, the URL must be well thought of.

20
00:01:05,880 --> 00:01:09,330
You cannot just slap some URL on your API

21
00:01:09,330 --> 00:01:13,770
and hope that users will come, because they simply won't.

22
00:01:13,770 --> 00:01:17,550
So what you should know about the URL is that

23
00:01:17,550 --> 00:01:20,100
it should be self-explanatory.

24
00:01:20,100 --> 00:01:24,000
So if a developer will look at the URL of the API

25
00:01:24,000 --> 00:01:25,650
he will be able to understand

26
00:01:25,650 --> 00:01:27,702
what exactly this API is doing,

27
00:01:27,702 --> 00:01:30,840
even without looking at the documentation.

28
00:01:30,840 --> 00:01:34,203
And, between us, nobody likes to read documentation.

29
00:01:35,340 --> 00:01:39,330
In addition, the URL should be consistent across the API.

30
00:01:39,330 --> 00:01:42,120
So if you decide on a specific template

31
00:01:42,120 --> 00:01:44,280
of how the API should look like,

32
00:01:44,280 --> 00:01:48,840
then all your APIs should be compliant with this template,

33
00:01:48,840 --> 00:01:51,690
and the URL should be predictable.

34
00:01:51,690 --> 00:01:54,120
So if a developer used your API

35
00:01:54,120 --> 00:01:57,008
for a specific result or specific action,

36
00:01:57,008 --> 00:02:01,007
and now she wants to use it for another action,

37
00:02:01,007 --> 00:02:04,290
then she should be able to roughly predict

38
00:02:04,290 --> 00:02:07,860
how the URL will look like for the other action.

39
00:02:07,860 --> 00:02:10,139
And when making the URL predictable,

40
00:02:10,139 --> 00:02:13,320
you will make your client's life much more easier,

41
00:02:13,320 --> 00:02:16,560
and you will have a better chance of them using it.

42
00:02:16,560 --> 00:02:20,910
So to summarize, your URL should be self explanatory,

43
00:02:20,910 --> 00:02:22,612
consistent, and predictable

44
00:02:22,612 --> 00:02:26,700
or no one will use it, because no one likes

45
00:02:26,700 --> 00:02:29,430
to use something that is incomprehensible

46
00:02:29,430 --> 00:02:31,083
or difficult to use.

47
00:02:32,250 --> 00:02:35,175
Okay, so now let's analyze the various components

48
00:02:35,175 --> 00:02:37,154
of the URL and explain how

49
00:02:37,154 --> 00:02:40,173
and well should they be implemented.

