SearchDates class helps you find the cheapest dates to fly by searching across date ranges. It’s perfect for flexible travel planning when you want to find the best prices rather than search specific dates.
Basic usage
One-way date search
Find the cheapest one-way flights across a date range:This example comes from
examples/date_range_search.py in the source code.Round-trip date search
Find the cheapest round-trip dates with a specific duration:Advanced filtering
Filter by day of week
Find weekend flights only:This example comes from
examples/date_search_with_preferences.py in the source code.Time restrictions
Search with departure time preferences:Cabin class preferences
Search for premium cabin dates:Weekend trip optimization
Find the cheapest weekend trips with validation:This example comes from
examples/advanced_date_search_validation.py in the source code.API reference
SearchDates class
Defined infli/search/dates.py:25.
Constructor
- Automatic rate limiting (10 requests/second)
- Retry logic with exponential backoff (up to 3 attempts)
- Browser impersonation for API access
search() method
filters(DateSearchFilters): Search parameters including date range, airports, and preferences
list[DatePrice]containing date and price pairs, orNoneif no results
Exception: If the search fails or returns invalid data
- Automatically splits date ranges over 61 days into multiple searches
- Can search up to 305 days in the future
- For round-trip searches, returns tuples of
(outbound_date, return_date)in eachDatePrice.date
fli/search/dates.py:42-99.
DateSearchFilters
Complete search configuration for date-based searches. Required fields:passenger_info(PassengerInfo): Passenger countsflight_segments(list[FlightSegment]): One or more flight segmentsfrom_date(str): Start of date range inYYYY-MM-DDformatto_date(str): End of date range inYYYY-MM-DDformat
trip_type(TripType):ONE_WAYorROUND_TRIP(default:ONE_WAY)duration(int): Trip duration in days for round-trip searchesseat_type(SeatType): Cabin class preferencestops(MaxStops): Stop preferencesairlines(list[Airline]): Filter by specific airlines
DatePrice
Contains date and price information. Fields:date(tuple[datetime] | tuple[datetime, datetime]): Date(s) for the flight- One-way: Single datetime in tuple
(departure_date,) - Round-trip: Two datetimes in tuple
(outbound_date, return_date)
- One-way: Single datetime in tuple
price(float): Flight price for the date(s)
fli/search/dates.py:18-22.
Date range limitations
The library handles chunking automatically:fli/search/dates.py:63-98.
Price tracking
Track prices over time to find the best deals:This example comes from
examples/price_tracking.py in the source code.Best practices
Use for flexible dates
Use for flexible dates
SearchDates is ideal when you have flexible travel dates and want to find the cheapest options. For specific dates, use SearchFlights instead.
Handle None results
Handle None results
Always check if results is
None before processing:Round-trip date structure
Round-trip date structure
For round-trip searches,
DatePrice.date contains a tuple of two datetimes:Consider chunking overhead
Consider chunking overhead
Date ranges over 61 days trigger multiple API calls. For very large ranges, consider breaking into smaller searches.
Filter results post-search
Filter results post-search
Use Python’s filtering capabilities to narrow results by day of week, price range, etc.:
Examples
Explore complete working examples:Date range search
Find cheapest dates to fly
Date search with preferences
Advanced date filtering with day-of-week preferences
Advanced date search validation
Comprehensive validation for round-trip date searches
Price tracking
Monitor price changes over time
Next steps
SearchFlights
Search for flights on specific dates
All examples
Browse 11 complete code examples