get_info {yfinancer} | R Documentation |
Retrieve asset information from Yahoo Finance
Description
This function retrieves detailed asset information from Yahoo Finance's quoteSummary API. It can fetch various types of data including asset profiles, financial statements, key statistics, and more. The function supports retrieving multiple data modules in a single request.
Usage
get_info(
ticker,
modules = "summaryProfile",
output = c("tibble", "list", "response", "request"),
proxy = NULL
)
Arguments
ticker |
A ticker name or ticker object created with |
modules |
Character vector of module names to retrieve. Default is "summaryProfile". See section "Available Modules" for common options. |
output |
The type of output to return. Can be "tibble" (default), "list" (raw parsed JSON), "response" (httr2 response), or "request" (httr2 request). |
proxy |
Optional proxy settings for the request. |
Value
Depending on the output parameter and number of modules requested:
For a single module with output="tibble": A tibble containing the module data
For multiple modules with output="tibble": A named list of tibbles, one per module
For output="list": The raw parsed JSON data
For output="response": The httr2 response object
For output="request": The httr2 request object
Available Modules
The modules
parameter accepts any of the valid module names from Yahoo Finance API.
Common modules include:
-
"assetProfile"
: Asset overview, description, industry, sector, officers -
"summaryProfile"
: Brief asset profile information -
"financialData"
: Key financial metrics and ratios -
"defaultKeyStatistics"
: Important statistics like market cap, P/E ratio -
"incomeStatementHistory"
: Annual income statements -
"incomeStatementHistoryQuarterly"
: Quarterly income statements -
"balanceSheetHistory"
: Annual balance sheets -
"balanceSheetHistoryQuarterly"
: Quarterly balance sheets -
"cashflowStatementHistory"
: Annual cash flow statements -
"cashflowStatementHistoryQuarterly"
: Quarterly cash flow statements
See valid_modules
for a complete list of available modules.
Authentication
This function requires authentication via two components:
-
A1 Cookie: Session identifier
-
Crumb: Security token
Authentication methods (in order of priority):
Environment variables:
YFINANCE_CRUMB
andYFINANCE_A1
Saved auth file:
~/.yfinance/auth
Auto-generated using curl-impersonate (requires installation)
Example:
Sys.setenv(YFINANCE_CRUMB = "your-crumb") Sys.setenv(YFINANCE_A1 = "your-a1-cookie")
See https://github.com/lwthiker/curl-impersonate for curl-impersonate installation.
Option 3 above expects curl_chrome110
to be installed and available in the system path.
Examples
## Not run:
# Get a single ticker
apple <- get_tickers("AAPL")
# Get summary information
# using default module "summaryProfile"
apple_summary <- get_info(apple)
# Get basic company profile
apple_profile <- get_info(apple, modules = "assetProfile")
# Get key financial metrics
apple_financials <- get_info(apple, modules = "financialData")
# Get multiple modules as a list of tibbles
apple_data <- get_info(apple,
modules = c("incomeStatementHistory", "balanceSheetHistory", "cashflowStatementHistory")
)
# Access specific financial statements
income_statement <- apple_data$incomeStatementHistory
balance_sheet <- apple_data$balanceSheetHistory
# Get raw JSON response for custom processing
apple_raw <- get_info(apple, modules = "assetProfile", output = "response")
## End(Not run)