Learn R Programming

r-fmpapi

Provides a flexible interface to the ‘Financial Modeling Prep’ API. The package supports all available endpoints and parameters, enabling R users to interact with a wide range of financial data.

This package is a product of Christoph Scheuch and not sponsored by or affiliated with FMP in any way. For a Python implementation, please consider the py-fmpapi library.

Installation

You can install the package from CRAN via:

install.packages("fmpapi")

You can install the development version from GitHub:

pak::pak("tidy-finance/r-fmpapi")

Setup

Before using the package, you need to set your Financial Modeling Prep API key. You can set it using the fmp_set_api_key() function, which saves the key to your .Renviron file for future use (either in your project or home folder).

library(fmpapi)

fmp_set_api_key()

Usage

Since the FMP API has a myriad of endpoints and parameters, the package provides a single function to handle requests: fmp_get().

You can retrieve a company’s profile by providing its stock symbol to the profile endpoint:

fmp_get(resource = "profile", symbol = "AAPL")

To retrieve the balance sheet statements for a company, use the balance-sheet-statement endpoint. You can specify whether to retrieve annual or quarterly data using the period parameter and the number of records via limit. Note that you need a paid account for quarterly data.

fmp_get(resource = "balance-sheet-statement", symbol = "AAPL", params = list(period = "annual", limit = 5))

The income-statement endpoint allows you to retrieve income statements for a specific stock symbol.

fmp_get(resource = "income-statement", symbol = "AAPL")

You can fetch cash flow statements using the cash-flow-statement endpoint.

fmp_get(resource = "cash-flow-statement", symbol = "AAPL")

Most free endpoints live under API version 3, but you can also control the api version in fmp_get(), which you need for some paid endpoints. For instance, the symbol_change endpoint:

fmp_get(resource = "symbol_change", api_version = "v4")

Relation to Existing Packages

There are two existing R packages that also provide an interface to the FMP API. Both packages lack flexibility because they provide dedicated functions for each endpoint, which means that users need to study both the FMP API docs and the package documentation and developers have to create new functions for each new endpoint.

  • fmpapi: not released on CRAN and last commit more than 3 years ago.
  • fmpcloudr: last updated on CRAN more than 3 years ago.

Contributing

Feel free to open issues or submit pull requests to improve the package. Contributions are welcome!

License

This package is licensed under the MIT License.

Copy Link

Version

Install

install.packages('fmpapi')

Monthly Downloads

437

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Christoph Scheuch

Last Published

December 19th, 2024

Functions in fmpapi (0.2.0)

perform_request

Perform a request to the Financial Modeling Prep API
fmp_set_api_key

Set the Financial Modeling Prep API key
fmp_get

Retrieve Financial Data from the Financial Modeling Prep (FMP) API
convert_column_types

Convert Column Types in a Data Frame
fmpapi-package

fmpapi: Flexible Client for the 'Financial Modeling Prep' API
convert_column_names

Convert Column Names to snake_case