How to pull financial statements using the FMP API

Financial statements are fundamental to most financial analysis and especially when it comes to investment decisions. Most analysts are used to using Excel to p

How to pull financial statements using the FMP API

Sep 30, 2022 2:26 AM - Jack Dalton

blog post cover photo

Image credit: Tech Daily

Financial statements are fundamental to most financial analysis and especially when it comes to investment decisions. Most analysts are used to using Excel to perform their analysis but many are learning about the power of using a coding language like Python. So, if you're somewhat new to coding and you want to learn how to pull financial statements from FMP Financial Statement API, you are in the right place. Here's a step-by-step guide to learn how to pull financial statements from the FMP API.

Step 1: Load FMP Developer API Docs Website

From this article go to the top right of the page, click “Developers” and then click "API Docs" from the list below. Make sure you are logged into your account. You should see this in the top right corner:


Otherwise, click login and enter your account credentials.

A key piece of information that'll want to write down in a safely secured location is your API Key. This is located in the second section of the API docs page which is called "Your Details". See in the example below, it should be a long series of letters and numbers. As with any key, this unlocks something and in this case it ensures that you have permission to access the API you are requesting. Make sure to keep your key private and safely secured if you are storing it somewhere on your computer. It is against our terms and conditions to share your API key with anyone - your account will be blocked and investigated if we suspect you are doing this.

Step 2: Copy the API URL from the Financial Statement you wish to Retrieve


After the documentation URL is loaded you'll need to scroll down to the section called Company Financial Statements. Alternatively, you can use the navigation sidebar on the left and click Company Financial Statements om the menu on the left. Here you need to decide a few things:

  • Which financial statement do you want to pull?

Your options are Income Statement, Balance Sheet, or Cash Flow Statement

  • Which time period of statement do you want to pull?

Your options are Annual or Quarterly statements.

  • Which company do you want to pull?

You can choose almost any publicly listed company in the world! You'll need to find out what their stock ticker is and replace the default APPL (Apple Inc) ticker that is the standard. You can find stock tickers by simply googling Company Name + Stock Ticker.

Once you decide which type and period you want to pull, copy the relevant URL.

For this tutorial, we're going to be pulling Apple Inc's annual Income Statements.

Step 3: Open Your Python Environment and copy URL

Now you'll need to open up your Python environment to start writing code. To start with, create a variable called “URL” and give the string version of the URL you copied in step 2. You can simply use Ctrl + V (or cmd + V for mac users) to paste the url you copied.

ERROR ALERT: Make sure to add inverted commas (otherwise called quotation marks) around the copied URL to make the URL variable a string.

url = “”

If you're copying directly from this page you'll need to make sure that you replace the ‘demo' with your API key

Step 4: Write the Python code to access the Financial Statement

To learn more about exactly what all the following code means and why it works, visit out guide - How to call a Financial Modeling Prep API

try: # For Python 3.0 and later from urllib.request import urlopen except ImportError: # Fall back to Python 2's urllib2 from urllib2 import urlopen import json def get_jsonparsed_data(url): """ Receive the content of ``url``, parse it as JSON and return the object. Parameters ---------- url : str Returns ------- dict """ response = urlopen(url) data ="utf-8") return json.loads(data) url = ("") IncomeStatement_APPL = get_jsonparsed_data(url)

Step 5: Look inside the data you just received!

If you're working in a JupyterLab environment you'll be able to see the JSON data you received by simply typing in the name of the variable you've stored the information under and hitting enter. As you can see on the last line of code above, we've named our variable IncomeStatement_APPL. If you're working in a regular python environment and want to print the data then use the following:


You may have noticed that in the URL you copied over the limit = 120, this means that the API will deliver the last 120 statements. That's why when you hit enter above, you'll get a lot of statements. You may not want this many. If that's the case, simply enter the number of historical statements you wish to receive.

Step 6: Get a specific data point from the larger JSON data provided

Often it's good to take a look at the one of the statements delivered to be able to see the way everything has been stored. Assuming you're using JupyterLab, enter the following code to look at the most recent statement:


You should see something like this:


Now I'm going to show you how to pull one data point from this set. You'll need to index into the particular statement (note that you index in using a number from 0 to the limit you set minus 1) and then index the element of the statement you want to extract. Here's how you could pull the 2020 operating income:

IncomeStatement_APPL [0] [‘operatingIncome']

ERROR ALERT: To ensure you don't get a DNE error, make sure to directly copy the name of the financial statement element from the sample view of one years entire statement.

Rounding Up

There you have it! Getting access to financial statements using Financial Modeling Prep's financial statements API is that easy! As a bit of a bonus, here's an example of using a for loop to create a table with Apple's most recent 5 net income ratios.


From this we can see that 2020, had a significant dip in the net income ratio - perhaps this is caused by the pandemic?

Other Blogs

Sep 11, 2023 - Rajnish Katharotiya

Industry Analysis with Python

During this post we are going to perform an industry analysis with Python. We will build, analyse and compare all stocks operating within an industry. To do so, we will pick an industry and get all important financial metrics for companies operating in that industry. Then, we will use a couple of fi...

blog post title

Sep 11, 2023 - Rajnish Katharotiya

P/E Ratios Using Normalized Earnings

Price to Earnings is one of the key metrics use to value companies using multiples. The P/E ratio and other multiples are relative valuation metrics and they cannot be looked at in isolation. One of the problems with the P/E metric is the fact that if we are in the peak of a business cycle, earni...

blog post title

Sep 11, 2023 - Rajnish Katharotiya

What is Business Risk and how to Measure it with Python

One of the key aspects to do well in the stock market is to know what is business risk. It is important to understand what type of business risks a company may have. Photo by Pixabay on Pexels What Is A Business Risk? Investopedia provides a very simple definition of business risk. Busin...

blog post title


Financial Modeling Prep API provides real time stock price, company financial statements, major index prices, stock historical data, forex real time rate and cryptocurrencies. Financial Modeling Prep stock price API is in real time, the company reports can be found in quarter or annual format, and goes back 30 years in history.
2017-2024 © Financial Modeling Prep