Skip to main content
The 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

Find the cheapest one-way flights across a date range:
This example comes from examples/date_range_search.py in the source code.
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 in fli/search/dates.py:25.

Constructor

Creates a new instance with an initialized HTTP client. The client includes:
  • Automatic rate limiting (10 requests/second)
  • Retry logic with exponential backoff (up to 3 attempts)
  • Browser impersonation for API access

search() method

Parameters:
  • filters (DateSearchFilters): Search parameters including date range, airports, and preferences
Returns:
  • list[DatePrice] containing date and price pairs, or None if no results
Raises:
  • Exception: If the search fails or returns invalid data
Implementation notes:
  • 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 each DatePrice.date
See implementation at fli/search/dates.py:42-99.

DateSearchFilters

Complete search configuration for date-based searches. Required fields:
  • passenger_info (PassengerInfo): Passenger counts
  • flight_segments (list[FlightSegment]): One or more flight segments
  • from_date (str): Start of date range in YYYY-MM-DD format
  • to_date (str): End of date range in YYYY-MM-DD format
Optional fields:
  • trip_type (TripType): ONE_WAY or ROUND_TRIP (default: ONE_WAY)
  • duration (int): Trip duration in days for round-trip searches
  • seat_type (SeatType): Cabin class preference
  • stops (MaxStops): Stop preferences
  • airlines (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)
  • price (float): Flight price for the date(s)
Defined in fli/search/dates.py:18-22.

Date range limitations

Important limitations:
  • Maximum single search: 61 days (automatically chunked if larger)
  • Maximum future date: 305 days from today
  • Date ranges over 61 days will trigger multiple API calls
The library handles chunking automatically:
See chunking implementation at 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

SearchDates is ideal when you have flexible travel dates and want to find the cheapest options. For specific dates, use SearchFlights instead.
Always check if results is None before processing:
For round-trip searches, DatePrice.date contains a tuple of two datetimes:
Date ranges over 61 days trigger multiple API calls. For very large ranges, consider breaking into smaller searches.
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