| Title: | Yahoo Finance 'screener' API |
|---|---|
| Description: | Simple and efficient access to Yahoo Finance's 'screener' API <https://finance.yahoo.com/research-hub/screener/> for querying and retrieving financial data. The 'yfscreen' package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, pagination, and JSON payload generation. This abstraction allows users to focus on filtering and retrieving data rather than managing API details. Use cases include screening across a range of security types such as equities, mutual funds, ETFs, indices, and futures. The package supports advanced query capabilities, including logical operators, nested filters, and customizable payloads. It handles pagination automatically, fetching results in batches of up to 250 entries per request for efficient retrieval of large datasets. Filters can be defined dynamically to support a wide range of screening needs. 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.3 |
| Built: | 2026-07-05 17:07:16 UTC |
| Source: | https://github.com/jasonjfoster/screen |
Simple and efficient access to Yahoo Finance's 'screener' API <https://finance.yahoo.com/research-hub/screener/> for querying and retrieving financial data. The 'yfscreen' package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, pagination, and JSON payload generation. This abstraction allows users to focus on filtering and retrieving data rather than managing API details. Use cases include screening across a range of security types such as equities, mutual funds, ETFs, indices, and futures. The package supports advanced query capabilities, including logical operators, nested filters, and customizable payloads. It handles pagination automatically, fetching results in batches of up to 250 entries per request for efficient retrieval of large datasets. Filters can be defined dynamically to support a wide range of screening needs. 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.
yfscreen is a package that provides simple and efficient access to Yahoo Finance's screener functionality for querying and retrieving financial data.
The core functionality of the yfscreen package abstracts the complexities of interacting with Yahoo Finance APIs, such as session management, crumb and cookie handling, query construction, pagination, and JSON payload generation. This abstraction allows users to focus on filtering and retrieving data rather than managing API details. Use cases include screening across a range of asset classes:
Equities: coverage spans 50 regions to enable the identification of top-performing stocks based on specified criteria
Mutual funds: funds can be screened using metrics such as historical performance, performance ratings, and other factors
ETFs: a wide range of ETFs can be filtered by criteria including expense ratio, historical performance, and additional attributes
Indices: stock market indices are available and often categorized by sector, industry, or the overall market
Futures: futures contracts can be screened by exchange, price percent changes, and regional specifications
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 function to create a payload to query the Yahoo Finance API with customizable parameters.
create_payload(sec_type = "equity", query = NULL, size = 25, offset = 0, sort_field = NULL, sort_type = NULL, top_operator = "and")create_payload(sec_type = "equity", query = NULL, size = 25, offset = 0, sort_field = NULL, sort_type = NULL, top_operator = "and")
sec_type |
string. Type of security to search (i.e., "equity", "mutualfund", "etf", "index", "future"). |
query |
list. Structured query to filter results created by
the |
size |
integer. Number of results to return. |
offset |
integer. Starting position of the results. |
sort_field |
string. Field to sort the results. |
sort_type |
string. Type of sort to apply (i.e., "asc", "desc"). |
top_operator |
string. Logical operator for the top-level of the query (i.e., "and", "or"). |
A list representing the payload to be sent to the Yahoo Finance API with the specified parameters.
filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters) payload <- create_payload("equity", query)filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters) payload <- create_payload("equity", query)
A function to create a structured query with logical operations and nested conditions formatted for the Yahoo Finance API.
create_query(filters = list("eq", list("region", "us")), top_operator = "and")create_query(filters = list("eq", list("region", "us")), top_operator = "and")
filters |
list. Each element is a sublist that defines a filtering condition with the following structure:
|
top_operator |
string. Top-level logical operator to combine all filters (i.e., "and", "or"). |
A nested list representing the structured query with logical operations and nested conditions formatted for the Yahoo Finance API.
filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters)filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters)
A data frame with the available category name data for the Yahoo Finance API.
data_categorynamedata_categoryname
A data frame.
A data frame with the available errors data for the Yahoo Finance API.
data_errorsdata_errors
A data frame.
A data frame with the available exchange data for the Yahoo Finance API.
data_exchangedata_exchange
A data frame.
A data frame with the available filters data for the Yahoo Finance API.
data_filtersdata_filters
A data frame.
A data frame with the available fund family name data for the Yahoo Finance API.
data_fundfamilynamedata_fundfamilyname
A data frame.
A data frame with the available industry data for the Yahoo Finance API.
data_industrydata_industry
A data frame.
A data frame with the available peer group data for the Yahoo Finance API.
data_peer_groupdata_peer_group
A data frame.
A data frame with the available region data for the Yahoo Finance API.
data_regiondata_region
A data frame.
A data frame with the available sector data for the Yahoo Finance API.
data_sectordata_sector
A data frame.
A function to get data from the Yahoo Finance API using the specified payload.
get_data(payload = NULL)get_data(payload = NULL)
payload |
list. Payload that contains search criteria created using
the |
A data frame that contains data from the Yahoo Finance API for the specified search criteria.
filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters) payload <- create_payload("equity", query) ## Not run: data <- get_data(payload) ## End(Not run)filters <- list( list("eq", list("region", "us")), list("btwn", list("intradaymarketcap", 2000000000, 10000000000)), list("btwn", list("intradaymarketcap", 10000000000, 100000000000)), list("gt", list("intradaymarketcap", 100000000000)), list("gt", list("dayvolume", 5000000)) ) query <- create_query(filters) payload <- create_payload("equity", query) ## Not run: data <- get_data(payload) ## 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()