👾 Game Master

What Is An API?

What is an API?

API stands for the Application Programming Interface. It is a type of intermediary which connects two applications. In modeling, API is a commonly used interface to acquire data from the established dataset.

For example, when we are performing prediction or analytical models, a dataset that contains historical information, such as previous stock prices or volumes, are required. It is indeed very trivial to search, copy, and paste data manually from the internet. Therefore, a financial API is necessary to achieve the data collection task more efficiently.

Examples of API and How API Works

One commonly used financial API is YahooFinance. It contains historical information on financial assets like stocks, bonds, and even cryptocurrencies. The API “communicating” process is straightforward. Take Python as an example. A few lines of code can achieve the task.

Here is an example to acquire historical data on Tesla stock from 2019 to 2022.

Step One: Import the required libraries to set up the API. In this case, pandas_datareader is required to communicate with the YahooFinance API.

Step Two: “Explain” to the API your needs. State the date and symbol for the data you want.

Step Three: Connect with the API

Now if we print the stock_data, we derive the following table:


Is this article helpful for you?

Leave a comment below!


Comments