In this video we will discuss Application Program Interfaces API for short. Specifically, we will discuss: What is an API API Libraries REST API, including: Request and Response An Example with PyCoinGecko An API lets two pieces of software talk to each other For example you have your program, you have some data, you have other software components. You use the api to communicate with the api via inputs and outputs. Just like a function, you don’t have to know how the API works, but just its inputs and outputs. Pandas is actually a set of software components, much of which are not even written in Python. You have some data. You have a set of software components. We use the pandas api to process the data by communicating with the other Software Components. Let’s clean up the diagram. When you create a dictionary, and then create a pandas object with the Dataframe constructor, in API lingo, this is an “instance.” The data in the dictionary is passed along to the pandas API. You then use the dataframe to communicate with the API. When you call the method head, the dataframe communicates with the API displaying the first few rows of the dataframe. When you call the method mean the API will calculate the mean and return the values. REST APIs are another popular type of API; they allow you to communicate through the internet allowing you to take advantage of resources like storage, access more data, artificial intelligent algorithms, and much more. The RE stands for Representational, the S stands for State, the T stand for Transfer. In rest API’s your program is called the client. The API communicates with a web service you call through the internet. There is a set of rules regarding Communication, Input or Request, and Output or Response. Here are some common terms. You or your code can be thought of as a client. The web service is referred to as a resource. The client finds the service via an endpoint. We will review this more in the next section. The client sends requests to the resource and the response to the client. HTTP methods are a way of transmitting data over the internet We tell the Rest API’s what to do by sending a request. The request is usually communicated via an HTTP message. The HTTP message usually contains a JSON file. This contains instructions for what operation we would like the service to perform. This operation is transmitted to the webservice via the internet. The service performs the operation. In the similar manner, the webservice returns a response via an HTTP message, where the information is usually returned via a JSON file. This information is transmitted back to the client. Crypto Currency data is excellent to be used in an API because it is being constantly updated and it is vital to CryptoCurrency Trading We will use the Py-Coin-Gecko Python Client/Wrapper for the Coin Gecko API, updated every minute by Coin-Gecko We use the Wrapper/Client because it is easy to use so you can focus on the task of collecting data, we will also introduce pandas time series functions for dealing with time series data Using Py-Coin-Gecko to collect data is quite simple All we need is to install and import the library Create a client object And finally use a function to request our data. In this function we are getting data on bitcoin, in U.S. Dollars, for the past 30 days. In this case our response is a JSON expressed as a python dictionary of nested lists including price, market cap, and total volumes which contain the unix timestamp and the price at that time. We are only interested in price so that is what we will select using the key price To make things simple, we can convert our nested list to a DataFrame, with the columns time stamp and price its difficult to understand the column time stamp we Will convert it to a more readable format using the pandas Function to_datetime Using the to datetime function, we create readable time data, the input is the time stamp column unit of time is set to milliseconds We append the output to the new column date We. Would like to create a candle stick plot To get the data for the daily candlesticks we will group by the date to find the minimum, maximum, first, and last price of each day Finally we will use plotly to create the candlestick chart and plot it Now we can view the candlestick chart by opening the html file and clicking trust HTML in the top left of the tab It should look something like this