Fli Documentation

repository·main·Indexed 25 days ago

https://github.com/punitarani/fli

Fli is a flight search library and MCP server providing programmatic access to Google Flights data via direct API interaction. It includes a Python wrapper (flights package v0.10.0), a TypeScript library (fli-js), and a CLI for performing one-way, round-trip, and multi-city searches. Key features include date-range searches for cheapest fares, advanced filtering by alliance and layover, and the ability to generate deterministic Google Flights booking and search URLs. It also provides an MCP server (fli-mcp) for integration with AI assistants like Claude.

Tokens
35.5K
Snippets
76
Records
157
Agent score
82%

What's inside Fli

  1. Overview of Fli example capabilities

    main

    The Fli library examples cover a wide range of flight search scenarios. While most core features are available in both Python and TypeScript, some advanced features are currently specific to the Python implementation.

    Available in both Python and TypeScript:

    • One-way search
    • Round-trip search
    • Cheapest dates in a range
    • Multi-city itinerary
    • Advanced filters (alliances, exclusions, layovers, locale)
    • Error handling & client tuning

    Available in Python only:

    • Time-restricted search
    • Day-of-week / weekend date preferences
    • Validation-heavy round trips & date ranges
    • Price tracking over time
    • Result processing (using pandas)
  2. Install fli-js via npm or bun

    main

    Fli is available as a TypeScript port published to npm as fli-js. It provides the same models, filter encoding, and direct-API approach as the Python version.

    bun add fli-js   # or: npm install fli-js
  3. Run the Fli MCP Server over HTTP

    main

    For web-based integrations, you can run the server over a streamable HTTP transport. By default, it binds to 127.0.0.1:8000 and serves the MCP endpoint at /mcp/ (e.g., http://127.0.0.1:8000/mcp/).

    Use the fli-mcp-http command, or override the host and port by calling run_http directly in Python.

  4. Use Fli MCP tools in natural language conversations

    main

    Once the Fli MCP server is connected to an MCP client like Claude Desktop, you can perform flight searches using natural language. The server provides the following tools to the LLM:

    • search_flights: Used for specific flight searches (e.g., finding flights between specific airports or with specific cabin classes).
    • search_dates: Used to find the cheapest or most suitable dates for travel between two locations.
    • get_booking_options: Used to retrieve available booking details.
  5. Run Python flight search examples

    main

    To run the provided Python examples, you can use uv (recommended) or install the required dependencies manually.

    Required dependencies for manual installation:

    • pydantic
    • curl_cffi
    • httpx
    # Run with uv (recommended)
    uv run python examples/python/basic_one_way_search.py
    uv run python examples/python/date_range_search.py
    
    # Or install dependencies and run directly
    pip install pydantic curl_cffi httpx
    python examples/python/basic_one_way_search.py
  6. Run Fli TypeScript Examples

    main

    You can run the examples using Bun (recommended for direct .ts execution) or via Node.js using a TypeScript loader like tsx.

    Using Bun

    Run specific files or use the predefined package scripts for common search patterns.

    Using Node.js

    Use npx tsx to execute the TypeScript files directly.

    # Using Bun
    bun run basic_one_way_search.ts
    # or via package scripts:
    bun run basic         # one-way
    bun run round-trip    # round trip
    bun run dates         # cheapest dates in a range
    bun run multi-city    # 3-leg itinerary
    bun run advanced      # alliances + exclusions + locale
    bun run errors        # client tuning + typed error handling
    
    # Using Node
    npx tsx basic_one_way_search.ts
  7. Run Fli examples in Python or TypeScript

    main
    Fli provides practical, runnable examples for both Python and TypeScript. The examples are designed to mirror each other so you can compare the APIs side-by-side. All examples interact with the live Google Flights API. Note that requests are rate-limited to 10 requests per second.
  8. Run CI locally with act

    main

    To run GitHub Actions locally, install act and use the provided Makefile commands.

    brew install act
    
    # Run CI locally (lint + tests on Python 3.10-3.13)
    make ci
    
    # Or run CI inside Docker (no local act installation needed)
    make ci-docker