Skip to main content
The builders module provides utilities for constructing flight search filter objects from parsed parameters. These functions are used by both the CLI and MCP interfaces to build consistent search requests.

build_time_restrictions

Build a TimeRestrictions object from time window strings.
str | None
Departure time range in ‘HH-HH’ format (e.g., ‘6-20’ for 6 AM to 8 PM). Optional.
str | None
Arrival time range in ‘HH-HH’ format (e.g., ‘8-22’ for 8 AM to 10 PM). Optional.
Returns: TimeRestrictions object with parsed time constraints, or None if no restrictions specified

Usage

build_flight_segments

Build flight segments for a search request.
Airport
required
Departure airport enum
Airport
required
Arrival airport enum
str
required
Outbound travel date in YYYY-MM-DD format
str | None
Return travel date in YYYY-MM-DD format. If provided, creates a round-trip search. Optional.
TimeRestrictions | None
Time restrictions to apply to all segments. Optional.
Returns: Tuple of (list[FlightSegment], TripType)
  • List contains one segment for one-way trips, two segments for round-trips
  • TripType is either TripType.ONE_WAY or TripType.ROUND_TRIP

Usage

build_date_search_segments

Build flight segments for a date range search.
Airport
required
Departure airport enum
Airport
required
Arrival airport enum
str
required
Start date of the search range in YYYY-MM-DD format
int | None
Duration of the trip in days (for round trips). Defaults to 3 days if not specified. Optional.
bool
Whether to search for round-trip flights. Defaults to False. Optional.
TimeRestrictions | None
Time restrictions to apply to all segments. Optional.
Returns: Tuple of (list[FlightSegment], TripType)
  • For one-way searches: single segment with the start date
  • For round-trip searches: two segments, with return date calculated as start_date + trip_duration

Usage

Complete example

Here’s how the builder functions work together to create a complete flight search: