Type: Package
Title: Flexible Client for the 'Financial Modeling Prep' API
Version: 0.2.1
Description: Provides a flexible interface to the 'Financial Modeling Prep' API https://site.financialmodelingprep.com/developer/docs. The package supports all available endpoints and parameters, enabling R users to interact with a wide range of financial data.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
Depends: R (≥ 4.1)
Imports: httr2 (≥ 1.0.0), dplyr (≥ 1.0.0), cli (≥ 1.0.0)
Suggests: spelling, testthat (≥ 3.0.0)
URL: https://github.com/tidy-finance/r-fmpapi, https://tidy-finance.github.io/r-fmpapi/
BugReports: https://github.com/tidy-finance/r-fmpapi/issues
Config/testthat/edition: 3
Language: en-US
NeedsCompilation: no
Packaged: 2025-05-07 19:10:54 UTC; krise
Author: Christoph Scheuch ORCID iD [aut, cre, cph]
Maintainer: Christoph Scheuch <christoph@tidy-intelligence.com>
Repository: CRAN
Date/Publication: 2025-05-07 19:20:08 UTC

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

Description

Provides a flexible interface to the 'Financial Modeling Prep' API https://site.financialmodelingprep.com/developer/docs. The package supports all available endpoints and parameters, enabling R users to interact with a wide range of financial data.

Author(s)

Maintainer: Christoph Scheuch christoph@tidy-intelligence.com (ORCID) [copyright holder]

See Also

Useful links:


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

Description

This function fetches financial data from the FMP API, including balance sheet statements, income statements, cash flow statements, historical market data, stock lists, and company profiles.

Usage

fmp_get(
  resource,
  symbol = NULL,
  params = list(),
  api_version = "v3",
  snake_case = TRUE
)

Arguments

resource

A string indicating the API resource to query. Examples include "balance-sheet-statement", "income-statement", "cash-flow-statement", "historical-market-capitalization", "profile", and "stock/list".

symbol

A string specifying the stock ticker symbol (optional).

params

List of additional arguments to customize the query (optional).

api_version

A string specifying the version of the FMP API to use. Defaults to "v3".

snake_case

A boolean indicating whether column names are converted to snake_case. Defaults to TRUE.

Value

A data frame containing the processed financial data.

Examples

## Not run: 
# Get available balance sheet statements
fmp_get(
  resource = "balance-sheet-statement",
  symbol = "AAPL"
)

# Get last income statements
fmp_get(
  resource = "income-statement",
  symbol = "AAPL",
  params = list(limit = 1)
)

# Get annual cash flow statements
fmp_get(
  resource = "cash-flow-statement",
  symbol = "AAPL",
  params = list(period = "annual")
)

# Get historical market capitalization
fmp_get(
  resource = "historical-market-capitalization",
  symbol = "UNH",
  params = list(from = "2023-12-01", to = "2023-12-31")
)

# Get stock list
fmp_get(
  resource = "stock/list"
)

# Get company profile
fmp_get(
  resource = "profile", symbol = "AAPL"
)

# Search for stock information
fmp_get(
  resource = "search", params = list(query = "AAP")
)

# Get data with original column names
fmp_get(
  resource = "profile", symbol = "AAPL", snake_case = FALSE
)

## End(Not run)


Set the Financial Modeling Prep API key

Description

This function prompts the user to input their Financial Modeling Prep (FMP) API key and saves it to a .Renviron file, either in the project directory or the home directory. It also gives the user the option to add .Renviron to .gitignore for security purposes.

Usage

fmp_set_api_key()

Value

Invisibly returns TRUE after saving the key or aborting the operation. The function will read the .Renviron file after saving, allowing the environment variables to be immediately available. A restart of the R session is recommended.

Examples


fmp_set_api_key()