Welcome back. Before I show you how to write a program that will fetch
data from a REST API from another website on the internet,
let's take a little time to figure out how the internet really
works and what URLs are and all that kind of stuff.
You're I'm sure all used to using a web browser.
Like we see here, this is a web browser
and we're fetching a page from the umich.edu website.
So, you see in the URL bar that URL http://umich.edu/about.
You can think about parsing that as there's a certain part before
the colon and we'll call that the protocol.
In this case, HTTP is our protocol.
Then, we have a colon slash slash.
That's just a separator,
and then all the stuff until the next forward slash is called the domain or the server.
Then we have another slash as a separator and then we can have
some other stuff which we'll call the path or the arguments.
So, the server says where to fetch something from,
and the argument says what to fetch from that remote server.
The protocol says how to communicate with that remote server.
Next, let's talk about those servers.
Those servers are referred to by name.
Usually, you get a name like umich.edu,
or si.umich.edu, or www.google.com.
Those are called domain names.
They say what remote computer you're trying to talk to.
Every computer that's attached to the internet has a unique identifier, an address.
It's called the IP address.
IP stands for Internet Protocol.
No two computers that are connected to the internet have
the same IP address at the same time.
When the computer disconnects,
you might get another computer getting to reuse that IP address.
When we have a domain name like www.si.umich.edu,
that's of a more permanent name but
the actual server that is responding to that name may change over time,
and each server will have an IP address.
So the internet has something called the DNS,
the Domain Name System,
that is setup to resolve names like
www.si.umich.edu and turn them into these unique identifiers, the IP addresses.
An IP address will look something like 159.89.239.247.
The dots are just there to help us divide it up and think about it as four chunks.
In each of those chunks,
we have to have a number between zero and 255.
If you ever see an IP address that has a number bigger than 255,
that's not really an IP address.
The numbers go from zero to 255,
it turns out that you can represent that with eight bits,
eight zeros and ones.
We're not going to go into the details of binary arithmetic here,
but we get these four sets of eight bits,
and so we have a total of 32 bits.
Sometimes these are called 32-bit addresses,
and we have the decimal representations with the dots
159.89.239.247 just to make it a little easier for people to speak them and write them.
So how is it that www.si.umich.edu gets converted into that number and how does every
computer on the internet know to find that number whenever they're
trying to communicate with www.si.umich.edu?
Turns out there's a distributed lookups system,
the Domain Name System,
and you can go to various sites that will let you do this lookup.
Your computer has a way of doing that lookup,
it has a server that it talks to in the background.
But here's one that's public.
So I've gone to look.
I've already set this up here,
and you can see I've looked up
www.si.umich.edu and actually got back two possible IP addresses.
The main IP address is the first one.
So it's that 159.89.239.247.
That's the basics of URLs,
domain names, and IP addresses.
We'll see you next time.