Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,240 --> 00:00:07,290
Hey guys. In this module we're going to be talking all about APIs, Application Programming Interfaces.
2
00:00:07,350 --> 00:00:13,830
Now it's very likely, if you spend any time on the Internet at all, you would have heard of this term
3
00:00:14,010 --> 00:00:16,170
crop up every so often.
4
00:00:16,170 --> 00:00:22,500
So in the coming lessons of this module, we're going to explore what exactly APIs are, and what we can
5
00:00:22,500 --> 00:00:23,980
do with it.
6
00:00:24,000 --> 00:00:30,000
First things first. In this module you're going to be exploring a number of APIs, and you're going to
7
00:00:30,000 --> 00:00:36,490
be building a weather application, as well as a email sign up web application.
8
00:00:36,510 --> 00:00:43,470
This is going to allow you to collect real users’ email addresses, and save it to your own database on MailChimp,
9
00:00:43,920 --> 00:00:46,170
so that you can contact them at a later point.
10
00:00:46,170 --> 00:00:52,980
And this is really useful if you decide to create a landing page and email people when your product
11
00:00:52,980 --> 00:00:59,260
launches, or if you're trying to set up an email newsletter and stay in touch with your subscribers.
12
00:00:59,340 --> 00:01:00,890
So that's the goal.
13
00:01:00,930 --> 00:01:08,430
Now, in order to get there though, we first have to understand what are APIs, and why are they useful.
14
00:01:08,430 --> 00:01:16,560
Now, if you went onto yahoo.com, and you took a look at their little weather section on the right, you'll
15
00:01:16,560 --> 00:01:23,700
notice that it takes the current location of your web browser, and gives you the upcoming weather forecast
16
00:01:23,760 --> 00:01:25,680
for your location.
17
00:01:25,680 --> 00:01:32,310
Now, if we wanted to create our own web site, and we wanted a little module like this, how would we do
18
00:01:32,310 --> 00:01:32,920
that?
19
00:01:33,060 --> 00:01:36,270
Because we're not going to go around collecting weather data, right?
20
00:01:36,300 --> 00:01:43,470
We're not really kitted out to be able to detect wind speed and the temperature and forecast what
21
00:01:43,470 --> 00:01:45,950
the weather will be like in the future.
22
00:01:45,990 --> 00:01:48,590
So where do we get this data anyways?
23
00:01:48,630 --> 00:01:56,880
Well, we could use a weather data service, like OpenWeatherMap, where their job is to collect these pieces
24
00:01:56,880 --> 00:02:02,900
of data and organize it and do all of the complicated things to forecast the weather,
25
00:02:03,450 --> 00:02:10,560
and then all we have to do is to use their API to tap into that live weather data, and we'll be able to
26
00:02:10,560 --> 00:02:12,390
start pulling it into our web site,
27
00:02:12,510 --> 00:02:15,300
just like how Yahoo does it here.
28
00:02:16,020 --> 00:02:22,410
Now similarly, when you go onto Tinder, and you've seen that section where it says ‘Shared Friends’ or
29
00:02:22,410 --> 00:02:24,210
‘Shared Interests’,
30
00:02:24,210 --> 00:02:27,090
where did these pieces of data come from?
31
00:02:27,090 --> 00:02:30,590
Well, it comes from when the user logs in with Facebook.
32
00:02:30,720 --> 00:02:38,280
Tinder is able to ask Facebook for these pieces of data on the user, and then it can use that data to
33
00:02:38,280 --> 00:02:44,790
populate these sections, and it will do that through the use of the Facebook API in order to get that
34
00:02:44,790 --> 00:02:46,470
data from Facebook.
35
00:02:46,470 --> 00:02:51,090
Now out there there are loads of different types of APIs that you can use.
36
00:02:51,180 --> 00:02:58,590
For example, in the UK we have the Police API, which gives us granular data on where certain crimes have
37
00:02:58,590 --> 00:03:04,830
happened, on things like what happened with that crime, who was involved, and a whole lot of things.
38
00:03:04,860 --> 00:03:12,100
And through the use of an API like this, people are able to build interesting web sites, like this one.
39
00:03:12,360 --> 00:03:14,130
This is called Murder Map.
40
00:03:14,130 --> 00:03:21,000
It has a little bit of a dark name, and it's a little bit of a strange web site, but it takes that data
41
00:03:21,000 --> 00:03:29,520
from the police API, and it maps out all of the murders that take place in London by location as well
42
00:03:29,520 --> 00:03:35,700
as by weapon, by date, and by the age and gender of the victim.
43
00:03:35,790 --> 00:03:41,040
And it's really interesting to see this data mapped out, especially if you're trying to figure out where
44
00:03:41,040 --> 00:03:41,880
you want to live.
45
00:03:42,540 --> 00:03:49,500
So maybe stay away from gun and knife crime, but maybe poisoning and other things won't affect you so
46
00:03:49,500 --> 00:03:50,390
much.
47
00:03:50,580 --> 00:03:55,400
So in the coming lessons, I'm going to be introducing you to some really fun API.
48
00:03:55,620 --> 00:04:02,460
But there's all sorts of APIs out there, and they range from things such as APIs that give you data
49
00:04:02,490 --> 00:04:09,580
on the prices of various stocks, to things like an API that gives you data on various Pokémon,
50
00:04:09,600 --> 00:04:13,480
so all the way from very serious to very not serious.
51
00:04:13,530 --> 00:04:21,459
You can access all sorts of data via APIs and use them to create your own web sites.
52
00:04:21,459 --> 00:04:24,000
Now we've talked so much about APIs.
53
00:04:24,060 --> 00:04:27,310
What exactly is the definition of an API?
54
00:04:27,420 --> 00:04:34,110
A broad definition that a lot of people go by is that an API is a set of commands, functions, protocols
55
00:04:34,110 --> 00:04:41,730
and objects that programmers can use to create software or interact with an external system.
56
00:04:41,760 --> 00:04:43,770
So what does all of that mean?
57
00:04:43,770 --> 00:04:45,220
Well, let's simplify it.
58
00:04:45,420 --> 00:04:51,750
Let's say that you were going to a restaurant, and in a restaurant we know that there are the things
59
00:04:51,750 --> 00:04:58,590
that are on the menu, say various cakes and desserts that they sell, but you could also go into the kitchen
60
00:04:58,590 --> 00:05:05,590
and you would find there’s loads of raw ingredients, and probably a couple of surprised chefs as to what it
61
00:05:05,590 --> 00:05:07,490
is you're doing in the kitchen.
62
00:05:07,840 --> 00:05:13,360
Now if you had just decided that you were going to go into the kitchen pantry and just start eating
63
00:05:13,360 --> 00:05:17,410
things that they have they're, like just start spooning some mayonnaise,
64
00:05:17,410 --> 00:05:23,050
then the restaurant's going to be pretty shocked, right, and they're going to be pretty unhappy about that,
65
00:05:23,590 --> 00:05:28,120
because there are certain things which they sell and they will let you buy,
66
00:05:28,150 --> 00:05:31,730
but then there's other things which are kind of off limits.
67
00:05:31,870 --> 00:05:38,530
It's kind of similar with data. For every web site that has their own data, be it Facebook, which has data
68
00:05:38,560 --> 00:05:44,170
on their users, or something like the police API, which has data on crimes,
69
00:05:44,320 --> 00:05:48,490
there’s certain pieces of data that they will allow you to access,
70
00:05:49,000 --> 00:05:53,850
but there's other pieces of data that's not really your business.
71
00:05:54,670 --> 00:06:00,730
So how can these web sites tell you what are the things that you can actually access from them and how
72
00:06:00,730 --> 00:06:02,010
to do that?
73
00:06:02,020 --> 00:06:08,130
Well, if we were in a restaurant then they might provide that information in the form of a menu,
74
00:06:08,290 --> 00:06:08,590
right?
75
00:06:08,590 --> 00:06:14,980
So at this restaurant you can buy cakes, you can buy sandwiches, tea and coffee. And for a service like
76
00:06:15,040 --> 00:06:22,030
a weather API, say like OpenWeatherMap, then the kind of data that you can access include things like
77
00:06:22,030 --> 00:06:29,110
the temperature, the weather conditions, the weather images, and maybe the atmospheric pressure. In API,
78
00:06:29,110 --> 00:06:38,210
some people will consider to be a contract. It’s a contract between the data provider and the developer.
79
00:06:38,260 --> 00:06:46,150
And essentially what it says is these are all the things that developers can access, and these are the
80
00:06:46,150 --> 00:06:51,520
methods, the objects, the protocols that you would use to access them.
81
00:06:51,520 --> 00:06:59,860
And we, as the web site that hosts the data, will try to not change any of these methods or functions without
82
00:06:59,860 --> 00:07:01,170
notifying you.
83
00:07:01,600 --> 00:07:07,450
Coming back to our definition, then it starts to make a little bit more sense, right, where an API is a
84
00:07:07,450 --> 00:07:14,740
set of commands, functions, protocols and objects that programmers can use to create software or interact
85
00:07:14,860 --> 00:07:17,050
with an external system.
86
00:07:17,050 --> 00:07:24,700
Now we've seen a lot of examples of an API that allows you to interact with an external system, but we
87
00:07:24,700 --> 00:07:29,640
haven't really seen any that allow you to create software, or have we?
88
00:07:29,660 --> 00:07:32,250
Well, if you think about it, when we learnt about
89
00:07:32,260 --> 00:07:33,640
jQuery, what is
90
00:07:33,640 --> 00:07:37,060
jQuery? Well, it's an API, right?
91
00:07:37,090 --> 00:07:43,090
It's something that gives you access to a whole bunch of functions and objects that let you create software
92
00:07:43,330 --> 00:07:47,680
much more easily than if you were just writing vanilla Javascript.
93
00:07:47,680 --> 00:07:54,370
Now if we think back to the Tinder example, where Tinder was getting data from Facebook to get the shared
94
00:07:54,370 --> 00:07:57,030
friends and shared interests of their users,
95
00:07:57,040 --> 00:08:03,400
well this is a case where they're using the Facebook API to interact with an external system, namely
96
00:08:03,550 --> 00:08:05,800
the Facebook database.
97
00:08:05,800 --> 00:08:13,390
Now in this module we're going to focus on the types of APIs that allow us to interact with an external
98
00:08:13,390 --> 00:08:14,240
system,
99
00:08:14,440 --> 00:08:18,000
and most importantly an external server.
100
00:08:18,040 --> 00:08:22,920
So we're going to get hold of some piece of data from a web site,
101
00:08:23,110 --> 00:08:30,050
and we're going to do that through their API, and we're going to read their documentation to see what are
102
00:08:30,070 --> 00:08:31,770
all the things that we can do.
103
00:08:31,840 --> 00:08:40,330
And we're going to use their API as a menu of things that we can do to interact with their data.
104
00:08:40,330 --> 00:08:42,880
So that's a little bit on the theory of API,
105
00:08:43,360 --> 00:08:49,300
but in the next lesson we're going to look at how we can put it into practice. For all of that and more,
106
00:08:49,510 --> 00:08:50,080
I'll see you there.
11712
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.