DEV Community

Dataspace
Dataspace

Posted on AI-assisted

How to Get Google Flights Data with Python (There Is No Official API)

If you have ever tried to build a fare tracker, a travel bot or a pricing dashboard, you have probably searched for a "Google Flights API". It does not exist anymore. Google shut down its public flight search API (QPX Express) in 2018, and Google Flights has no official API today.

In this post I show a simple way to get the same data that you see on Google Flights into Python: prices, airlines, flight numbers, times, stops, layovers, CO₂ emissions and Google's own "prices are low / typical / high" insight.

Disclosure: I built the tool used below, the Google Flights Scraper on Apify. It is a paid tool, but it runs on Apify's free monthly credit for small projects, and the code in this post works with any similar setup.

What data can you get?

For every flight option of a search you get one JSON object. Here is a real result for a round trip from Istanbul to Berlin (shortened):

{
  "origin": "IST",
  "destination": "BER",
  "departureDate": "2026-11-20",
  "returnDate": "2026-11-27",
  "tripType": "ROUND_TRIP",
  "price": 183,
  "currency": "USD",
  "priceLevel": "typical",
  "typicalPriceLow": 160,
  "typicalPriceHigh": 255,
  "airline": "Air Serbia",
  "flightNumbers": ["JU423", "JU356"],
  "departureTime": "2026-11-20T16:40",
  "arrivalTime": "2026-11-20T20:00",
  "durationText": "5h 20m",
  "stops": 1,
  "layovers": [{ "airport": "BEG", "city": "Belgrade", "durationMinutes": 105 }],
  "co2EmissionsKg": 212
}
Enter fullscreen mode Exit fullscreen mode

A few things that are hard to get elsewhere:

  • All options, not only the first page. Google shows about 20 "top flights" and hides the rest behind "View more flights". For New York JFK → London Heathrow on one day there were 104 options, not 21.
  • Google's price insight. priceLevel tells you if today's price is low, typical or high for that route, together with the typical price range. With includePriceInsights you also get the price history of the last ~60 days.
  • Every leg and layover, including aircraft type, legroom and emissions per leg.

Step 1: Install the client

You need a free Apify account and its API token (Console → Settings → API & Integrations).

pip install apify-client
Enter fullscreen mode Exit fullscreen mode

Step 2: Search flights from Python

Each search is one line: FROM-TO DEPARTURE [RETURN] with IATA airport or city codes. You can also use relative dates like +30 (30 days from today), which is handy for scheduled price tracking.

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("dataspace/google-flights-scraper").call(run_input={
    "searches": [
        "JFK-LHR +30",                    # one way, 30 days from today
        "IST-BER 2026-11-20 2026-11-27",  # round trip
        "NYC-PAR +45",                    # city codes search all airports
    ],
    "currency": "USD",
    "maxStops": "1",                      # nonstop or 1 stop
    "sortBy": "price",
    "maxResultsPerSearch": 50,
    "includePriceInsights": True,
})

items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
flights = [i for i in items if i["type"] == "flight"]
insights = [i for i in items if i["type"] == "searchSummary"]

for f in flights[:5]:
    print(f'{f["origin"]}-{f["destination"]} {f["price"]} {f["currency"]} '
          f'{f["airline"]} {f["durationText"]} stops={f["stops"]}')

for s in insights:
    print(f'{s["origin"]}-{s["destination"]}: cheapest {s["cheapestPrice"]}, '
          f'typical {s["typicalPriceLow"]}-{s["typicalPriceHigh"]}, prices are {s["priceLevel"]}')
Enter fullscreen mode Exit fullscreen mode

When I ran a search for New York JFK → London Heathrow, the summary said the cheapest fare was $325 while the typical range was $170–300, so priceLevel was high. That one field is often enough to decide whether to buy now or wait.

Step 3: Turn it into a fare alert

A simple fare alert is just the same run on a schedule plus a condition:

TARGET = 300  # USD

cheap = [f for f in flights if f["price"] and f["price"] <= TARGET]
if cheap:
    best = min(cheap, key=lambda f: f["price"])
    print(f'Deal: {best["origin"]}-{best["destination"]} for {best["price"]} USD '
          f'({best["airline"]}, {best["departureTime"]})')
    # send it to Slack, Telegram or e-mail here
Enter fullscreen mode Exit fullscreen mode

To run it every day without a server, create a Schedule in Apify Console for the Actor with relative dates (+30, +60) and connect a webhook, Make or Zapier to receive the results.

Useful options

Option What it does
flexibleDays Also search the next N days (find the cheapest day)
adults, children, cabinClass Passengers and Economy / Premium / Business / First
airlines IATA codes like TK, or STAR_ALLIANCE, ONEWORLD, SKYTEAM
country, currency Point of sale and currency (prices differ by country)
maxPrice, sortBy Filter and sort the options

How much does it cost?

The Actor charges $0.50 per 1,000 flight options (plus $0.00005 per run). A typical route search returns 20–150 options, so one search costs about $0.05. Apify's free plan includes a monthly platform credit, which covers roughly 10,000 flight results per month for small projects.

A note on responsible use

The data comes from the public Google Flights pages that anyone can open, without logging in. Use it for price research, analytics and alerts, keep request volumes reasonable, and check that your use fits the laws and terms that apply to you.


If you build something with it, I would love to hear about it in the comments. Questions and feature requests are welcome on the Actor's Issues tab.

Top comments (0)