Skip to main content
This guide covers advanced Fli features for complex flight searches including round-trip flights, multi-passenger bookings, and time-based restrictions.

Round-trip searches

Round-trip searches require two flight segments and the ROUND_TRIP trip type:

Processing round-trip results

Round-trip searches return tuples of (outbound_flight, return_flight):
Round-trip results include separate FlightResult objects for outbound and return, making it easy to analyze each direction independently.

Limiting return flight results

By default, Fli fetches return flights for the top 5 outbound flights. Adjust this with the top_n parameter:
Increasing top_n makes more API requests and takes longer. For round-trip searches with top_n=10, Fli makes 11 requests (1 for outbound + 10 for returns).

Multi-passenger bookings

Search for flights with multiple passengers using the PassengerInfo model:

Passenger types

  • adults - Passengers 18 years and older
  • children - Passengers 2-17 years old
  • infants_on_lap - Infants under 2 years old sitting on a lap (no seat)
  • infants_in_seat - Infants under 2 years old with their own seat

Pricing with multiple passengers

The returned flight.price is the total price for all passengers:

Time restrictions

Control departure and arrival times for each flight segment:

Time format

All times are in hours from midnight (0-23) in local airport time:
  • 0 = midnight
  • 6 = 6:00 AM
  • 12 = noon
  • 18 = 6:00 PM
  • 23 = 11:00 PM

Different restrictions per segment

Apply different time restrictions to each segment of a round-trip:
Time restrictions are per segment. For multi-leg flights, the restriction applies to the first leg’s departure and last leg’s arrival.

Date range searches

Find the cheapest dates to fly within a date range using SearchDates:

Round-trip date searches

For round-trips, specify the trip duration:
Date range searches are limited to 305 days in the future. Fli automatically splits searches longer than 61 days into multiple API calls.

Filtering date results

Filter results by day of the week or other criteria:

Layover control

Manage layover airports and durations:

Layover preferences

The airports parameter suggests preferred layover locations but doesn’t guarantee them:
The max_duration applies to each individual layover, not the total layover time for multi-stop flights.

Processing flight legs

Each FlightResult contains one or more FlightLeg objects:

Result analysis

Analyze search results to find patterns:

Builder utilities

Use builder functions for common search patterns:
The builder utilities automatically set the trip_type based on whether a return_date is provided.