| Title: | Yahoo Finance 'history' API |
|---|---|
| Description: | Simple and efficient access to Yahoo Finance's 'history' API <https://finance.yahoo.com/> for querying and retrieving financial data. The 'yfhist' package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, date validation, and interval management. This abstraction allows users to focus on retrieving data rather than managing API details. Use cases include retrieving historical data across a range of security types such as equities and ETFs, indices, and other tickers. The package supports flexible query capabilities, including customizable date ranges, multiple time intervals, and automatic data validation. It manages interval-specific limitations automatically, such as lookback periods for intraday data and maximum date ranges for minute-level intervals. The implementation uses standard HTTP libraries to handle API interactions efficiently and is available in both R and 'Python' for accessibility to a broad audience. |
| Authors: | Jason Foster [aut, cre] |
| Maintainer: | Jason Foster <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.4 |
| Built: | 2026-06-05 02:51:29 UTC |
| Source: | https://github.com/jasonjfoster/hist |
Simple and efficient access to Yahoo Finance's 'history' API <https://finance.yahoo.com/> for querying and retrieving financial data. The 'yfhist' package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, date validation, and interval management. This abstraction allows users to focus on retrieving data rather than managing API details. Use cases include retrieving historical data across a range of security types such as equities and ETFs, indices, and other tickers. The package supports flexible query capabilities, including customizable date ranges, multiple time intervals, and automatic data validation. It manages interval-specific limitations automatically, such as lookback periods for intraday data and maximum date ranges for minute-level intervals. The implementation uses standard HTTP libraries to handle API interactions efficiently and is available in both R and 'Python' for accessibility to a broad audience.
yfhist is a package that provides simple and efficient access to Yahoo Finance's history functionality for querying and retrieving financial data.
The core functionality of the yfhist package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, date validation, and interval management. This abstraction allows users to focus on retrieving data rather than managing API details. Use cases include retrieving historical data across a range of security types:
Equities and ETFs: end-of-day or intraday Open, High, Low, Close, Volume (OHLCV), and adjusted close prices
Indices: levels over time for benchmarking and research
Other tickers: additional symbols supported by Yahoo Finance where chart data is available
The implementation leverages standard HTTP libraries to handle API interactions efficiently and provides support for both R and Python to ensure accessibility for a broad audience.
Jason Foster [aut, cre]
A data frame with the available intervals data for the Yahoo Finance API.
data_intervalsdata_intervals
A data frame.
A function to get a column from data retrieved from the Yahoo Finance API.
get_col(data, col)get_col(data, col)
data |
data frame or list. Data that contains an |
col |
string. Column name to get (i.e., "open", "high", "low", "close", "adjclose", "volume"). |
A data frame with rows as the index and columns as the symbols.
## Not run: data <- get_data(c("AAPL", "MSFT")) adj <- get_col(data, "adjclose") ## End(Not run)## Not run: data <- get_data(c("AAPL", "MSFT")) adj <- get_col(data, "adjclose") ## End(Not run)
A function to get data from the Yahoo Finance API for symbols using a date range and interval.
get_data(symbols, from_date = "2007-01-01", to_date = NULL, interval = "1d")get_data(symbols, from_date = "2007-01-01", to_date = NULL, interval = "1d")
symbols |
string. Symbol or vector of symbols. |
from_date |
string. Start date in |
to_date |
string. End date in |
interval |
string. Data interval (see |
A data frame or list of data frame(s) that contains data from the Yahoo Finance API for the specified symbol(s).
## Not run: data <- get_data(c("AAPL", "MSFT")) ## End(Not run)## Not run: data <- get_data(c("AAPL", "MSFT")) ## End(Not run)
A function to get the crumb, cookies, and handle required to authenticate and interact with the Yahoo Finance API.
get_session()get_session()
A list containing the following elements:
handle |
A curl handle object for subsequent requests. |
crumb |
A string representing the crumb value for authentication. |
cookies |
A data frame of cookies for the request. |
session <- get_session()session <- get_session()