Hello. The first thing we're going to try to access data from using Python is an API. First, I'd like to talk a little bit about what an API is and what we'll be doing with it. So an API, API stands for Application Programming Interface.
Let's just write that down. No, now, Application Programming Interface is kind of like a graphical user interface, which you might have heard referred to as a GUI. And a GUI is what you're looking at right now. This is a graphical interface we're looking at in our here and our Python notebook.
And the graphical interface is an interface that you can describe by saying, okay, when the user moves the cursor in a certain way or over a certain element, maybe, you know, I put my cursor over this to press Execute that I expect a certain behavior to happen. When I expect if I've used this if I understand this interface enough that if I execute this, I know what will happen, which is that it will execute that code. Now, an application programming interface is very similar. It's an interface that we can describe where when the user does something, they get a certain response.
However, in our case, the user, instead of being somebody typically think of as a user, you know, somebody with a mouse and a keyboard or perhaps a touch screen and a finger. Instead, our user is somebody who is writing code that accesses data. So, let's take a look at an example to understand a little more. Here we have an API called FruityVice.
And it's just a very simple API for getting information about Fruity. So, if we go to FruityVice's home, it's a nice cheery cherries there. You can receive interesting data from any fruit of your choosing. Sounds great.
How does it work? You can receive data for a specific fruit or all fruit and add your own data. Okay. Let's try it.
So, what we do is we send a request to a certain URL. Again, this is like in a graphical interface saying, I click on a certain thing and this happens. I expect, you know, when I click on this tab and my browser just switch to that tab and that tab becomes visible and the previous tab goes away. If I click on this, the other tab goes away and this tab comes back.
That's what I expect to have happened here. Instead, it's I'm sending an HTTP and internet request to this URL or rather this URL on FruityVice.com. And if I get returned here, I get a response and the response is something that looks like Python. This is a valid Python code here.
Addictionary, illist. And in fact, we have several dictionaries. And each one appears to be all the information about one fruit. So, what we're doing instead of, with this interface, instead of moving things graphically is we are doing some programming to make a request.
In this case, simply programming it to hit up a specific API as a specific URL. And we get back what we expect to have happened is we get data. And that's very, very helpful to those of us who are in data. Those of us who are doing data science, machine learning, data visualization, any of those fields we want data.
And APIs are a great place to get them. Okay. In our next step, we're going to get set up with accessing our first API.