Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 2.22 KB

python.md

File metadata and controls

82 lines (62 loc) · 2.22 KB

Python (apify-client) — Google Flights Scraper

Call the Google Flights Scraper from Python with the official apify-client.

Install

pip install apify-client

Search and read the flights

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("logiover/google-flights-scraper").call(run_input={
    "origin": "JFK",
    "destination": "LHR",
    "departureDate": "2026-08-15",
    "tripType": "one-way",
    "seatClass": "economy",
    "currency": "USD",
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
print(f"Fetched {len(items)} itineraries")

for f in items:
    print(f'{f.get("airlines")} · {f.get("price")} {f.get("currency")} · '
          f'{f.get("stops")} stop(s) · {f.get("fromCode")}→{f.get("toCode")} '
          f'{f.get("departureTime")}-{f.get("arrivalTime")}')

Cheapest-day fare calendar into pandas

import pandas as pd
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("logiover/google-flights-scraper").call(run_input={
    "origin": "JFK",
    "destination": "LHR",
    "departureDate": "2026-08-01",
    "departureDateEnd": "2026-08-31",
    "currency": "USD",
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
df = pd.DataFrame(items)
calendar = df.groupby("departureDate")["price"].min().sort_values()
print(calendar)
calendar.to_csv("fare_calendar.csv")

Round-trip, find the cheapest fare

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("logiover/google-flights-scraper").call(run_input={
    "origin": "IST",
    "destination": "DXB",
    "departureDate": "2026-09-10",
    "returnDate": "2026-09-17",
    "tripType": "round-trip",
    "seatClass": "business",
    "currency": "EUR",
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
cheapest = min(items, key=lambda f: f["price"])
print("Cheapest:", cheapest["price"], cheapest["currency"], "on", cheapest["airlines"])

📄 Documentation only. ▶️ Run it: https://apify.com/logiover/google-flights-scraper