1
00:00:02,120 --> 00:00:03,810
Now in this core section,

2
00:00:03,810 --> 00:00:06,770
I want to start with a very important question.

3
00:00:06,770 --> 00:00:10,125
What exactly are services and APIs no matter

4
00:00:10,125 --> 00:00:13,170
if we're talking about a third party services,

5
00:00:13,170 --> 00:00:15,690
or custom build services,

6
00:00:15,690 --> 00:00:18,680
we'll discuss the latter once in a later course section,

7
00:00:18,680 --> 00:00:22,370
but what are services and APIs to begin with?

8
00:00:22,370 --> 00:00:24,660
Well, when it comes to services,

9
00:00:24,660 --> 00:00:26,140
you can really take that word.

10
00:00:26,140 --> 00:00:30,187
Literally services are just debt services that you can use

11
00:00:30,187 --> 00:00:34,410
in your projects and websites to enhance these projects and

12
00:00:34,410 --> 00:00:36,500
websites. Like for example,

13
00:00:36,500 --> 00:00:39,433
a third party service that helps us handle credit card

14
00:00:39,433 --> 00:00:43,010
payments. That makes that much easier for us,

15
00:00:43,010 --> 00:00:47,240
but we don't have to start with such more complex services

16
00:00:47,240 --> 00:00:49,480
like handling credit card payments.

17
00:00:49,480 --> 00:00:52,890
We can actually have a look at services if you want to call

18
00:00:52,890 --> 00:00:55,590
them such that we have been using throughout,

19
00:00:55,590 --> 00:00:57,010
this course already.

20
00:00:57,010 --> 00:00:58,420
And that would, for example,

21
00:00:58,420 --> 00:01:02,317
be third party packages like Axiom, which we haven't used,

22
00:01:02,317 --> 00:01:06,870
but which has showed you or express or be crypt or the Mongo

23
00:01:06,870 --> 00:01:07,950
DB package,

24
00:01:07,950 --> 00:01:10,840
all those packages that we have been using throughout the

25
00:01:10,840 --> 00:01:15,840
discourse section, we used such packages like for example,

26
00:01:16,030 --> 00:01:19,860
express so that we could have an easier time handling

27
00:01:19,860 --> 00:01:23,340
incoming requests and sending back responses so that we

28
00:01:23,340 --> 00:01:27,010
don't have to write all the low-level code ourselves so that

29
00:01:27,010 --> 00:01:30,227
we don't have to reinvent the wheel all the time and write

30
00:01:30,227 --> 00:01:33,980
all the functionalities that we might need on our own.

31
00:01:33,980 --> 00:01:36,510
But so that we can instead use a package,

32
00:01:36,510 --> 00:01:40,050
which solves a certain problem for us. For example,

33
00:01:40,050 --> 00:01:43,363
the B crypt package solves the problem of hashing passwords,

34
00:01:43,363 --> 00:01:46,133
and we can then just use that package and its functionality,

35
00:01:46,133 --> 00:01:51,133
and don't care about how it solves that problem in any way.

36
00:01:51,330 --> 00:01:56,050
And that is why we use services like third party packages.

37
00:01:56,050 --> 00:02:00,230
Now, thus far, I always called the dose packages packages,

38
00:02:00,230 --> 00:02:03,730
but we could also call them services because clearly those

39
00:02:03,730 --> 00:02:07,210
packages provide a service to us. And to our website,

40
00:02:07,210 --> 00:02:10,639
the B trip package provides the service of making hash

41
00:02:10,639 --> 00:02:12,320
and passwords easy.

42
00:02:12,320 --> 00:02:13,400
Now packages,

43
00:02:13,400 --> 00:02:16,780
aren't the only kind of service you could integrate into a

44
00:02:16,780 --> 00:02:19,460
website. And indeed, in this course section,

45
00:02:19,460 --> 00:02:22,996
we are going to have a look at a different kind of service,

46
00:02:22,996 --> 00:02:23,829
for example,

47
00:02:23,829 --> 00:02:27,140
another service that you could use in your website to add

48
00:02:27,140 --> 00:02:30,320
a certain feature would be Google maps,

49
00:02:30,320 --> 00:02:33,580
the Google maps API specifically though I will come back to

50
00:02:33,580 --> 00:02:36,370
what API means in just a second.

51
00:02:36,370 --> 00:02:38,680
We all of course know Google maps,

52
00:02:38,680 --> 00:02:41,130
but besides the Google maps, which you know,

53
00:02:41,130 --> 00:02:44,958
and probably use every day on their website or in their

54
00:02:44,958 --> 00:02:46,259
mobile app,

55
00:02:46,259 --> 00:02:50,470
they're actually also is a service the maps platform,

56
00:02:50,470 --> 00:02:53,921
which you can use as a developer to integrate maps into your

57
00:02:53,921 --> 00:02:58,312
app because you might be building a mobile app maybe,

58
00:02:58,312 --> 00:03:02,590
or website that should show some maps.

59
00:03:02,590 --> 00:03:03,423
For example,

60
00:03:03,423 --> 00:03:08,423
if you are using Airbnb and you choose some category there,

61
00:03:08,900 --> 00:03:13,350
you also are presented with a map and this is actually

62
00:03:13,350 --> 00:03:15,580
powered by Google maps.

63
00:03:15,580 --> 00:03:18,936
Airbnb did not build their own map service.

64
00:03:18,936 --> 00:03:20,670
If you think about it,

65
00:03:20,670 --> 00:03:23,830
that would be super complex because it's not just about the

66
00:03:23,830 --> 00:03:24,820
graphics here.

67
00:03:24,820 --> 00:03:27,080
It is about getting all the data for that map,

68
00:03:27,080 --> 00:03:30,020
all the names of the streets and off the cities and the

69
00:03:30,020 --> 00:03:31,800
shops to which are there.

70
00:03:31,800 --> 00:03:36,520
So therefore Airbnb uses to Google maps platform so that

71
00:03:36,520 --> 00:03:39,920
they can get all the data from Google so that they can get

72
00:03:39,920 --> 00:03:41,970
the map rendering by Google.

73
00:03:41,970 --> 00:03:45,520
And they can focus on enriching that map with their own

74
00:03:45,520 --> 00:03:49,910
data, which an Airbnb's case is about vacation rentals,

75
00:03:49,910 --> 00:03:52,760
rooms, apartments, and so on.

76
00:03:52,760 --> 00:03:53,950
Uber would be another,

77
00:03:53,950 --> 00:03:57,330
a very popular website and app that you might know that

78
00:03:57,330 --> 00:04:00,343
leverage is to Google maps, API to show a map.

79
00:04:01,260 --> 00:04:04,890
So Google maps is a great example for a service that is

80
00:04:04,890 --> 00:04:07,160
provided by another company, Google,

81
00:04:07,160 --> 00:04:11,560
in this case to any developer who wants to integrate maps

82
00:04:11,560 --> 00:04:13,011
into their websites.

83
00:04:13,011 --> 00:04:15,430
Now, when it comes to Google maps,

84
00:04:15,430 --> 00:04:17,040
if you check out the pricing,

85
00:04:17,040 --> 00:04:19,899
you'll learn that you can get started for free.

86
00:04:19,899 --> 00:04:23,410
There is some free credit, which you can use every month,

87
00:04:23,410 --> 00:04:26,160
but from a certain point on you'll have to pay.

88
00:04:26,160 --> 00:04:29,451
And that's quite typical for us services whilst there are

89
00:04:29,451 --> 00:04:34,130
free services and especially a third party packages are

90
00:04:34,130 --> 00:04:37,711
often free to use services like Google maps or in general

91
00:04:37,711 --> 00:04:42,711
more complex services where you rely on data and logic

92
00:04:42,970 --> 00:04:46,230
provided by another company may be free,

93
00:04:46,230 --> 00:04:49,070
but often they actually cost money.

94
00:04:49,070 --> 00:04:49,903
So you,

95
00:04:49,903 --> 00:04:53,720
as a developer can pay these companies to use their services

96
00:04:53,720 --> 00:04:57,566
in your website. And that's a quite common use case.

97
00:04:57,566 --> 00:05:01,090
And now, for example, for such a third-party service,

98
00:05:01,090 --> 00:05:03,960
which you could use would be Google analytics,

99
00:05:03,960 --> 00:05:07,010
which is an analytics service provided by Google,

100
00:05:07,010 --> 00:05:10,520
which helps you collect data about your website visitors,

101
00:05:10,520 --> 00:05:14,320
and which gives you a dashboard and a user interface for

102
00:05:14,320 --> 00:05:16,520
browsing these analytics.

103
00:05:16,520 --> 00:05:19,330
But of course there also are services offered by other

104
00:05:19,330 --> 00:05:21,880
companies. Then Google, for example,

105
00:05:21,880 --> 00:05:24,070
there is a company called Stripe,

106
00:05:24,070 --> 00:05:26,640
which offers a payments service.

107
00:05:26,640 --> 00:05:29,630
And indeed Stripe is the service at which we'll have a

108
00:05:29,630 --> 00:05:33,030
closer look throughout the discourse section because they

109
00:05:33,030 --> 00:05:34,640
offer many products,

110
00:05:34,640 --> 00:05:37,750
many different kinds of services you could say,

111
00:05:37,750 --> 00:05:40,650
and we're going to use the payments service for all the dis

112
00:05:40,650 --> 00:05:42,830
section to add payments,

113
00:05:42,830 --> 00:05:45,496
credit card payments and handling such payments to our

114
00:05:45,496 --> 00:05:49,550
website so that we don't have to write all the logic for it

115
00:05:49,550 --> 00:05:50,650
as ourselves,

116
00:05:50,650 --> 00:05:53,424
so that we don't have to negotiate contracts with credit

117
00:05:53,424 --> 00:05:55,230
card providers,

118
00:05:55,230 --> 00:05:58,587
but that we can instead use Stripe to easily handle customer

119
00:05:58,587 --> 00:06:01,480
payments in our website.

120
00:06:01,480 --> 00:06:04,791
So using such services is a really common thing.

121
00:06:04,791 --> 00:06:06,300
And as a side note, it,

122
00:06:06,300 --> 00:06:08,715
of course also means that as a web developer,

123
00:06:08,715 --> 00:06:13,270
you could not just earn money by building websites or

124
00:06:13,270 --> 00:06:14,920
selling products on websites.

125
00:06:14,920 --> 00:06:18,520
You could also build a service that provides a really useful

126
00:06:18,520 --> 00:06:20,570
kind of service,

127
00:06:20,570 --> 00:06:23,078
and you could make that a paid service and then offer that

128
00:06:23,078 --> 00:06:26,080
service to other developers and companies.

129
00:06:26,080 --> 00:06:27,240
So as a web developer,

130
00:06:27,240 --> 00:06:30,200
you could also be building such services.

131
00:06:30,200 --> 00:06:32,731
And especially if you keep in mind that there are not just

132
00:06:32,731 --> 00:06:34,430
websites out there,

133
00:06:34,430 --> 00:06:38,160
but also many mobile apps that might need certain features

134
00:06:38,160 --> 00:06:39,140
in their apps.

135
00:06:39,140 --> 00:06:42,112
There is a broad customer base that could be interested in

136
00:06:42,112 --> 00:06:44,000
your services.

137
00:06:44,000 --> 00:06:47,510
Now we're going to have a look at building custom services

138
00:06:47,510 --> 00:06:50,161
and API APIs later in the course section in this core

139
00:06:50,161 --> 00:06:50,994
section,

140
00:06:50,994 --> 00:06:54,130
I just want to introduce you to this feature and especially

141
00:06:54,130 --> 00:06:56,010
show an example, Stripe,

142
00:06:56,010 --> 00:06:58,573
to be precise so that you see how you could use such

143
00:06:58,573 --> 00:07:02,490
services, but that's services.

144
00:07:02,490 --> 00:07:04,860
What are API then?

145
00:07:04,860 --> 00:07:06,510
Well, when it comes to APIs,

146
00:07:06,510 --> 00:07:09,568
it's important to understand that all those services,

147
00:07:09,568 --> 00:07:14,220
no matter if we are talking about a third party package or

148
00:07:14,220 --> 00:07:16,157
something like Google maps or Stripe,

149
00:07:16,157 --> 00:07:21,157
all those services in the end provide certain actions or

150
00:07:21,170 --> 00:07:25,180
so-called end points that we can access from inside our

151
00:07:25,180 --> 00:07:26,310
code.

152
00:07:26,310 --> 00:07:29,090
If you have a look at the express package, again,

153
00:07:29,090 --> 00:07:32,170
for example, by visiting their official website,

154
00:07:32,170 --> 00:07:34,490
then you will notice that on their website,

155
00:07:34,490 --> 00:07:37,123
they actually have an API reference.

156
00:07:38,270 --> 00:07:39,850
Now this is in the end,

157
00:07:39,850 --> 00:07:44,850
just a list of documentation of all the methods and features

158
00:07:45,060 --> 00:07:48,610
offered by express and how you use them in your code.

159
00:07:48,610 --> 00:07:49,640
For example,

160
00:07:49,640 --> 00:07:52,630
that you can use the Jason method to get a middleware that

161
00:07:52,630 --> 00:07:55,350
parses Jason request bodies.

162
00:07:55,350 --> 00:07:58,440
It's a feature we use before in this course that we can call

163
00:07:58,440 --> 00:08:02,530
the router method to get a router and never featured,

164
00:08:02,530 --> 00:08:04,543
which we used for all the discourse.

165
00:08:05,400 --> 00:08:06,910
So in the end,

166
00:08:06,910 --> 00:08:11,466
an API is really just a collection and a description of all

167
00:08:11,466 --> 00:08:15,870
the methods that we can call on a third-party package.

168
00:08:15,870 --> 00:08:17,880
It's a documentation off the code.

169
00:08:17,880 --> 00:08:21,750
We can write using a third-party package to use the various

170
00:08:21,750 --> 00:08:26,220
features off that third-party package or in case of Google

171
00:08:26,220 --> 00:08:27,053
maps.

172
00:08:27,053 --> 00:08:31,040
It's a documentation of the various features you can use

173
00:08:31,040 --> 00:08:33,299
from that service there.

174
00:08:33,299 --> 00:08:35,350
If you have a look at the documentation,

175
00:08:35,350 --> 00:08:38,809
you'll find various pieces of documentation and you,

176
00:08:38,809 --> 00:08:39,643
for example,

177
00:08:39,643 --> 00:08:43,120
all defined a JavaScript package that's provided by Google,

178
00:08:43,120 --> 00:08:45,968
which you can download and integrate into your website.

179
00:08:45,968 --> 00:08:47,290
And then again,

180
00:08:47,290 --> 00:08:50,330
a description of how to use that package and which methods

181
00:08:50,330 --> 00:08:55,060
or constructors or properties it provides,

182
00:08:55,060 --> 00:08:57,060
but you could also have an API.

183
00:08:57,060 --> 00:09:00,250
That's actually not a description of a third-party package,

184
00:09:00,250 --> 00:09:01,120
but instead,

185
00:09:01,120 --> 00:09:06,120
a list of URLs to which you can send requests and

186
00:09:06,510 --> 00:09:09,330
then a description of how these requests should be

187
00:09:09,330 --> 00:09:10,300
formatted,

188
00:09:10,300 --> 00:09:13,340
which parameters and query parameters you might need to

189
00:09:13,340 --> 00:09:15,970
provide, or which requests bodies,

190
00:09:15,970 --> 00:09:18,230
which HDP methods should be used.

191
00:09:18,230 --> 00:09:21,904
So a description of such URLs to which you can send requests

192
00:09:21,904 --> 00:09:25,370
because a service doesn't have to be a package.

193
00:09:25,370 --> 00:09:26,580
It sometimes is.

194
00:09:26,580 --> 00:09:30,340
And sometimes services like Google maps do provide packages,

195
00:09:30,340 --> 00:09:31,806
which you can add to your website,

196
00:09:31,806 --> 00:09:35,360
but a service can also provide access to its various

197
00:09:35,360 --> 00:09:38,800
features. By giving you a list of URLs,

198
00:09:38,800 --> 00:09:42,390
to which you can send the request from either the front end,

199
00:09:42,390 --> 00:09:45,490
with fetch or from the backend from node JS.

200
00:09:45,490 --> 00:09:47,390
You can also send requests there,

201
00:09:47,390 --> 00:09:49,610
even though we haven't done this in this course,

202
00:09:49,610 --> 00:09:52,860
but you can use packages like axial stair as well to send

203
00:09:52,860 --> 00:09:54,360
requests.

204
00:09:54,360 --> 00:09:57,750
And then these requests will give you responses.

205
00:09:57,750 --> 00:09:59,110
And for example, here,

206
00:09:59,110 --> 00:10:02,470
where I'm having a look at the description of the routes

207
00:10:02,470 --> 00:10:04,160
service provided by Google,

208
00:10:04,160 --> 00:10:08,070
I can send the request to get a description of the route

209
00:10:08,070 --> 00:10:10,790
between two points on a map.

210
00:10:10,790 --> 00:10:14,740
And then the response will contain data in the Jason format

211
00:10:14,740 --> 00:10:18,330
that I could use on my website to den well,

212
00:10:18,330 --> 00:10:22,280
show data about this route between these two destinations,

213
00:10:22,280 --> 00:10:23,570
for example.

214
00:10:23,570 --> 00:10:24,490
So in the end,

215
00:10:24,490 --> 00:10:27,400
no matter if it's through a third-party package,

216
00:10:27,400 --> 00:10:30,790
which we add to our code or through a bunch of URLs,

217
00:10:30,790 --> 00:10:33,790
to which we can send requests and where we then get back

218
00:10:33,790 --> 00:10:35,581
responses with some data,

219
00:10:35,581 --> 00:10:40,240
those services do provide these actions or endpoints,

220
00:10:40,240 --> 00:10:42,237
which we can access from inside our code.

221
00:10:42,237 --> 00:10:46,090
And it's always in the documentation of a service where we

222
00:10:46,090 --> 00:10:48,290
can learn how to use that service.

223
00:10:48,290 --> 00:10:50,266
If it gives us a package we can use,

224
00:10:50,266 --> 00:10:53,370
or if we should send requests to certain URLs.

225
00:10:54,280 --> 00:10:55,113
And in the end,

226
00:10:55,113 --> 00:10:58,480
it's this collection of actions and end points that makes up

227
00:10:58,480 --> 00:10:59,870
the so-called API,

228
00:10:59,870 --> 00:11:03,820
the application programming interface because of these

229
00:11:03,820 --> 00:11:05,090
actions or end points,

230
00:11:05,090 --> 00:11:08,610
which are clearly documented and which are not up to us,

231
00:11:08,610 --> 00:11:11,224
but which are instead clearly defined by the service

232
00:11:11,224 --> 00:11:12,304
provider.

233
00:11:12,304 --> 00:11:15,720
These are the actions or end points we have to target from

234
00:11:15,720 --> 00:11:18,648
inside our code to get a certain behavior or to get certain

235
00:11:18,648 --> 00:11:21,120
data.

236
00:11:21,120 --> 00:11:24,410
Because of course, if you are using a third-party service,

237
00:11:24,410 --> 00:11:28,540
it's not up to you as a developer to decide how you want to

238
00:11:28,540 --> 00:11:31,440
call a certain method that you want to execute.

239
00:11:31,440 --> 00:11:35,030
Instead you have to call and execute a method or send a

240
00:11:35,030 --> 00:11:39,960
request to our URL that is clearly defined and provided by

241
00:11:39,960 --> 00:11:42,890
the service provider. And they'll for debts, the API,

242
00:11:42,890 --> 00:11:46,190
this collections of actions and endpoints. And of course,

243
00:11:46,190 --> 00:11:48,100
all of the documentation then,

244
00:11:48,100 --> 00:11:51,650
because without documentation, as a user of a service,

245
00:11:51,650 --> 00:11:53,885
you wouldn't know how to use the service,

246
00:11:53,885 --> 00:11:57,810
which methods to call or where to send your age to the P

247
00:11:57,810 --> 00:11:59,013
requests to.

