Skip to contents

This function allows you to search for ticker symbols, companies, ETFs, etc. using the Yahoo Finance search API. It can also return related news articles. The search functionality is particularly useful for discovering ticker symbols when you only know the company name or part of it.

Usage

search_tickers(
  query,
  limit = 10,
  quotes_only = TRUE,
  fuzzy_query = FALSE,
  lists_count = 0,
  enable_research = FALSE,
  proxy = NULL,
  output = c("tibble", "response", "request", "all")
)

Arguments

query

Search query string

limit

Maximum number of results to return (default 10)

quotes_only

Return only quotes/tickers, not news (default TRUE)

fuzzy_query

Enable fuzzy search for typos (default FALSE)

lists_count

Number of lists to retrieve (default 0)

enable_research

Include research reports (default FALSE)

proxy

Optional proxy settings

output

Object to return. Can be "tibble", "response", "request", or "all" (default "tibble")

Value

Depending on output parameter:

  • "tibble": quotes data (or a list with quotes and news if quotes_only is FALSE)

  • "response": raw response from the API

  • "request": the request object

  • "all": a named list containing all results: quotes, news, lists, research, and raw response

Rate Limiting

Yahoo Finance does not provide official API documentation or rate limits. Based on community observations, search queries may be more heavily rate-limited than other endpoints. To avoid rate limiting:

  • Limit the frequency of search requests

  • Cache search results when possible

  • Consider adding delays between requests (e.g., using Sys.sleep())

  • Use more specific search queries to reduce the number of needed requests

Examples

if (FALSE) { # \dontrun{
# Search for Apple
apple_results <- search_tickers("Apple")

# Search for tech companies with more results
tech_results <- search_tickers("tech", limit = 20)

# Get both quotes and news articles
apple_with_news <- search_tickers("Apple", quotes_only = FALSE)

# Get all data including lists and research reports
all_apple_data <- search_tickers(
  "Apple",
  quotes_only = FALSE,
  lists_count = 5,
  enable_research = TRUE,
  output = "all"
)
} # }