Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a structured Python workflow, use a provider that documents Google Flights search results: send it an origin, destination, trip type, and travel dates, then validate the JSON response and extract itinerary prices, flight legs, airports, and times. The example below uses SerpApi’s third-party Google Flights integration—not a Google-published Flights API—and is an adaptation of its documented interface, not a claim of independent testing.

What can you collect from a Google Flights search?

A result is best treated as an itinerary, not as one flat flight record. An itinerary may include a price and total duration, plus one or more flight legs. Each leg can provide details such as airline, departure and arrival airports, and local departure and arrival times. SerpApi documents fields including total_duration, carbon_emissions, airline, airport, and flight-time details; individual optional fields may be absent.

Results are useful for route and schedule research, comparing returned itineraries, and building a display that links travelers to current offers. They are not a booking guarantee. Prices and available offers are time-sensitive, so refresh the search and confirm the airline’s current offer details before a booking decision.

How to scrape Google Flights with Python

This example uses the SerpApi Python package to request a round trip. It reads the API key from the environment, calculates future travel dates, supplies a timeout, and handles HTTP errors, provider errors, and missing result groups. It prints each itinerary’s price and the airport identifiers and times available for its legs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

1. Install the package and set your key

Install the documented package in your Python environment:

python -m pip install serpapi

Set SERPAPI_KEY outside your source code. For example, in a Unix-like shell:

export SERPAPI_KEY="your_api_key"

In PowerShell, use $env:SERPAPI_KEY="your_api_key". Do not commit a real key to a repository. The SerpApi Python wrapper documentation describes environment-variable use and HTTP and timeout exceptions.

2. Search a route and inspect returned itineraries

import os
from datetime import date, timedelta

import serpapi

api_key = os.environ.get("SERPAPI_KEY")
if not api_key:
    raise RuntimeError("Set the SERPAPI_KEY environment variable first.")

# Replace these airport IATA codes and dates with your own search.
today = date.today()
outbound = today + timedelta(days=30)
returning = outbound + timedelta(days=7)

client = serpapi.Client(api_key=api_key)
params = {
    "engine": "google_flights",
    "departure_id": "JFK",
    "arrival_id": "LHR",
    "type": 1,  # round trip; see the provider's current parameter reference
    "outbound_date": outbound.isoformat(),
    "return_date": returning.isoformat(),
    "currency": "USD",
    "hl": "en",
    "gl": "us",
}

try:
    response = client.search(params)
    data = response.as_dict()
except Exception as exc:
    # The wrapper documents HTTP and timeout exceptions. Catching broadly here
    # keeps the example runnable across wrapper exception-class versions.
    raise RuntimeError(f"Google Flights search request failed: {exc}") from exc

if data.get("error"):
    raise RuntimeError(f"Search provider returned an error: {data['error']}")

itineraries = data.get("best_flights") or data.get("other_flights") or []
if not itineraries:
    print("The request returned no best_flights or other_flights results.")
else:
    for index, itinerary in enumerate(itineraries, start=1):
        print(f"Itinerary {index}: price={itinerary.get('price', 'not provided')}")
        print(f"  Duration: {itinerary.get('total_duration', 'not provided')}")
        for leg in itinerary.get("flights") or []:
            departure = leg.get("departure_airport") or {}
            arrival = leg.get("arrival_airport") or {}
            print(
                "  "
                f"{departure.get('id', 'unknown')} "
                f"{departure.get('time', 'time not provided')} -> "
                f"{arrival.get('id', 'unknown')} "
                f"{arrival.get('time', 'time not provided')}"
            )

The package interface and result-group fallback follow SerpApi’s Python Google Flights example. The code is illustrative: check the live provider documentation for current package behavior and accepted parameter values. Replace the example route with the airports relevant to your search.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Using ordinary HTTP requests instead

The provider also documents a direct HTTP GET pattern. This version makes the request and checks both HTTP status and a possible API-level error. Install requests with python -m pip install requests. The endpoint and parameter details can change, so confirm the provider’s current reference before deploying.

import os
from datetime import date, timedelta

import requests

api_key = os.environ.get("SERPAPI_KEY")
if not api_key:
    raise RuntimeError("Set the SERPAPI_KEY environment variable first.")

outbound = date.today() + timedelta(days=30)
returning = outbound + timedelta(days=7)
params = {
    "engine": "google_flights",
    "api_key": api_key,
    "departure_id": "JFK",
    "arrival_id": "LHR",
    "type": 1,
    "outbound_date": outbound.isoformat(),
    "return_date": returning.isoformat(),
    "currency": "USD",
    "hl": "en",
    "gl": "us",
}

try:
    response = requests.get(
        "https://serpapi.com/search.json", params=params, timeout=90
    )
    response.raise_for_status()
    data = response.json()
except requests.Timeout as exc:
    raise RuntimeError("The search timed out; retry with an appropriate backoff.") from exc
except requests.RequestException as exc:
    raise RuntimeError(f"HTTP request failed: {exc}") from exc
except ValueError as exc:
    raise RuntimeError("The response was not valid JSON.") from exc

if data.get("error"):
    raise RuntimeError(f"Search provider returned an error: {data['error']}")

itineraries = data.get("best_flights") or data.get("other_flights") or []
for itinerary in itineraries:
    print("Price:", itinerary.get("price", "not provided"))
    for leg in itinerary.get("flights") or []:
        departure = leg.get("departure_airport") or {}
        arrival = leg.get("arrival_airport") or {}
        print(
            departure.get("id", "unknown"), departure.get("time", "unknown"),
            "->", arrival.get("id", "unknown"), arrival.get("time", "unknown")
        )

The endpoint and parameters shown here reflect the documented SerpApi HTTP approach. For endpoint details and accepted parameters, see the Google Flights endpoint and parameter reference. A successful HTTP status alone does not mean the response contains flight results.

Which parameters do you need?

For a typical airport-pair search, provide the departure and arrival identifiers, trip type, and applicable date or dates. The documented parameter names below are SerpApi vendor details, not Google API guarantees. Verify their current accepted values and conditions in the provider reference.

Purpose Parameter How to use it
Origin and destination departure_id, arrival_id Airport IATA codes are a straightforward choice; supported place identifiers may also be accepted.
Trip type type Identifies round trip, one way, or multi-city. Confirm the current values with the provider.
Travel dates outbound_date, return_date Use YYYY-MM-DD. A round trip needs an outbound and return date; a one-way search needs its applicable outbound date.
Localization gl, hl, currency Country, language, and currency can affect localization and how offers are displayed.
Passenger and itinerary filters Travel class, passenger counts, sort, stops, airline controls, time windows Use the provider’s documented controls to narrow results; accepted values and conditions are provider-specific.

Round trips and one-way trips

The example uses an outbound date 30 days ahead and a return date seven days after that. These are demonstration calculations, not recommended travel dates. For a real search, use the traveler’s intended dates and check that the dates are valid for the itinerary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Multi-city trips

The documented multi-city format uses a JSON list of legs, each with its own departure, arrival, and date, rather than the top-level outbound and return date pattern. Consult the current endpoint reference for the precise serialized format and trip-type value before sending a multi-city query.

Localization and filters

Country (gl), language (hl), and currency influence localized results or presentation. Additional documented controls include cabin class, passenger counts, sort order, number of stops, airline inclusion or exclusion, and outbound or return time windows. Add only the filters your application needs: every extra constraint can narrow the returned set, and a result set that is empty does not by itself show that no flights exist.

How to parse fares, routes, and times safely

Do not assume every response contains both result groups or that every itinerary has every field. A resilient parser checks for best_flights, falls back to other_flights, and treats missing price, duration, flight legs, airport objects, or time values as unavailable rather than crashing.

  • Fare: Read the itinerary’s price when present. Do not treat it as a guaranteed purchase price.
  • Route: Iterate the itinerary’s flights array. A connection itinerary may have multiple legs, so preserve their order instead of assuming one flight object.
  • Times and airports: Read departure and arrival airport details from each leg when present. Preserve the returned time string and its associated airport; do not silently reinterpret it as a timestamp in your server’s timezone.
  • Duration and emissions: Fields such as total_duration and carbon_emissions can be useful when returned, but are not guaranteed on every record.

For production, normalize fields into your own schema while retaining the raw response for debugging where your data and retention policies permit. Keep absent values nullable or explicitly marked as unavailable; do not substitute a guessed fare, airport, or time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Direct page scraping, access rules, and practical limits

The documented approach here is a managed structured-result workflow. The reviewed provider material does not establish a stable public Google Flights page schema or a supported direct page-scraping interface. A script built on requests and BeautifulSoup or on browser automation should not be presented as a reliable way to retrieve fares: page structure and access behavior can change.

Google’s Terms of Service, under “Don’t abuse our services,” say users must not use automated means to access content in violation of machine-readable instructions on Google pages, and must not bypass Google’s systems or protective measures. Automated access should respect the applicable instructions and terms. This is not a blanket legal conclusion about all scraping or every jurisdiction.

A third-party service returning structured results does not, by itself, establish permission for every use case. Review the service terms, applicable Google instructions, and the legal requirements for your own application and location. Do not treat bypassing protective measures as an ordinary implementation step.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When an airline offers API may fit better

If your application needs airline-sourced offers or a booking flow rather than Google Flights-style search results, an airline offers API is a different integration choice. Duffel documents an offer-request workflow: describe passengers and journey slices, then receive offers from a range of airlines. It is not a drop-in Google Flights replica and does not guarantee identical route coverage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Duffel notes that airline search results can be incomplete within a supplier timeout, and its offer documentation says prices and service details can change. Refresh offer details when a traveler is considering booking rather than presenting a search-time price as guaranteed at purchase. Choose between these approaches based on whether you need Google-specific coverage, airline sourcing and booking support, route/date and passenger filters, integration effort, and refresh behavior. See Duffel Offer Requests and Duffel Offers.

Troubleshooting common failures

Symptom Likely cause What to check
Missing-key error before the request SERPAPI_KEY is not set in the process environment. Set the variable in the same shell or runtime that launches Python. Avoid embedding the secret in committed code.
Authentication or provider error The key may be absent, invalid, or rejected; the provider may also return an API-level error in JSON. Check the provider account and inspect the response’s error field without logging the key.
HTTP timeout or network exception The service or network did not complete the request within the timeout. Handle the exception, check connectivity, and retry cautiously with a suitable backoff. Do not loop without limits.
HTTP success but no itineraries The response may contain no best_flights or other_flights, or the filters and route may yield no returned results. Inspect the response structure and provider error field; verify airport identifiers, dates, trip type, and restrictive filters.
Key error when reading a field An optional result field or nested airport object is absent. Use .get(), handle missing objects, and iterate over flights only when it is present.
Unexpectedly different prices or schedules Offers are time-sensitive and may change between search and booking. Refresh the search and confirm current details with the airline or booking flow before purchase.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a Google Flights data API. It does not replace the structured flight-results workflow above. For a webpage capture, one GET request can return an image or PDF; see the ScreenshotNeo site and API documentation.

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.

FAQ

Is SerpApi’s Google Flights integration a Google API?

No. It is a third-party service that documents retrieval of Google Flights results; it is not a Google-published Flights API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I use these results as a final booking quote?

No. Treat them as search-time results and confirm the current offer details in the booking flow.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.