{"slug": "how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut", "title": "How to Use the Google Flights API in 2026 (Python, MCP, and a No-Code Shortcut)", "summary": "A developer detailed how to extract live flight prices from Google Flights using a hosted scraper on Apify, since Google retired its QPX Express API in 2018 and never released a public Google Flights API. The scraper accepts a route and date as JSON input and returns structured data including price, airlines, stops, duration, and booking links. The post also covers the limitations of building a custom scraper and provides code examples for using the Apify client in Python.", "body_md": "Getting live flight prices out of [Google Flights](https://www.google.com/travel/flights) by hand is a grind. There is no public API to call, the search URL hides the whole query behind an opaque `tfs`\n\nblob, and the page renders its results with JavaScript that fights simple scripts. I'll show the manual way and where it breaks, then a faster path, and a repo you can clone. The faster path uses the [Google Flights API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search?fpr=9n7kx3&fp_sid=devto) on Apify, which turns a route and a date into structured JSON.\n\nDisclosure: the Apify links in this post are affiliate links. If you run the Actor, I may earn a referral commission at no extra cost to you.\n\nNo. Google retired QPX Express in 2018 and has never shipped a public Google Flights API. There is no key to request and no endpoint to call, which is why a search for \"google flights api\" mostly turns up scraping libraries and hosted scrapers. So in practice a Google Flights API means a scraper you consume like an API: send a route and a date, get flights and prices back as JSON.\n\nThe Google Flights API returns every itinerary for a route as structured JSON: price, airlines, stops, duration, departure and arrival times, plus a price insight for the route and optional direct booking links.\n\n| Field | Example | Notes |\n|---|---|---|\n`price` |\n`299` |\nPer the search currency |\n`airlines` |\n`AA` |\nOperating carriers on the itinerary |\n`stops_label` |\n`Nonstop` |\nWith `stops` as an integer too |\n`duration` |\n`5h 30m` |\nTotal travel time |\n`price_insights` |\n`{ \"price_level\": \"typical\", \"typical_price_range\": [299, 450] }` |\nToday's fare against a normal band |\n`booking_url` |\n`https://www.jetblue.com/booking/...` |\nDirect link, one-way only |\n\nEach dataset item is one page of results holding many flights, and the flat `all_flights`\n\narray gives you one row per itinerary for easy loading into a table.\n\nTravel aggregators building fare comparison, indie developers tracking a route for a trip, analysts collecting pricing trends, and anyone wiring live fares into an AI agent.\n\nThe DIY route is to build the Google Flights URL yourself, render the page in a headless browser, and parse the result cards. It works in a quick local test, then falls over. The `tfs`\n\nparameter is a Base64 blob you have to reverse-engineer for every filter. The results load through JavaScript, so a plain HTTP request comes back nearly empty. And the layout shifts often enough that your selectors rot within a few weeks. Add proxies and retries on top, and you're maintaining infrastructure instead of shipping your feature.\n\nYou send a documented JSON input and get a documented JSON output, with nothing to keep alive.\n\n**Apify Console**\n\n`departure_id`\n\n, `arrival_id`\n\n, and `outbound_date`\n\n.**REST**\n\n```\ncurl -X POST \"https://api.apify.com/v2/acts/johnvc~Google-Flights-Data-Scraper-Flight-and-Price-Search/runs?token=YOUR_APIFY_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{ \"departure_id\": \"JFK\", \"arrival_id\": \"LHR\", \"outbound_date\": \"2026-11-25\", \"max_pages\": 1 }'\n```\n\nRun endpoint reference: the [Apify API docs](https://docs.apify.com/api/v2).\n\nCall the Actor with `apify-client`\n\n. The flat `all_flights`\n\narray is one row per itinerary:\n\n``` python\nfrom apify_client import ApifyClient\n\nclient = ApifyClient(\"YOUR_APIFY_TOKEN\")\n\nrun = client.actor(\"johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search\").call(\n    run_input={\n        \"departure_id\": \"JFK\",\n        \"arrival_id\": \"LHR\",\n        \"outbound_date\": \"2026-11-25\",\n        \"max_stops\": 0,\n        \"currency\": \"USD\",\n        \"max_pages\": 1,\n    }\n)\n\nfor page in client.dataset(run[\"defaultDatasetId\"]).iterate_items():\n    insights = page.get(\"price_insights\") or {}\n    print(insights.get(\"lowest_price\"), insights.get(\"price_level\"))\n    for flight in page.get(\"all_flights\", []):\n        print(flight[\"route\"], flight[\"price\"], flight[\"airlines\"], flight[\"stops_label\"], flight[\"duration\"])\n```\n\nThere is a ready-to-run version in the published task [Get Google Flights Prices in Python by API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/examples/get-google-flights-prices-in-python?fpr=9n7kx3&fp_sid=devto).\n\nA single search answers one question. The value comes from running the same search on a schedule and watching the fare move. Save the run as a task, attach an Apify schedule with a cron expression like `0 7 * * *`\n\n, and each run appends a fresh page with its own `search_timestamp`\n\nand `price_insights`\n\n, which gives you a fare history you can export. The worked example is the task [Track NYC to London flight prices by API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/examples/track-nyc-to-london-flight-prices-by-api?fpr=9n7kx3&fp_sid=devto).\n\nBoth `departure_id`\n\nand `arrival_id`\n\naccept comma-separated codes, so `CDG,ORY`\n\nsearches every Paris airport in one run. For multi-leg trips, pass `multi_city_json`\n\nwith a list of legs and the Actor prices the whole itinerary the way Google Flights does, including open-jaw routings. See the task [Find cheap flights from NYC to Europe by API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/examples/find-cheap-flights-from-nyc-to-europe-by-api?fpr=9n7kx3&fp_sid=devto).\n\nApify exposes the Actor through the Model Context Protocol, so Claude, Claude Code, and Cursor can run a live search mid-conversation and answer \"what is the cheapest nonstop from JFK to LHR next month\" with real data. The task [Use Google Flights in Claude via MCP](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search/examples/use-google-flights-in-claude-via-mcp?fpr=9n7kx3&fp_sid=devto) has the config, and you can read more about Claude Code at [claude.ai](https://claude.ai/referral/uIlpa7nPLg).\n\nThe 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**Clone the repository**\n\n```\ngit clone https://github.com/johnisanerd/Apify-Google-Flights-API.git\ncd Apify-Google-Flights-API\n```\n\n**Install dependencies with UV**\n\n```\n# Install UV if you do not have it:\n```\n\n…The repo has a Python quick start, the booking-options variant, and the MCP setup, so you can go from clone to first result in a few minutes.\n\nThere is no free official API to compare against, so the honest answer is per-page billing. A typical search fits on one page and costs one page event, and `max_pages`\n\ncaps the spend before a run starts. New Apify accounts come with free platform credit, so early searches usually cost nothing out of pocket. The one setting that changes the math is `fetch_booking_options`\n\n, since each resolved booking URL bills separately and a one-way search commonly returns 80 to 120 of them.\n\nCall the Actor with `apify-client`\n\nas shown above, then read the flat `all_flights`\n\narray for one row per flight. The published Python task carries a runnable version.\n\nYes. Connect the Apify MCP server to Claude, Claude Code, or Cursor and the Actor appears as a callable tool that runs a live search from your prompt.\n\nYes, and it is the most popular way to run it. Save a task per route, attach an Apify schedule with a cron expression, and each run appends a new page of fares. Scheduling is how the price-tracking use case works, and you can start from the [Google Flights API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search?fpr=9n7kx3&fp_sid=devto).\n\nNo, and treat anything that claims otherwise with suspicion. You get `price_insights`\n\n: a `price_level`\n\nfor the current fare and a `typical_price_range`\n\nfor the route. That is a read on today's fare against a normal band, not a forecast. If you want something forward-looking, schedule the scraper and model the trend from the record you own.\n\nYou can, and for a one-off you might. The tradeoff is the `tfs`\n\nblob, JavaScript rendering, proxies, and layout changes you then own forever. A hosted scraper trades a per-page fee for never touching that maintenance.\n\nSame Actor, other angles: [Give your AI agent real flight prices (Peerlist)](https://peerlist.io/johnvc/articles/give-your-ai-agent-real-flight-prices), [Google Flights API for AI Agents on Medium](https://medium.com/@finosint/google-flights-api-for-ai-agents-search-live-fares-via-mcp-6b3b4c6634bc), and the [Google Flights API write-up on LinkedIn](https://www.linkedin.com/pulse/google-flights-scraper-api-flight-prices-booking-links-zz85e/).\n\nA flight is one leg of a trip. These related Actors return the same kind of structured JSON: [Google Travel Explore API](https://apify.com/johnvc/google-travel-explore-api?fpr=9n7kx3&fp_sid=devto) for when you know the origin but not the destination, [Google Hotels Search Scraper](https://apify.com/johnvc/google-hotels-search-scraper?fpr=9n7kx3&fp_sid=devto) for the nights, and [Google Maps Directions API](https://apify.com/johnvc/google-maps-directions-api?fpr=9n7kx3&fp_sid=devto) for the airport-to-hotel leg.\n\nThere's no official Google Flights API, but you can still get the same data as clean JSON without babysitting a scraper. Try the [Google Flights API](https://apify.com/johnvc/Google-Flights-Data-Scraper-Flight-and-Price-Search?fpr=9n7kx3&fp_sid=devto), or clone the [example repo](https://github.com/johnisanerd/Apify-Google-Flights-API) and point it at your own routes.", "url": "https://wpnews.pro/news/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut", "canonical_source": "https://dev.to/trufflepig/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut-1ej6", "published_at": "2026-07-17 02:50:22+00:00", "updated_at": "2026-07-17 02:58:11.773274+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Google Flights", "Apify", "QPX Express", "JetBlue"], "alternates": {"html": "https://wpnews.pro/news/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut", "markdown": "https://wpnews.pro/news/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut.md", "text": "https://wpnews.pro/news/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut.txt", "jsonld": "https://wpnews.pro/news/how-to-use-the-google-flights-api-in-2026-python-mcp-and-a-no-code-shortcut.jsonld"}}