Skip to main content
The Fli Python library provides a clean, typed interface for searching Google Flights data programmatically. It uses direct API integration (not web scraping) with built-in rate limiting and retry logic.

Installation

Quick start

Here’s a basic one-way flight search:

Core classes

SearchFlights

The SearchFlights class handles specific flight searches with detailed filters. Use it when you know your travel dates and want to find available flights. Key features:
  • Search one-way or round-trip flights
  • Filter by cabin class, stops, airlines, and more
  • Set time restrictions for departures and arrivals
  • Automatic rate limiting (10 requests/second)
  • Built-in retry logic with exponential backoff
Returns:
  • For one-way: List of FlightResult objects
  • For round-trip: List of tuples (outbound_flight, return_flight)
Learn more about SearchFlights →

SearchDates

The SearchDates class finds the cheapest dates to fly within a date range. Use it for flexible travel planning when you want to find the best prices. Key features:
  • Search across date ranges (up to 305 days in future)
  • Automatic chunking for ranges over 61 days
  • Filter by cabin class, stops, airlines, and more
  • Returns price data for each date in range
Returns:
  • List of DatePrice objects containing date and price pairs
Learn more about SearchDates →

Data models

Fli uses Pydantic models for type safety and validation:

FlightSearchFilters

Complete search configuration for SearchFlights:

DateSearchFilters

Complete search configuration for SearchDates:

FlightSegment

Defines a single leg of the journey:

FlightResult

Contains complete flight information:

FlightLeg

Details for a single flight:

DatePrice

Price information for specific dates:

Enums and filters

Airport

IATA airport codes as enums:

Airline

IATA airline codes as enums:

SeatType

Cabin class options:

MaxStops

Stop preferences:

SortBy

Result sorting options:

Rate limiting and retries

The library includes automatic rate limiting and retry logic:
  • Rate limit: 10 requests per second
  • Retries: Up to 3 attempts with exponential backoff
  • Session management: Persistent HTTP sessions for efficiency
  • Browser impersonation: Uses curl-cffi to mimic browser behavior
You don’t need to implement your own retry logic - it’s built into the HTTP client at fli/search/client.py:38-39,62-63.

Error handling

Both SearchFlights and SearchDates raise exceptions on failures:
The library automatically handles:
  • Network errors (with retries)
  • Rate limit errors (with backoff)
  • Invalid API responses

Next steps

SearchFlights

Search for specific flights with detailed filters

SearchDates

Find the cheapest dates to fly

Examples

Explore 11 complete code examples