{
  "markdown": "# ✈️ Google Flights API: Flight and Price Search in Clean JSON\n\n> The most efficient, reliable, and developer-friendly way to use the Google Flights API.\n\n**Actor page:** [apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search?fpr=9n7kx3)\n**Input schema:** [apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/input-schema](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/input-schema?fpr=9n7kx3)\n\nThe Google Flights API searches flights and returns clean, structured JSON. Each page of results comes back with the top recommended flights and alternatives, full flight legs and timings, prices, price insights (level and historical range), airport details, and search metadata. It supports one-way, round-trip, and multi-city itineraries, single or multiple airports, filters for price, stops, airlines, and passenger counts, and can optionally resolve direct airline and OTA booking links. Localized across 29+ languages and 39+ countries.\n\n## Video Walkthrough\n\n[![Watch the walkthrough](https://img.youtube.com/vi/jREWahDGhJM/maxresdefault.jpg)](https://www.youtube.com/watch?v=jREWahDGhJM)\n\n## Quick Start\n\n### Prerequisites\n- Python 3.11 or higher\n- An Apify account and API key ([get a free key here](https://apify.com?fpr=9n7kx3))\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/johnisanerd/Apify-Google-Flights-API.git\n   cd Apify-Google-Flights-API\n   ```\n\n2. **Install dependencies with UV**\n   ```bash\n   # Install UV if you do not have it:\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n\n   # Install project dependencies:\n   uv sync\n   ```\n\n3. **Configure your API key**\n   ```bash\n   cp .env.example .env\n   # Edit .env and add your Apify API key\n   # Get your free API key at: https://apify.com?fpr=9n7kx3\n   ```\n\n4. **Run the example**\n   ```bash\n   uv run python google-flights-api.py\n   ```\n\nThis repo also includes **`google-flights-get-booking-options.py`**, a low-cost one-way example (BOS to PQI) that enables `fetch_booking_options` to resolve direct airline and OTA booking links:\n```bash\nuv run python google-flights-get-booking-options.py\n```\n\n### Alternative: set the API key directly\n```bash\nexport APIFY_API_TOKEN=\"your_api_key_here\"\nuv run python google-flights-api.py\n```\n\n## Why Use This Google Flights API?\n\n**Complete itineraries.** Search one-way, round-trip, and multi-city trips, with single or multiple departure and arrival airports, and get the top recommended flights plus alternatives with full leg-by-leg detail.\n\n**Direct booking links.** Enable `fetch_booking_options` and each flight resolves to a live booking URL on the airline or OTA site, with fare families and baggage fees, ready to embed in your app.\n\n**Powerful filters.** Constrain by max price, max stops, preferred airlines, passenger counts, and exclude basic economy.\n\n**Price intelligence.** Every search returns price insights: the current level (low, typical, high) and a historical price range for the route.\n\n**Predictable, pay-per-use pricing.** Billing is per page processed, plus per resolved booking link only when you ask for them. No subscription. You control cost with the page limit.\n\n**Easy to automate.** Call it from Python in a few lines, or load it as an MCP tool so assistants like Claude and Cursor can search flights for you on demand.\n\n## Features\n\n### Core Capabilities\n- **One-way, round-trip, and multi-city** itineraries\n- **Single or multiple airports** per leg (e.g. `CDG,ORY`)\n- **Filters** for price, stops, airlines, passengers, and basic economy\n- **Optional direct booking links** (airline/OTA URLs, fare families, baggage fees)\n- **Localization** across 29+ languages and 39+ countries\n\n### Data Quality\n- **Best and alternative flights** with full leg timings, airline, and duration\n- **Price insights** with level and historical range\n- **Airport details** for departure and arrival\n- **Per-page metadata** and search parameters echoed back\n- **Consistent JSON** shape across every query\n\n## Usage Examples\n\n### Basic one-way search\n```json\n{\n  \"departure_id\": \"LAX\",\n  \"arrival_id\": \"JFK\",\n  \"outbound_date\": \"2026-06-17\",\n  \"adults\": 1,\n  \"currency\": \"USD\",\n  \"max_pages\": 1\n}\n```\n\n### Round trip with filters\n```json\n{\n  \"departure_id\": \"JFK\",\n  \"arrival_id\": \"LHR\",\n  \"outbound_date\": \"2026-11-25\",\n  \"return_date\": \"2026-12-02\",\n  \"adults\": 2,\n  \"max_price\": 1500,\n  \"max_stops\": 1,\n  \"max_pages\": 2\n}\n```\n\n### Multi-city trip\n```json\n{\n  \"multi_city_json\": \"[{\\\"departure_id\\\":\\\"CDG\\\",\\\"arrival_id\\\":\\\"NRT\\\",\\\"date\\\":\\\"2026-11-17\\\"},{\\\"departure_id\\\":\\\"NRT\\\",\\\"arrival_id\\\":\\\"LAX\\\",\\\"date\\\":\\\"2026-11-24\\\"}]\",\n  \"adults\": 1,\n  \"currency\": \"USD\",\n  \"max_pages\": 1\n}\n```\n\n### Direct booking links\n```json\n{\n  \"departure_id\": \"LAX\",\n  \"arrival_id\": \"JFK\",\n  \"outbound_date\": \"2026-06-17\",\n  \"adults\": 1,\n  \"fetch_booking_options\": true,\n  \"max_pages\": 1\n}\n```\nNote: `fetch_booking_options` works for one-way searches, is billed per resolved link, and needs Actor memory of 512 MB or more (it uses a headless browser).\n\n## Input Parameters\n\nEither `departure_id` + `arrival_id` + `outbound_date`, or `multi_city_json`, is required.\n\n| Parameter | Type | Required | Default | Description |\n|-----------|------|----------|---------|-------------|\n| `departure_id` | `string` | Yes* | - | Departure airport code(s), comma-separated for multiple (e.g. `LAX`, `CDG,ORY`). |\n| `arrival_id` | `string` | Yes* | - | Arrival airport code(s), comma-separated for multiple. |\n| `outbound_date` | `string` | Yes* | - | Departure date, `YYYY-MM-DD`. |\n| `return_date` | `string` | No | (none) | Return date for round trips, `YYYY-MM-DD`. |\n| `multi_city_json` | `string` | Yes* | - | JSON string of legs for multi-city trips. Replaces the three fields above. |\n| `adults` | `integer` | No | `1` | Adult passengers (minimum 1). |\n| `children` | `integer` | No | `0` | Child passengers. |\n| `infants` | `integer` | No | `0` | Infant passengers. |\n| `currency` | `string` | No | `USD` | Currency code, e.g. `USD`, `EUR`, `GBP`. |\n| `hl` | `string` | No | `en` | Language code (29+ supported). |\n| `gl` | `string` | No | `us` | Country code (39+ supported). |\n| `max_price` | `integer` | No | (none) | Maximum price filter in the chosen currency. |\n| `max_stops` | `integer` | No | (none) | Maximum stops (`0` = direct only). |\n| `airlines` | `string` | No | (none) | Comma-separated preferred airline codes, e.g. `UA,AA,DL`. |\n| `exclude_basic` | `boolean` | No | `false` | Exclude basic-economy fares. |\n| `fetch_booking_options` | `boolean` | No | `false` | Resolve direct booking links (one-way only; billed per link; needs 512 MB+). |\n| `max_pages` | `integer` | No | `1` | Maximum pages to fetch (`0` = no limit). |\n| `output_file` | `string` | No | (none) | Optional filename to save results. |\n\n## Output Format\n\nA real result for `LAX` to `JFK` (one item per page; `best_flights` legs and the `price_insights` history are trimmed here for readability).\n\n```json\n{\n  \"search_parameters\": {\n    \"trip_type_description\": \"One-way\",\n    \"departure_id\": \"LAX\",\n    \"arrival_id\": \"JFK\",\n    \"outbound_date\": \"2026-06-17\",\n    \"adults\": 1,\n    \"currency\": \"USD\",\n    \"language\": \"en\",\n    \"country\": \"us\"\n  },\n  \"search_metadata\": {\n    \"total_flights_found\": 29,\n    \"best_flights_count\": 3,\n    \"other_flights_count\": 26,\n    \"pages_processed\": 1,\n    \"pagination_limit_reached\": true,\n    \"booking_options_count\": 0\n  },\n  \"page_number\": 1,\n  \"best_flights\": [\n    {\n      \"price\": 207,\n      \"type\": \"One way\",\n      \"total_duration\": 590,\n      \"flights\": [\n        {\n          \"departure_airport\": { \"name\": \"Los Angeles International Airport\", \"id\": \"LAX\", \"time\": \"2026-06-17 09:24\" },\n          \"arrival_airport\": { \"name\": \"Charlotte Douglas International Airport\", \"id\": \"CLT\", \"time\": \"2026-06-17 17:28\" },\n          \"airline\": \"American\",\n          \"flight_number\": \"AA 2570\",\n          \"travel_class\": \"Economy\",\n          \"duration\": 304\n        },\n        {\n          \"departure_airport\": { \"name\": \"Charlotte Douglas International Airport\", \"id\": \"CLT\", \"time\": \"2026-06-17 20:11\" },\n          \"arrival_airport\": { \"name\": \"John F. Kennedy International Airport\", \"id\": \"JFK\", \"time\": \"2026-06-17 22:14\" },\n          \"airline\": \"American\",\n          \"flight_number\": \"AA 1727\",\n          \"travel_class\": \"Economy\",\n          \"duration\": 123\n        }\n      ]\n    }\n  ],\n  \"other_flights\": [],\n  \"price_insights\": {\n    \"lowest_price\": 207,\n    \"price_level\": \"typical\",\n    \"typical_price_range\": [145, 255]\n  },\n  \"airports\": [\n    {\n      \"departure\": [\n        { \"airport\": { \"id\": \"LAX\", \"name\": \"Los Angeles International Airport\" }, \"city\": \"Los Angeles\", \"country\": \"United States\" }\n      ],\n      \"arrival\": [\n        { \"airport\": { \"id\": \"JFK\", \"name\": \"John F. Kennedy International Airport\" }, \"city\": \"New York\", \"country\": \"United States\" }\n      ]\n    }\n  ],\n  \"booking_options\": []\n}\n```\n\nWhen `fetch_booking_options` is `true`, each `booking_options` entry includes a resolved `booking_url` to the airline or OTA, plus fare family and baggage details.\n\n---\n\n## Use as an MCP tool\n\nYou can load the Google Flights API as an MCP tool so assistants call it for you. The MCP server URL preloads just this one Actor:\n\n```\nhttps://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\n```\n\nAuthenticate with OAuth in the browser when offered, or with your Apify API token (the same `APIFY_API_TOKEN` used by the Python example). Get a token at https://console.apify.com/settings/integrations and a free Apify account at https://apify.com?fpr=9n7kx3 .\n\n## Install in Claude Cowork Desktop\n\n![Install in Claude Cowork Desktop](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_desktop.png)\n\nCowork is the desktop app's automation mode. To give it the Google Flights API as a tool, add the Apify MCP server as a connector.\n\n1. Open the Claude desktop app and go to **Settings → Connectors** (or **Settings → Developer → Edit Config** to edit `claude_desktop_config.json` directly).\n   - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`\n   - Windows: `%APPDATA%\\Claude\\claude_desktop_config.json`\n2. Add the Apify MCP server, preloaded with only this Actor:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote\",\n        \"https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\"\n      ]\n    }\n  }\n}\n```\n\n3. Restart the app. When Cowork first calls the tool, complete the OAuth prompt in your browser, or add your Apify API token in the connector settings to skip OAuth.\n4. In a Cowork chat, confirm the tool is available and ask it to run the Google Flights API.\n\nDownload the desktop app and start a free trial: https://claude.ai/referral/uIlpa7nPLg\nMore help: https://docs.apify.com/platform/integrations/claude-desktop\n\n## Install in Claude Code\n\n![Install in Claude Code](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_code.png)\n\nClaude Code is the command-line tool. Add the Actor's MCP server with one command:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\"\n```\n\nTo use a token instead of browser OAuth:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\" \\\n  --header \"Authorization: Bearer YOUR_APIFY_TOKEN\"\n```\n\nThen verify with `claude mcp list`, or run `/mcp` inside a session. Ask Claude Code to call the Google Flights API.\n\nTry Claude Code free: https://claude.ai/referral/uIlpa7nPLg\nClaude Code MCP docs: https://code.claude.com/docs/en/mcp\n\n## Install in Claude (website)\n\n![Install in Claude (website)](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_ai.png)\n\nOn claude.ai you add Apify as a connector, then enable just this Actor's tool.\n\n1. Go to **Settings → Connectors → Browse connectors** and search for **Apify MCP server**. Install it (enable or update if prompted).\n2. When connecting, authenticate with your Apify API token, and enable the tool `johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search`.\n3. In any chat, open **+ → Connectors** and turn on **Apify**.\n4. Alternatively, choose **Add custom connector** and paste the full MCP URL `https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search`, using OAuth when prompted.\n5. Ask Claude to run the Google Flights API.\n\nOpen Claude on the web: https://claude.ai/referral/uIlpa7nPLg\n\n## Install in Cursor\n\n![Install in Cursor](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_cursor.png)\n\nCursor reads MCP servers from a project file at `.cursor/mcp.json`.\n\n1. In your project, create `.cursor/mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\"\n    }\n  }\n}\n```\n\n2. If you prefer token auth over browser OAuth, add a header:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\",\n      \"headers\": { \"Authorization\": \"Bearer YOUR_APIFY_TOKEN\" }\n    }\n  }\n}\n```\n\n3. Open **Cursor → Settings → MCP** and confirm the **apify** server is connected (green dot).\n4. In Composer or Chat, ask Cursor to call the Google Flights API.\n\nNew to Cursor? Get it here: https://cursor.com/referral?code=XQP4VBLI3NNX\n\n## Install in ChatGPT\n\n![Install in ChatGPT](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_ChatGPT.png)\n\nChatGPT connects to the Apify MCP server through Developer mode (available on ChatGPT Pro, Plus, Business, Enterprise, and Education plans).\n\n1. Click your profile icon, then go to **Settings > Apps**. If you do not see a **Create app** button, open **Advanced settings** and enable **Developer mode**.\n2. Click **Create app** and fill out the form:\n   - **Name:** Apify\n   - **MCP Server URL:** `https://mcp.apify.com/?tools=actors,docs,johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search`\n   - **Authentication:** OAuth\n3. Click **Create** and authorize the connection with Apify.\n4. To use the app in a conversation, click **+** in the chat, choose **Developer mode**, and select **Apify**.\n\nMore help: https://docs.apify.com/platform/integrations/mcp\n\n---\n\n[**Made with care**](https://apify.com/johnvc?fpr=9n7kx3)\n\n*Use the Google Flights API to power travel apps, fare tracking, and analytics with reliable, structured results.*\n\nLast Updated: 2026.09.07\n",
  "bytes": 14995,
  "sha": "19c982ff1ccf5e70b4c4963d45837e731257b1de3d00ae8c2069605878001efc",
  "repo_slug": "johnisanerd/apify-google-flights-api",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_johnisanerd_google_flights_4fd4ed6b/readme"
}