First, let's take a look at what application programming interfaces
are and then we'll see how we can use them to start pulling in some data from the
internet. So when you're browsing the web,
you might've realized that there's a lot of websites out there that carry a
whole bunch of data. For example,
you could go onto Yahoo weather and see next week's weather predictions for
any city in the world,
you could go onto Coinbase and see what is the current market value of various
cryptocurrencies like Bitcoin and Ethereum.
You can also go onto the MBA website and look at various stats about your
favorite basketball players. Now,
what if we wanted to use the data that they have?
How can we tap into it and use it in our own programs? Well,
that's where application programming interfaces come into play.
They all are a set of commands, functions, protocols, and objects
that programmers can use to create software or interact with an external system.
In the upcoming lessons
what we're going to be focusing on is this interacting with external systems.
Namely,
we're going to try and interact with various websites and pull live data from
those websites. Essentially,
the API is an interface or rather a sort of barrier between your program and an
external system.
And what you're trying to do is you're trying to use the rules that the API has
prescribed to make a request to the external system for some piece of data.
And if you have structured your request
according to all of the requirements that this external system has set out in
their API,
then they will respond to you appropriately and give you the data that you want.
But if you don't follow the rules,
then your request will be invalid and they will tell you to go away.
So if we think about the websites we saw before, Yahoo weather has a Yahoo
weather API
which you can tap into using your programs or apps and get things like 10-day
forecast, wind, atmosphere, astronomy conditions,
and Coinbase has their own API,
which lets you tap into the current live prices of various cryptocurrencies.
And of course, the MBA also has an API for you to be able to get various
information that you're interested in on leagues, teams, players, games and a whole
bunch more.
So essentially, you can imagine these websites as the sort of restaurant,
right?
And the data that powers these websites as the kitchen behind the scenes.
We can't really go to a restaurant as a member of the public and just go in to
the kitchen and start raiding their cupboards. You can't, you know,
imagine going to your favorite Japanese restaurant and heading straight into the
kitchen for some of your favorite Kewpie mayonnaise.
That's not really appropriate. In a restaurant
we have a menu and this menu is kind of like the interface between you and the
restaurant.
It's the thing that tells you what you can order and what you can't.
So maybe you can get a cake, a sandwich or tea from the restaurant,
but you can't just go into the kitchen and demand whatever it is that you want.
Essentially an API is exactly that. It's the menu.
It's all of the things that you can do to interact with
an external system such as a website
that carries data like Yahoo
weather or the MBA website. In the coming lessons
we're going to be looking at how we can read the documentation for the API and
interact with them to be able to pull pieces of data that
we want in the moment that we want it. So for all of that and more,
I'll see on the next lesson.