1
00:00:00,450 --> 00:00:05,160
-: So we talked about the basic principles of what is an API

2
00:00:05,160 --> 00:00:08,460
but another thing that is important to know about API

3
00:00:08,460 --> 00:00:10,890
is that it comes in few flavors

4
00:00:10,890 --> 00:00:14,193
and actually there are four main types of API.

5
00:00:15,060 --> 00:00:20,060
The first type is Operating System API, next Library API

6
00:00:21,540 --> 00:00:26,540
then Remote API, and last, Web API.

7
00:00:27,270 --> 00:00:28,920
Let's dive deeper into each one of them

8
00:00:28,920 --> 00:00:30,663
and explain what is it.

9
00:00:31,560 --> 00:00:33,900
So Operating System API.

10
00:00:33,900 --> 00:00:36,420
Let's say you write some kind of application.

11
00:00:36,420 --> 00:00:38,460
It it doesn't really matter which platform

12
00:00:38,460 --> 00:00:40,260
you are using to write this application

13
00:00:40,260 --> 00:00:43,860
it can be .Net or Java or c++ or whatever.

14
00:00:43,860 --> 00:00:46,380
Now, naturally, your application runs

15
00:00:46,380 --> 00:00:48,270
inside an operating system.

16
00:00:48,270 --> 00:00:51,300
Again, it doesn't matter which operating system.

17
00:00:51,300 --> 00:00:55,293
iI could be Windows or Linux or OASIS or anything else.

18
00:00:56,460 --> 00:01:00,870
In many cases, the application needs some kind of services

19
00:01:00,870 --> 00:01:02,790
from the operating system.

20
00:01:02,790 --> 00:01:05,099
For example, file system.

21
00:01:05,099 --> 00:01:08,370
If the application wants to access files

22
00:01:08,370 --> 00:01:11,970
in the operating system, it asks the operating system

23
00:01:11,970 --> 00:01:15,150
to give it access to the files.

24
00:01:15,150 --> 00:01:17,040
Network devices.

25
00:01:17,040 --> 00:01:19,950
If the application needs to access network devices

26
00:01:19,950 --> 00:01:21,930
connected to the operating system,

27
00:01:21,930 --> 00:01:24,960
then the operating system should allow it.

28
00:01:24,960 --> 00:01:26,520
User interface elements.

29
00:01:26,520 --> 00:01:29,880
If the application, for example, wants to display a button

30
00:01:29,880 --> 00:01:33,060
on the screen, then it asks the operating system

31
00:01:33,060 --> 00:01:36,000
for a visual representation of the button.

32
00:01:36,000 --> 00:01:37,950
So how does it do that?

33
00:01:37,950 --> 00:01:41,070
How the application asks the operating system

34
00:01:41,070 --> 00:01:43,230
for all those kind of services?

35
00:01:43,230 --> 00:01:45,360
Well, the answer, as you probably guessed

36
00:01:45,360 --> 00:01:48,030
is using the operating system API.

37
00:01:48,030 --> 00:01:51,750
The operating system or the operating systems

38
00:01:51,750 --> 00:01:53,550
exposed some kind of API

39
00:01:53,550 --> 00:01:56,670
that applications that run in the operating system

40
00:01:56,670 --> 00:01:58,110
can access and use.

41
00:01:58,110 --> 00:02:01,189
And one of the most famous operating system API

42
00:02:01,189 --> 00:02:03,330
is the win32 API.

43
00:02:03,330 --> 00:02:07,110
It is used by all the applications that run on Windows

44
00:02:07,110 --> 00:02:10,893
and it provides a huge number of operating system services.

45
00:02:12,630 --> 00:02:14,040
Okay, next.

46
00:02:14,040 --> 00:02:18,570
So the next type of API is the Library API.

47
00:02:18,570 --> 00:02:20,550
And what it means is this.

48
00:02:20,550 --> 00:02:22,470
When you develop your application,

49
00:02:22,470 --> 00:02:24,960
you probably use some kind of libraries.

50
00:02:24,960 --> 00:02:27,270
The concept of libraries is very common

51
00:02:27,270 --> 00:02:29,880
in all the development platforms today.

52
00:02:29,880 --> 00:02:33,540
So you develop your library, let's call it Users library,

53
00:02:33,540 --> 00:02:37,350
and there is another library called Logging library.

54
00:02:37,350 --> 00:02:41,550
Now the user library wants to use the logging library.

55
00:02:41,550 --> 00:02:42,870
How can it do that?

56
00:02:42,870 --> 00:02:47,870
Simply, the logging library exposes logging API,

57
00:02:48,150 --> 00:02:51,840
and by doing so, it allows the user's library

58
00:02:51,840 --> 00:02:56,130
to access this API and use logging library's method

59
00:02:56,130 --> 00:02:59,820
such as right to log file or change the severity

60
00:02:59,820 --> 00:03:02,100
of the logging or anything else.

61
00:03:02,100 --> 00:03:04,530
But without an API, the users library

62
00:03:04,530 --> 00:03:07,140
won't be able to access the logging library.

63
00:03:07,140 --> 00:03:10,080
Now note again that those libraries

64
00:03:10,080 --> 00:03:13,860
they are both executed in the same single process.

65
00:03:13,860 --> 00:03:16,953
They are not communicating through any kind of network.

66
00:03:18,240 --> 00:03:21,780
As mentioned earlier, class libraries are implemented in

67
00:03:21,780 --> 00:03:24,060
all kinds of development platforms like

68
00:03:24,060 --> 00:03:27,600
as we said, .NET, Java, Python, nodeJs

69
00:03:27,600 --> 00:03:30,453
and even PHP and so on and so forth.

70
00:03:31,470 --> 00:03:36,470
Okay, so the next type of API is Remote API.

71
00:03:38,400 --> 00:03:41,940
Now what it means is this, we have two software components.

72
00:03:41,940 --> 00:03:45,840
Let's say these are User component and Orders component.

73
00:03:45,840 --> 00:03:48,390
Now note that those two components

74
00:03:48,390 --> 00:03:50,310
are distributed over the network,

75
00:03:50,310 --> 00:03:52,890
meaning they are not in the same process

76
00:03:52,890 --> 00:03:55,530
and probably also not on the same server

77
00:03:55,530 --> 00:03:58,110
or virtual machine or PC.

78
00:03:58,110 --> 00:04:00,390
In order for them to communicate with each other

79
00:04:00,390 --> 00:04:02,580
they need to go through the network.

80
00:04:02,580 --> 00:04:03,730
So how do they do that?

81
00:04:05,371 --> 00:04:09,000
So the User component build an Orders proxy.

82
00:04:09,000 --> 00:04:12,060
This proxy is used to communicate with the Orders component.

83
00:04:12,060 --> 00:04:15,150
This proxy contains all the internal working

84
00:04:15,150 --> 00:04:17,010
of accessing the Orders component.

85
00:04:17,010 --> 00:04:19,380
It knows everything there is to know about

86
00:04:19,380 --> 00:04:21,899
how to access the component, such as

87
00:04:21,899 --> 00:04:25,410
network protocol, network address, methods, signatures,

88
00:04:25,410 --> 00:04:28,380
authentication, authorization, everything that is important

89
00:04:28,380 --> 00:04:30,720
in order to access this component.

90
00:04:30,720 --> 00:04:33,660
So after building this proxy, the Orders proxy

91
00:04:33,660 --> 00:04:37,830
can access the Orders component using proprietary protocol

92
00:04:37,830 --> 00:04:39,450
and access the method

93
00:04:39,450 --> 00:04:43,290
and all the other functionality exposed by this component.

94
00:04:43,290 --> 00:04:44,940
Now, what is important to know

95
00:04:44,940 --> 00:04:48,720
about this method of communication, the remote API

96
00:04:48,720 --> 00:04:50,610
is that in it mandates

97
00:04:50,610 --> 00:04:52,470
that both the components will be based

98
00:04:52,470 --> 00:04:55,470
on the same development platform.

99
00:04:55,470 --> 00:04:58,410
For example, it's not possible in this example,

100
00:04:58,410 --> 00:05:01,200
that the user component will be developed using .net

101
00:05:01,200 --> 00:05:03,960
and the orders component will be developed in Python.

102
00:05:03,960 --> 00:05:06,090
It'll simply won't work.

103
00:05:06,090 --> 00:05:10,350
Examples of such a Remote API implementations are

104
00:05:10,350 --> 00:05:15,150
DCOM, .NET Remoting, Java RMI, and there are some more.

105
00:05:15,150 --> 00:05:17,040
Its also important to note that

106
00:05:17,040 --> 00:05:19,170
Remote API is losing popularity

107
00:05:19,170 --> 00:05:21,903
and almost no one is using them nowadays.

108
00:05:22,740 --> 00:05:25,620
And that brings us to the last

109
00:05:25,620 --> 00:05:29,310
and definitely not the least kind of API,

110
00:05:29,310 --> 00:05:31,620
which is the Web API.

111
00:05:31,620 --> 00:05:35,340
With Web API, web apps and web APIs

112
00:05:35,340 --> 00:05:38,460
can communicate with each other over the internet

113
00:05:38,460 --> 00:05:40,410
and here is how it works.

114
00:05:40,410 --> 00:05:42,600
So we are looking at the internet

115
00:05:42,600 --> 00:05:44,760
and we have some kind of web app

116
00:05:44,760 --> 00:05:47,070
which we developed and published over the internet.

117
00:05:47,070 --> 00:05:51,060
This web app wants to use another web apps, let's say

118
00:05:51,060 --> 00:05:54,030
weather web app, which provides weather forecast

119
00:05:54,030 --> 00:05:56,009
for destinations that we are interested in.

120
00:05:56,009 --> 00:05:59,793
How can my web app communicate with the weather web app?

121
00:06:00,720 --> 00:06:02,550
So there are a few steps for this.

122
00:06:02,550 --> 00:06:06,840
First, the weather web app should expose, and again

123
00:06:06,840 --> 00:06:09,600
not the use of the word expose.

124
00:06:09,600 --> 00:06:11,973
It exposes Web API.

125
00:06:13,680 --> 00:06:17,400
Then my web app can access this web API

126
00:06:17,400 --> 00:06:19,950
and it can do it because the web API

127
00:06:19,950 --> 00:06:23,580
always uses standard protocol for accessing it.

128
00:06:23,580 --> 00:06:27,810
And using this protocol, my web app can access this web API

129
00:06:27,810 --> 00:06:31,530
and query the weather web app for weather forecast.

130
00:06:31,530 --> 00:06:33,810
Now, one of the most important thing to know

131
00:06:33,810 --> 00:06:37,110
about the web API is that it can be used

132
00:06:37,110 --> 00:06:40,980
across any platform, operating system, or language.

133
00:06:40,980 --> 00:06:42,030
In other words,

134
00:06:42,030 --> 00:06:44,843
it doesn't really matter how my web app is implemented

135
00:06:44,843 --> 00:06:47,580
and how the weather web app is implemented.

136
00:06:47,580 --> 00:06:50,340
If you remember, we say that we Remote API,

137
00:06:50,340 --> 00:06:53,250
both the software components must be developed

138
00:06:53,250 --> 00:06:54,810
using the same platform.

139
00:06:54,810 --> 00:06:57,270
This is not the case with Web API.

140
00:06:57,270 --> 00:07:00,810
In this example, my web app can be developed using .NET

141
00:07:00,810 --> 00:07:03,930
and the weather web app can be developed using Java

142
00:07:03,930 --> 00:07:05,700
and it'll work just fine.

143
00:07:05,700 --> 00:07:08,850
This is just one of the factors that make Web API

144
00:07:08,850 --> 00:07:11,433
so successful and so popular.

