Install Required Libraries
- Install the requests library to make HTTP Requests
- Install pandas to do some data exploratory
- In this recipe we will use altair to do the data visualization, if you are unfamiliar with altair, try to watch this playlist Altair Tutorial
- This is not a library, but you will need your API Keys for this recipe
Data Exploration
In this recipe we will use a few API from Sectors, here are the following API:- List of Companies by Subsector API to retrieve all the companies in a subsector
- Individual Company Report per Section API to retrieve the financial data for each company
List all companies by subsectors
Let’s take a look at list of companies under the tobacco subsectorsIndividual Company Report Per Section
After retrieving the list of companies under the tobacco subsector, the next step is to obtain the financial report for each company. With the help of Sectors, you can easily access the Company Report, which provides comprehensive information beyond just financial. The available sections of the report include:- Overview
- Valuation
- Peers
- Future
- Financials
- Dividend
- Management
- Ownership
data
the output should look like this
Data Visualization
Since we already gathered the revenue and earnings data from each company, now let’s try to visualize and compare the revenue and earnings data from each companyRevenue Comparison
Let’s take a look at a single company revenue first and try to visualize it.

Earning Comparison
To compare earnings between companies, you can easily modify the previous code by replacingrevenue
with earnings
. We won’t repeat the code here as it remains largely the same, and we trust in your ability to make this straightforward change.
