fli: The Library That Turns Google Flights Into an API

A reverse-engineered Python stack that bypasses scraping, validates Google’s hidden flight data, and exposes it to scripts, CLIs, and AI assistants.

9 min read • View on GitHub • More from punitarani

A wide editorial scene shows a polished airport gate perched above a hidden machine room. In the foreground, a developer’s hand turns a key labeled as an internal API path, while beneath the gate nested pipes and structured request fragments move through a sealed system. It explains that the project opens Google Flights’ backstage machinery instead of scraping the visible page.
The big idea is simple: `fli` does not watch the screen. It speaks to the mechanism behind it.
Key Takeaways

Most flight tools start with a browser. `fli` starts one layer deeper. It treats Google Flights like a sealed machine with a private interface, then turns that interface into a Python library, a CLI, and an MCP server.

The hidden API under Google Flights

That is the core move. Instead of parsing HTML that changes whenever the UI does, `fli` talks to the structured endpoints behind Google Flights and receives structured data back. The result is less brittle, faster to parse, and much closer to the logic the product itself uses.

Unlike traditional flight search libraries that rely on web scraping methods, Fli offers structured access to flight data by interfacing directly with Google's API endpoints.

Why reverse engineering beats scraping here

ApproachData sourceReliabilityCostAccess frictionBest fitWeakness
fliGoogle Flights internal endpointsHighFreeLow once implementedDeveloper tooling and AI agentsDepends on a reverse-engineered interface
Web scraping toolsRendered HTMLLowFreeLow to start, high to maintainQuick one-off extractionBreaks when the UI changes
Commercial flight APIsGDS or airline contractsVery highPaidHighProduction travel productsExpensive and gated

The key insight is that a round-trip search is stateful. `fli` does not issue two unrelated queries. It stages one search, pins the outbound leg, and uses that state to shape the return leg and any flexible-date chunking.

A close-up drafting table shows two flight paths laid over each other. One route is pinned first, then a transparent hand adds the return route on top, while a small ledger of dates is split into narrower blocks beside it. It explains that the library models the search as a staged, stateful process rather than a flat query.
The most important implementation detail is not the endpoint itself. It is the way `fli` carries state from one leg of the trip into the next.

The search flow is stateful, not flat

This is where `fli` stops looking like a wrapper and starts looking like a model of Google Flights’ own interaction pattern. The library builds a nested request payload, sends it to the internal service, captures the outbound leg, and then reuses that chosen state when it asks for the return leg. Flexible dates add another layer: the search window is split into smaller chunks so the request stays inside the endpoint’s limits.

from fli import Fli

fli = Fli()
results = fli.search_flights(
    origin="JFK",
    destination="LHR",
    depart_date="2026-10-25",
    return_date="2026-11-02",
    cabin="business",
)

for trip in results:
    print(trip.total_price, trip.outbound.airline, trip.return_.airline)

From Python library to MCP tool

The MCP layer changes the size of the project. A normal library helps developers. An MCP server makes the same capability available to an assistant that can call tools, chain steps, and reason over flight results. In practice, `fli` becomes a travel primitive for agents, not just another search helper for scripts.

That is the real distribution story. Once the same search engine can serve a notebook, a terminal, and an LLM runtime, the project stops being one interface and becomes three.

The architecture behind the polish

The modularity matters. `fli/core` handles payload building and parsing. `fli/models` gives the project a schema. `fli/search` owns network behavior and search strategy. `fli/mcp` and `fli/cli` are thin surfaces on top. That split keeps a reverse-engineered system from collapsing into one giant script.

What `fli` replaces

BaselineWhy people use itWhy it falls shortWhere `fli` wins
Manual Google Flights useFast for one-off trip planningNot programmableIt gives you reusable structured data
Web scraping toolsEasy to prototypeBrittle and UI-dependentIt skips the DOM entirely
Commercial flight APIsReliable and supportedCost and access barriersIt is free and immediately accessible

The sweet spot is narrow but real. If you need a free, developer-friendly way to access Google Flights data, `fli` lands in a gap that commercial providers do not fill and scrapers cannot hold onto for long.

Why this project matters

`fli` points at a larger shift in software. Developers are moving away from brittle page scraping and toward direct interaction with the private backends that power modern products. At the same time, they are wrapping those capabilities in tool interfaces that AI systems can use without a human in the loop.

That is why this repo feels bigger than a flight library. It is a template for how reverse engineering, typed Python, and MCP can turn a sealed consumer app into a durable developer surface.