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.
- `fli` is interesting because it speaks to Google Flights’ hidden service layer instead of scraping the public page.
- The library’s real trick is turning a consumer product’s internal logic into structured Python data, then reusing that same engine in a CLI and MCP server.
- Its round-trip search flow is stateful, so the second leg is not a fresh search but a continuation of the first one.
- Compared with scraping tools and commercial travel APIs, `fli` sits in a rare middle ground: free, structured, and immediately useful to developers and agents.
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
| Approach | Data source | Reliability | Cost | Access friction | Best fit | Weakness |
|---|---|---|---|---|---|---|
| fli | Google Flights internal endpoints | High | Free | Low once implemented | Developer tooling and AI agents | Depends on a reverse-engineered interface |
| Web scraping tools | Rendered HTML | Low | Free | Low to start, high to maintain | Quick one-off extraction | Breaks when the UI changes |
| Commercial flight APIs | GDS or airline contracts | Very high | Paid | High | Production travel products | Expensive and gated |
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.
- `fli/core` turns human travel intent into Google’s nested request format.
- `fli/search` owns the live interaction with the service and the search state.
- `fli/models` keeps the output strict enough to trust in downstream code.
- `fli/mcp` and `fli/cli` expose the same engine to people and agents.
What `fli` replaces
| Baseline | Why people use it | Why it falls short | Where `fli` wins |
|---|---|---|---|
| Manual Google Flights use | Fast for one-off trip planning | Not programmable | It gives you reusable structured data |
| Web scraping tools | Easy to prototype | Brittle and UI-dependent | It skips the DOM entirely |
| Commercial flight APIs | Reliable and supported | Cost and access barriers | It 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.





