1 00:00:07,940 --> 00:00:13,620 Welcome back. Before I show you how to write a program that will fetch 2 00:00:13,620 --> 00:00:18,720 data from a REST API from another website on the internet, 3 00:00:18,720 --> 00:00:21,960 let's take a little time to figure out how the internet really 4 00:00:21,960 --> 00:00:25,620 works and what URLs are and all that kind of stuff. 5 00:00:25,620 --> 00:00:29,490 You're I'm sure all used to using a web browser. 6 00:00:29,490 --> 00:00:33,000 Like we see here, this is a web browser 7 00:00:33,000 --> 00:00:36,960 and we're fetching a page from the umich.edu website. 8 00:00:36,960 --> 00:00:46,960 So, you see in the URL bar that URL http://umich.edu/about. 9 00:00:48,830 --> 00:00:54,190 You can think about parsing that as there's a certain part before 10 00:00:54,190 --> 00:01:01,110 the colon and we'll call that the protocol. 11 00:01:01,110 --> 00:01:05,200 In this case, HTTP is our protocol. 12 00:01:06,170 --> 00:01:09,925 Then, we have a colon slash slash. 13 00:01:09,925 --> 00:01:11,570 That's just a separator, 14 00:01:11,570 --> 00:01:19,850 and then all the stuff until the next forward slash is called the domain or the server. 15 00:01:21,680 --> 00:01:25,850 Then we have another slash as a separator and then we can have 16 00:01:25,850 --> 00:01:31,350 some other stuff which we'll call the path or the arguments. 17 00:01:31,510 --> 00:01:35,600 So, the server says where to fetch something from, 18 00:01:35,600 --> 00:01:40,520 and the argument says what to fetch from that remote server. 19 00:01:40,520 --> 00:01:46,475 The protocol says how to communicate with that remote server. 20 00:01:46,475 --> 00:01:50,600 Next, let's talk about those servers. 21 00:01:50,600 --> 00:01:54,110 Those servers are referred to by name. 22 00:01:54,110 --> 00:01:57,740 Usually, you get a name like umich.edu, 23 00:01:57,740 --> 00:02:04,385 or si.umich.edu, or www.google.com. 24 00:02:04,385 --> 00:02:06,840 Those are called domain names. 25 00:02:06,840 --> 00:02:12,060 They say what remote computer you're trying to talk to. 26 00:02:12,220 --> 00:02:18,940 Every computer that's attached to the internet has a unique identifier, an address. 27 00:02:18,940 --> 00:02:20,465 It's called the IP address. 28 00:02:20,465 --> 00:02:23,215 IP stands for Internet Protocol. 29 00:02:23,215 --> 00:02:26,885 No two computers that are connected to the internet have 30 00:02:26,885 --> 00:02:30,290 the same IP address at the same time. 31 00:02:30,290 --> 00:02:32,239 When the computer disconnects, 32 00:02:32,239 --> 00:02:36,605 you might get another computer getting to reuse that IP address. 33 00:02:36,605 --> 00:02:42,635 When we have a domain name like www.si.umich.edu, 34 00:02:42,635 --> 00:02:46,040 that's of a more permanent name but 35 00:02:46,040 --> 00:02:51,680 the actual server that is responding to that name may change over time, 36 00:02:51,680 --> 00:02:54,320 and each server will have an IP address. 37 00:02:54,320 --> 00:02:57,785 So the internet has something called the DNS, 38 00:02:57,785 --> 00:02:59,300 the Domain Name System, 39 00:02:59,300 --> 00:03:02,215 that is setup to resolve names like 40 00:03:02,215 --> 00:03:09,020 www.si.umich.edu and turn them into these unique identifiers, the IP addresses. 41 00:03:09,020 --> 00:03:16,050 An IP address will look something like 159.89.239.247. 42 00:03:16,430 --> 00:03:22,250 The dots are just there to help us divide it up and think about it as four chunks. 43 00:03:22,250 --> 00:03:23,690 In each of those chunks, 44 00:03:23,690 --> 00:03:28,520 we have to have a number between zero and 255. 45 00:03:28,520 --> 00:03:33,140 If you ever see an IP address that has a number bigger than 255, 46 00:03:33,140 --> 00:03:35,660 that's not really an IP address. 47 00:03:35,660 --> 00:03:38,660 The numbers go from zero to 255, 48 00:03:38,660 --> 00:03:42,955 it turns out that you can represent that with eight bits, 49 00:03:42,955 --> 00:03:45,730 eight zeros and ones. 50 00:03:47,990 --> 00:03:52,070 We're not going to go into the details of binary arithmetic here, 51 00:03:52,070 --> 00:03:54,950 but we get these four sets of eight bits, 52 00:03:54,950 --> 00:03:57,460 and so we have a total of 32 bits. 53 00:03:57,460 --> 00:04:00,760 Sometimes these are called 32-bit addresses, 54 00:04:00,760 --> 00:04:04,910 and we have the decimal representations with the dots 55 00:04:04,910 --> 00:04:12,945 159.89.239.247 just to make it a little easier for people to speak them and write them. 56 00:04:12,945 --> 00:04:21,260 So how is it that www.si.umich.edu gets converted into that number and how does every 57 00:04:21,260 --> 00:04:25,340 computer on the internet know to find that number whenever they're 58 00:04:25,340 --> 00:04:29,885 trying to communicate with www.si.umich.edu? 59 00:04:29,885 --> 00:04:32,840 Turns out there's a distributed lookups system, 60 00:04:32,840 --> 00:04:34,580 the Domain Name System, 61 00:04:34,580 --> 00:04:37,680 and you can go to various sites that will let you do this lookup. 62 00:04:37,680 --> 00:04:40,550 Your computer has a way of doing that lookup, 63 00:04:40,550 --> 00:04:43,435 it has a server that it talks to in the background. 64 00:04:43,435 --> 00:04:45,220 But here's one that's public. 65 00:04:45,220 --> 00:04:47,600 So I've gone to look. 66 00:04:47,610 --> 00:04:50,320 I've already set this up here, 67 00:04:50,320 --> 00:04:53,370 and you can see I've looked up 68 00:04:53,370 --> 00:05:01,125 www.si.umich.edu and actually got back two possible IP addresses. 69 00:05:01,125 --> 00:05:03,260 The main IP address is the first one. 70 00:05:03,260 --> 00:05:07,200 So it's that 159.89.239.247. 71 00:05:08,450 --> 00:05:11,519 That's the basics of URLs, 72 00:05:11,519 --> 00:05:13,700 domain names, and IP addresses. 73 00:05:13,700 --> 00:05:15,900 We'll see you next time.