1
00:00:01,200 --> 00:00:02,420
All right welcome back.

2
00:00:02,760 --> 00:00:07,940
So this topic this section that we're going to talk about is one of my favorite things to teach.

3
00:00:08,040 --> 00:00:09,860
It's really really fun for me.

4
00:00:09,900 --> 00:00:17,040
And I know I say that a few times in this course but this is by far the actual favorite topic of mine

5
00:00:18,120 --> 00:00:20,620
and it's really exciting to learn in my opinion.

6
00:00:20,640 --> 00:00:22,280
We're going to talk about A.P. guys.

7
00:00:22,530 --> 00:00:27,180
And the reason that it's exciting to learn is that it really opens up the possibilities for what you

8
00:00:27,180 --> 00:00:28,260
can build.

9
00:00:28,260 --> 00:00:34,950
You can make all sorts of amazing applications that use data from other applications or that rely on

10
00:00:34,950 --> 00:00:36,250
other applications.

11
00:00:36,360 --> 00:00:42,000
Basically you know you can stand on the shoulders of giants and and make some really awesome things

12
00:00:42,000 --> 00:00:45,910
for that having to do a ton of work and do everything yourself from scratch.

13
00:00:46,440 --> 00:00:49,380
So the subtitle is connecting with other apps.

14
00:00:49,800 --> 00:00:55,650
And that's really the gist of all of this is what if we want to display a map or I want to get latitude

15
00:00:55,650 --> 00:00:58,790
longitude data or I want to get weather data.

16
00:00:59,010 --> 00:01:04,020
You don't need to go put out weather sensors and connect them to the Internet and then get that data

17
00:01:04,020 --> 00:01:04,470
.

18
00:01:04,650 --> 00:01:10,110
Someone else has done that and made it all nice and easy for you to understand and interact with and

19
00:01:10,110 --> 00:01:12,950
then you just write code that uses that API.

20
00:01:13,470 --> 00:01:18,660
So without getting too far ahead of ourselves API stands for application programming interface although

21
00:01:18,930 --> 00:01:22,020
it's actually application program interface.

22
00:01:22,080 --> 00:01:24,150
Some people say programming it doesn't matter.

23
00:01:24,150 --> 00:01:29,940
But the idea is that it's an interface for programmers for code or computers to talk to one another

24
00:01:29,950 --> 00:01:30,290
.

25
00:01:30,690 --> 00:01:33,800
So I can write code like this code it's very small.

26
00:01:33,810 --> 00:01:37,730
But this code right here is interacting with Facebook.

27
00:01:37,770 --> 00:01:41,970
So Facebook has an API that allows me to get data from Facebook.

28
00:01:42,120 --> 00:01:47,760
So we have it you know human interface when I go on Facebook myself and hopefully don't spend too much

29
00:01:47,760 --> 00:01:54,270
time there but when I do that I'm looking at the human interface the HTML usually that I see it's rendered

30
00:01:54,270 --> 00:01:59,810
to me nice wig out photos and colors and text and fonts and all that stuff.

31
00:02:00,000 --> 00:02:05,940
When I want to make an app though that uses Facebook data so popular example would be something like

32
00:02:05,940 --> 00:02:10,860
Tinder if you're not familiar with Tinder you're probably lying.

33
00:02:10,860 --> 00:02:18,090
But if you're actually not familiar with Tinder Dating ish application that you go on sign up with your

34
00:02:18,090 --> 00:02:24,000
Facebook account and it shows you people's photos you can kind of say yes or no swipe left or right

35
00:02:24,010 --> 00:02:24,090
.

36
00:02:24,180 --> 00:02:30,780
But most importantly to what I'm talking about here is that it shows you if you have any likes in common

37
00:02:30,780 --> 00:02:31,050
with them.

38
00:02:31,050 --> 00:02:37,770
So if you have any favorite movies that you've added to to both of your Facebook profiles or books or

39
00:02:38,910 --> 00:02:43,980
music as well and a few other things and it also will tell you how many friends you have in common based

40
00:02:43,980 --> 00:02:45,030
off of Facebook.

41
00:02:45,240 --> 00:02:51,030
So that data is not just coming from the regular Facebook website like if I went on Facebook I could

42
00:02:51,030 --> 00:02:57,060
find that out if I matched someone I could go on their Facebook page if it's public at least and I could

43
00:02:57,240 --> 00:02:58,610
manually compare.

44
00:02:58,740 --> 00:03:00,370
Do we like the same movies.

45
00:03:00,600 --> 00:03:04,810
But of course that's not happening behind the scenes intender source code.

46
00:03:05,000 --> 00:03:10,330
There's code that's connecting to Facebook's API and saying Hey these two people.

47
00:03:10,740 --> 00:03:17,250
Well it's probably more like hey this person Nicole has matched with let's get their data and save it

48
00:03:17,250 --> 00:03:21,360
to our database and then let's take cold's data that we already have in our database and compare them

49
00:03:21,370 --> 00:03:21,470
.

50
00:03:21,570 --> 00:03:27,820
But the idea is we're talking or tender is talking to Facebook and that's one example.

51
00:03:27,930 --> 00:03:30,670
But API eyes are literally everywhere nowadays.

52
00:03:30,780 --> 00:03:33,500
Pretty much every application you use.

53
00:03:34,440 --> 00:03:42,840
So the term API is actually a broader term that refers to any type of code any interface that is made

54
00:03:42,840 --> 00:03:44,940
for other code to communicate with.

55
00:03:44,940 --> 00:03:52,500
So if we go on Wikipedia actually the definition the textbook definition I guess is in computer programming

56
00:03:52,500 --> 00:03:54,460
an application programming interface.

57
00:03:54,480 --> 00:03:55,680
So they use programming.

58
00:03:55,710 --> 00:04:00,590
That program is a set of routines protocols and tools for building software and applications.

59
00:04:00,600 --> 00:04:09,210
So that's very broad and that is basically saying it's any set of tools code routines that you can use

60
00:04:09,270 --> 00:04:10,550
in an application.

61
00:04:10,770 --> 00:04:14,540
So it could be a database API.

62
00:04:14,550 --> 00:04:16,510
So that has nothing to do with the Internet.

63
00:04:16,590 --> 00:04:19,920
It's just how you connect to a database locally on your computer.

64
00:04:19,920 --> 00:04:24,620
It could be a video card API or a hard drive a hard disk drive API.

65
00:04:24,870 --> 00:04:31,320
So those are kind of other non web based examples or when I was learning Java in high school I used

66
00:04:31,320 --> 00:04:39,600
an API to to incorporate the graphical elements buttons and windows and stuff into my applications.

67
00:04:39,720 --> 00:04:45,670
Really ugly Mario clone that I made and like solitaire I used an API for that.

68
00:04:45,720 --> 00:04:48,510
So that is a different kind of context.

69
00:04:48,570 --> 00:04:54,570
Typically what people mean when they refer to an API today is a web API which has its own section here

70
00:04:55,170 --> 00:04:57,630
but that is a subset of API in general.

71
00:04:57,630 --> 00:05:05,460
So API is in general any code whether it's a library a package or module a web API some sort of interface

72
00:05:05,460 --> 00:05:10,670
to work with image analysis on a computer or a database.

73
00:05:10,890 --> 00:05:14,220
They're all over the place so many different things that they do.

74
00:05:14,280 --> 00:05:19,450
You can use them in your own code web API is are more specialized.

75
00:05:19,510 --> 00:05:25,930
They have to do with web interfaces to other code or to other applications.

76
00:05:26,170 --> 00:05:33,100
So for instance the Facebook API we talked about the way that an application gets that data is through

77
00:05:33,220 --> 00:05:34,690
the Web through the Internet.

78
00:05:34,750 --> 00:05:37,440
I am requesting that data from Facebook.

79
00:05:37,660 --> 00:05:45,400
So just like when I request a web page lets say Reddit dot com slash slash Ah wench's cute photos or

80
00:05:45,460 --> 00:05:52,140
cute images of dogs and cats usually with the occasional reptile lover slash weirdo.

81
00:05:52,330 --> 00:05:54,070
No offense to anyone who has reptiles.

82
00:05:54,070 --> 00:05:56,640
I just can't can't get behind that.

83
00:05:56,710 --> 00:06:02,620
So when I request this hit enter and I'm seeing the human version the interface for me and for all of

84
00:06:02,620 --> 00:06:03,280
us.

85
00:06:03,580 --> 00:06:06,880
But there's also an interface for code to interact with.

86
00:06:06,880 --> 00:06:13,940
There's a web API where we request it and rather than seeing this our computer sees this.

87
00:06:14,080 --> 00:06:18,700
So I'll talk about what this is something called Jaison and just one video from now.

88
00:06:18,850 --> 00:06:24,550
But it's basically another format of data that is better and easier for computers to use.

89
00:06:24,550 --> 00:06:31,060
It doesn't have any of the fluff that we have here because if I'm writing an app let's say want to pit

90
00:06:31,060 --> 00:06:36,580
dogs versus cats and I want to count the number of posts every day that mentioned dogs.

91
00:06:36,590 --> 00:06:40,660
The number of posts every day that mentioned cats and have a chart so you can visit my web site and

92
00:06:40,660 --> 00:06:45,450
there's a live chart that's updating what I would need to do is get that from Reddit.

93
00:06:45,450 --> 00:06:51,850
I would need to ask Reddit you know give me the data today or every hour that update it give me the

94
00:06:51,850 --> 00:06:53,710
current front page of our site.

95
00:06:53,730 --> 00:06:54,170
Ah.

96
00:06:54,340 --> 00:06:56,060
And then I would go through the data.

97
00:06:56,200 --> 00:07:02,710
This data here and calculate you know search for dog search for cat and tally it up and update my graph

98
00:07:02,710 --> 00:07:03,640
every hour.

99
00:07:03,670 --> 00:07:05,860
So that's a simple example.

100
00:07:05,920 --> 00:07:09,160
You can do much more complex things of course.

101
00:07:09,160 --> 00:07:12,210
So here are some other examples of API is Twitter.

102
00:07:12,340 --> 00:07:18,680
You can do things like give me all the tweets that mention ice cream or you know unlike CNN they are

103
00:07:18,940 --> 00:07:24,010
always like live tweets coming in that mentions certain hashtags or certain news events.

104
00:07:24,130 --> 00:07:32,020
Facebook as we talked about so many things you can get from Facebook's API profile pictures likes and

105
00:07:32,080 --> 00:07:38,290
you probably see it all the time in applications where you see that kind of warning or question that

106
00:07:38,290 --> 00:07:43,200
pops up from Facebook it's like this application wants to use your data.

107
00:07:43,290 --> 00:07:45,130
Do you accept it or not or do you.

108
00:07:45,130 --> 00:07:45,880
Permitted or not.

109
00:07:45,880 --> 00:07:47,170
And you can kind of change things.

110
00:07:47,170 --> 00:07:51,920
Who can see what and what data it can access whether API.

111
00:07:51,920 --> 00:07:55,970
So there's lots of weather API is out there that do different things.

112
00:07:56,120 --> 00:08:02,820
Reddit API can we just saw very briefly Google Places what gas stations are near someone.

113
00:08:02,950 --> 00:08:06,000
Google Maps of course to get a map going.

114
00:08:06,100 --> 00:08:11,940
The Yelp API can do things like give me 10 restaurants in the zip code nine for one one.

115
00:08:13,150 --> 00:08:14,500
Lots and lots things you can do.

116
00:08:14,500 --> 00:08:21,220
And then of course by combining them together you can do even cooler things which is actually this site

117
00:08:21,700 --> 00:08:28,100
I teach dot com if this then that is a way to connect API.

118
00:08:28,690 --> 00:08:31,660
So there are 309 services.

119
00:08:31,930 --> 00:08:39,160
And basically this is kind of confusing I guess but it's a way to have a visual interface to connect

120
00:08:39,160 --> 00:08:40,930
API to do things for you.

121
00:08:41,320 --> 00:08:47,440
So I picked up photography on the side and there's so many photography sites if you want to do the whole

122
00:08:47,440 --> 00:08:57,400
social media thing and there's flicker and Instagram Facebook 500 pixels Dropbox and I want and iCloud

123
00:08:57,400 --> 00:09:02,380
and let's say I want all of those and any time I post a photo to Instagram I want it to post to all

124
00:09:02,380 --> 00:09:03,930
of those other places.

125
00:09:04,030 --> 00:09:07,240
You can do that using if this then that.

126
00:09:07,240 --> 00:09:09,760
So these are all the services that they allow.

127
00:09:09,760 --> 00:09:14,170
They worked with so Facebook's API Twitter's API get hubs.

128
00:09:14,350 --> 00:09:17,020
There are some I think there is something called the Internet of Things.

129
00:09:17,050 --> 00:09:24,010
So API is that will exist for physical objects like a thermostat where you can control the temperature

130
00:09:24,010 --> 00:09:32,320
through an API or a video camera security camera where you can use code to turn it on and off or rotate

131
00:09:32,320 --> 00:09:37,740
it or a light bulb that you can change the hue the color of dynamically using code.

132
00:09:37,750 --> 00:09:44,290
So you know in college I had friends who would take light bulbs that were smart electronic ones connected

133
00:09:44,290 --> 00:09:49,960
to the Internet plug them into their dorm and then it would automatically take whatever music was playing

134
00:09:49,960 --> 00:09:50,110
.

135
00:09:50,110 --> 00:09:54,310
They wrote some code that would then kind of turn the lights on and off and change the color to make

136
00:09:54,310 --> 00:09:58,440
a little visualizer for the music.

137
00:09:58,570 --> 00:10:00,740
So there's tons of things on here.

138
00:10:00,790 --> 00:10:03,210
This is just a side thing that's cool for you to check out.

139
00:10:03,220 --> 00:10:08,470
If this than that if you're not familiar with it you can look at browse recipes.

140
00:10:08,470 --> 00:10:13,930
So these are some of the popular things people will do like.

141
00:10:14,110 --> 00:10:20,410
Remind yourself to put on sunscreen when the heat index is high so it will automatically connect to

142
00:10:20,410 --> 00:10:26,060
an API that figures out what the U.V. index is and then it will write some code.

143
00:10:26,200 --> 00:10:27,000
You know whatever.

144
00:10:27,010 --> 00:10:31,750
I don't know what the Ubi index how that works what the scale is but whenever it reaches a certain number

145
00:10:32,110 --> 00:10:40,510
then it will send you an alert receive notification to turn off I find save battery power when you leave

146
00:10:40,510 --> 00:10:43,920
a specific location so you can do all sorts things connect.

147
00:10:43,930 --> 00:10:46,600
You know if this can do that.

148
00:10:46,660 --> 00:10:46,960
All right.

149
00:10:46,960 --> 00:10:48,680
So that all relies on API.

150
00:10:48,880 --> 00:10:55,620
And they support 300 plus AP guys but there are way more API is out there and a great place to see that

151
00:10:56,320 --> 00:11:02,770
is a tool or a site called programmable web and it's a API directory is how they build themselves.

152
00:11:02,770 --> 00:11:05,350
They have 15000 API.

153
00:11:05,530 --> 00:11:06,810
There are more out there.

154
00:11:06,820 --> 00:11:08,360
This is a great place to start.

155
00:11:08,590 --> 00:11:18,220
So if I know I want to use transportation data lets say I want to make an app that will tell you when

156
00:11:18,220 --> 00:11:25,540
the next train is in San Francisco using your current location or will tell you with the latest train

157
00:11:25,540 --> 00:11:29,890
you can take to still make it to work before your first meeting is something like that I would need

158
00:11:29,890 --> 00:11:35,950
an API to figure out when the trains are so I could cook click on transportation here I could do a search

159
00:11:36,250 --> 00:11:45,010
and there's all these different API cers at Yahoo traffic there's a bus Lufthansa for airlines or Indian

160
00:11:45,010 --> 00:11:46,000
Railways.

161
00:11:46,060 --> 00:11:49,940
So this is kind of all over the place you could narrow it down of course.

162
00:11:50,360 --> 00:11:57,280
Or you could look for weather if needed weather data and there's all these API eyes you can click on

163
00:11:57,280 --> 00:12:00,700
one like let's go.

164
00:12:00,830 --> 00:12:07,760
That was interesting climbing weather provides weather data for climbing sites and then I can see you

165
00:12:07,830 --> 00:12:10,120
Oreille for their home page.

166
00:12:10,150 --> 00:12:12,580
Sometimes for sample code.

167
00:12:12,580 --> 00:12:14,650
Not always.

168
00:12:14,650 --> 00:12:16,130
In this case there isn't.

169
00:12:16,160 --> 00:12:23,560
I can see the sites they support the climbing sites and then I can also see an endpoint that will show

170
00:12:23,560 --> 00:12:24,210
you.

171
00:12:24,310 --> 00:12:29,550
Basically this is the site where you can go learn about how the API works.

172
00:12:29,560 --> 00:12:34,420
So we're going to see this in just a moment with the API as we incorporate but this will tell you the

173
00:12:34,420 --> 00:12:39,400
documentation what the data looks like that you'll get back where you're supposed to make a request

174
00:12:39,400 --> 00:12:42,010
to to find certain data.

175
00:12:42,280 --> 00:12:44,040
So that's all I want to show though.

176
00:12:44,180 --> 00:12:49,600
Mainly programmable Web site directory for lots of API is some amazing things on here.

177
00:12:49,840 --> 00:12:58,480
Some sort of obscure things API is to detect nudity and images and then more common things like you

178
00:12:58,480 --> 00:13:07,010
know restaurants and bars and location guides National Park data linked in data maps Facebook you know

179
00:13:07,240 --> 00:13:09,140
lots and lots of things on here.

180
00:13:09,310 --> 00:13:10,830
So great resource.

181
00:13:10,930 --> 00:13:13,500
Also fun just to browse some things they have on here.

182
00:13:13,510 --> 00:13:17,360
If you ever you know a lot of times I would give students a project.

183
00:13:17,710 --> 00:13:22,060
And some people would know immediately they want to use a certain API and then some people weren't inspired

184
00:13:22,060 --> 00:13:23,090
and they needed help.

185
00:13:23,140 --> 00:13:28,280
They wanted inspiration and they just go browse until they find an API that excites them.

186
00:13:28,570 --> 00:13:30,250
Often on programs what Web.

187
00:13:30,640 --> 00:13:30,980
OK.

188
00:13:31,000 --> 00:13:38,000
So one last thing here that I just think is cool is that Tesla Tesla cars and motor cars the electric

189
00:13:37,990 --> 00:13:40,630
car maker has an API.

190
00:13:40,630 --> 00:13:45,850
I think it's unofficial that they don't support it because essentially But there's an API that you can

191
00:13:45,860 --> 00:13:53,620
use to interact with their cars so you can view the documentation here of things you can do.

192
00:13:53,620 --> 00:13:59,960
You can query a car for how charged it is what percentage of the battery is charged how much.

193
00:13:59,980 --> 00:14:01,520
Estimated range.

194
00:14:01,720 --> 00:14:03,420
And this is what you get back.

195
00:14:03,460 --> 00:14:09,820
So when you make a request to this you are l and you have to put in your vehicle ID and I don't have

196
00:14:09,820 --> 00:14:11,090
a test I won't do that.

197
00:14:11,200 --> 00:14:16,510
But if you did you could put it in there and plug it in the red and it would give you this information

198
00:14:16,540 --> 00:14:16,940
.

199
00:14:17,140 --> 00:14:22,750
But you can also do things like ask for the current climate settings temperature inside temperature

200
00:14:22,750 --> 00:14:30,180
outside and then you can do really fun things like wake the car up or open the charging port on the

201
00:14:30,190 --> 00:14:31,600
side.

202
00:14:31,810 --> 00:14:38,900
Start the charging stop charging flash the lights honk the horn so you can write code that will and

203
00:14:38,940 --> 00:14:43,960
there's videos of people who do this they'll have when their alarm goes off in the morning.

204
00:14:43,960 --> 00:14:49,350
Code will automatically check the weather outside and then appropriately set the Tesla.

205
00:14:49,410 --> 00:14:54,460
Well turn the Tesla on first set it to temperature inside to an appropriate temperature depending on

206
00:14:54,520 --> 00:15:00,600
how hot or cold just outside then it will honk the horn and start some music that will you know wakeup

207
00:15:00,620 --> 00:15:01,650
music or something.

208
00:15:01,750 --> 00:15:06,100
And there's videos of this online and you can do that because of the API.

209
00:15:06,350 --> 00:15:12,010
So that's an example of you know the Internet of Things where there is a physical object a thing that

210
00:15:12,010 --> 00:15:14,590
is being controlled through an API.

211
00:15:15,220 --> 00:15:16,020
OK.

212
00:15:16,480 --> 00:15:18,030
So we covered a lot there.

213
00:15:18,220 --> 00:15:26,560
Some of API application programming interface ways for you to write code that interacts with other code

214
00:15:26,650 --> 00:15:28,270
other pieces of data.

215
00:15:28,270 --> 00:15:35,260
Application services typically web API is what most people refer to which our API set are structured

216
00:15:35,260 --> 00:15:41,890
in a way that you interact with them through the web usually through HTP requests.
