fa_summarize_prices(), fa_plot_prices(), and fa_find_best_dates()) now only accept flight_results objects returned from fa_fetch_flights().
fa_fetch_flights() to create flight_results objects before using analysis functionsThis change simplifies the API by enforcing a consistent workflow:
fa_define_query() or fa_define_query_range()fa_fetch_flights() to get flight_results objectsfa_create_date_range() has been renamed to fa_define_query_range() for consistency with fa_define_query(). The old function has been removed.fa_define_query_range()), fa_fetch_flights() now returns a flight_results object that:
$data field with all flight data accessible directly$BOM, $DEL)fa_summarize_prices() and fa_find_best_dates() now use flight_results as the parameter name instead of results for clarity and type safetyflights$data directly# Create queries for multiple origins
queries <- fa_define_query_range(
origin = c("BOM", "DEL"),
dest = "JFK",
date_min = "2025-12-18",
date_max = "2025-12-22"
)
# Fetch data - returns flight_results object with merged data
flights <- fa_fetch_flights(queries)
# Access merged data directly
flights$data
# Or access individual origin data
flights$BOM$data
flights$DEL$data
# Use with analysis functions
fa_summarize_prices(flights)
fa_find_best_dates(flights, n = 5)
This release represents a complete redesign of the package API following Tidyverse conventions with consistent fa_ prefixing for all user-facing functions.
Query Creation:
fa_define_query() - Create flight query objects for one-way, round-trip, chain-trip, or perfect-chain searchesfa_define_query_range() - Create query objects for multiple origins and datesData Fetching:
fa_fetch_flights() - Fetch flight data from Google Flights using chromoteAnalysis Functions:
fa_summarize_prices() - Create wide summary table showing prices by city/airport and datefa_find_best_dates() - Identify cheapest travel dates across routeslibrary(flightanalysis)
# Create a query
query <- fa_define_query("JFK", "IST", "2025-12-20", "2025-12-27")
# Fetch flight data
result <- fa_fetch_flights(query)
# Analyze results
summary <- fa_summarize_prices(result)
best <- fa_find_best_dates(result, n = 5)
# Search multiple origins over a date range
queries <- fa_define_query_range(
origin = c("BOM", "DEL", "VNS"),
dest = "JFK",
date_min = "2025-12-18",
date_max = "2026-01-05"
)
# Fetch data for each origin
for (code in names(queries)) {
queries[[code]] <- fa_fetch_flights(queries[[code]])
}
# Analyze all results
summary <- fa_summarize_prices(queries)
best_dates <- fa_find_best_dates(queries, n = 10, by = "mean")
The following functions are internal and not exported:
Flight() - Used internally for parsing scraped dataflights_to_dataframe() - Converts flight objects to data framesFunctions organized by purpose:
fa_define_query_range.R - Date range query creationfa_summarize_prices.R - Price summary tablesfa_find_best_dates.R - Best date identificationfilter_placeholder_rows.R - Data cleaning helpersscrape.R - Core query and fetching functionalityComprehensive examples in examples/ directory
Full test coverage in tests/testthat/
Suggested dependencies: chromote, progress