Overview
TheSearchFlights class handles searching for specific flights with detailed filters, parsing the results into structured data models. It interfaces directly with Google Flights’ API to find available flights and their details.
Class initialization
Methods
search
Search for flights using the given filters.Full flight search object including airports, dates, and preferences
Number of flights to limit the return flight search to
For one-way trips: list of
FlightResult objects containing flight detailsFor round-trip: list of tuples containing (outbound FlightResult, return FlightResult) pairsReturns None if no results foundException: If the search fails or returns invalid data
Return types
FlightResult
EachFlightResult object contains:
Flight price in the search currency
Total flight duration in minutes
Number of stops (0 for non-stop)
List of individual flight leg details
FlightLeg
EachFlightLeg object contains:
Airline operating the flight leg
Flight number (e.g., “AA123”)
Departure airport code
Arrival airport code
Departure date and time
Arrival date and time
Leg duration in minutes
Notes
- For round-trip searches, the method automatically searches for return flights for the top N outbound flights
- The search client includes automatic rate limiting (10 req/sec) and retries
- Prices may be 0.0 if price data is unavailable from the API