API Hop

Guides

Google Flights API: Search Fares & Deals in Python

Use Google Flights API in Python after QPX shutdown: query search, airport autocomplete & deals at $0.0003/req with code and pricing math.

Reviewed:

Google shut down its official QPX Express flight API in 2018 and offers no public self-serve Google Flights API for developers. Through the API Hop Google Flights Data API, three synchronous GET endpoints—flight search, airport autocomplete, and deals discovery—cost a flat $0.0003 per successful request ($0.30 per 1,000 calls), roughly 30x lower than SerpApi subscriptions, letting you build fare trackers and travel agents in Python in under 10 minutes.

Key Takeaways

  • No Official Public Google Flights API: Google retired QPX Express in April 2018. For fare monitoring and itinerary comparison without enterprise GDS contracts or fragile headless scrapers, a managed REST data API gives direct access to structured Google Flights results.
  • Three GET Endpoints Priced at $0.0003 Each: GET /v1/google-flights/search, GET /v1/google-flights/autocomplete, and GET /v1/google-flights/deals all bill $0.0003 per successful call (300 credits) with zero monthly fee.
  • Strict Trip-Type and Token Rules: Round trips (type=1) require return_date, one-way queries (type=2) reject return_date, and multi-city searches (type=3) require 2 to 5 legs in multi_city_json. Never send departure_token and booking_token together, and note that each token lookup is a separate billable request.
  • Failed Calls Refund; Empty Results Bill: Upstream errors and 60-second timeouts release your credit hold with no automatic retry. A successful response returning results: [] still counts as one billable $0.0003 call.
  • $10 Minimum Top-Up Covers 33,333 Searches: A $10 prepaid balance on the API Hop Pricing page never expires and supports USDT/USDC crypto alongside Brazil PIX and Indonesia QRIS/GoPay/DANA with no overseas credit card required.

Five Ways to Access Google Flights Data in 2026

Compare onboarding barriers, billing models, and engineering trade-offs across the five main flight-data options (verified 2026-11-28):

Access RouteAccess Barrier & FocusBilling ModelEst. Cost for 10,000 SearchesMain Limitation
SerpApi (engine=google_flights)Self-serve signupMonthly subscription (Developer $75/mo for 5,000, Production $150/mo for 15,000)$100.00–$150.00Unused monthly quota expires; round-trip leg selection consumes extra calls
SearchApi / FlightPowersSelf-serve signupTiered plans (SearchApi ~$4.00/1K; FlightPowers ~$10/2,500 searches)~$40.00Still tied to monthly plans or fixed credit bundles
Open-Source fast_flights (Python)Free GitHub libraryFree library + self-managed residential proxies$0 (+ $10–$40+/mo proxies)Cloud data-center IPs face frequent blocks and DOM breakage
Duffel / Amadeus (NDC / GDS)Business verification (focused on live ticketing)Per-booking fees or tiered search contractsVaries by airline contractHeavy onboarding; lacks Google Flights price insights and explore feeds
API Hop Google Flights APISelf-serve, instant Bearer keyPay-as-you-go $0.0003 / successful call ($0 monthly fee)$3.00Read-only fare and itinerary data (no direct ticket checkout); client handles token steps

Prerequisites

Prepare three items before running your first query:

  1. API Hop Key: Create an account on the API Hop Pricing page and generate a key. Billing is prepaid pay-as-you-go ($10 minimum top-up, non-expiring credits) with no US credit card or corporate KYC needed—accepting USDT/USDC crypto plus regional wallets like Brazil PIX and Indonesia QRIS, GoPay, and DANA.
  2. Local Runtime: Python 3.9+ with requests installed, or standard curl.
  3. Contract Bookmarks: Keep the Google Flights API Overview and Google Flights Endpoint Reference open for all 35+ query parameters, currency codes, and validation rules.
pip install -U requests
export APIHOP_API_KEY="sk-your-apihop-key"

Quickstart: First Flight Search in 2 Minutes

All Google Flights endpoints accept GET query parameters with no request body and authenticate via Authorization: Bearer. Run a one-way JFK to LAX search ($0.0003/call):

curl --get "https://api.apihop.ai/v1/google-flights/search" \
  -H "Authorization: Bearer $APIHOP_API_KEY" \
  --data-urlencode "departure_id=JFK" \
  --data-urlencode "arrival_id=LAX" \
  --data-urlencode "outbound_date=2026-12-12" \
  --data-urlencode "type=2" \
  --data-urlencode "currency=USD"

Expected response envelope preserving native precision (illustrative shape; live payloads reflect current results, and empty matches return an empty results array):

{
  "success": true,
  "request_id": "req_01j9flights...",
  "data": {
    "format": "json",
    "content": {
      "results": []
    }
  }
}

Minimal Python Example

import os
import requests

resp = requests.get(
    "https://api.apihop.ai/v1/google-flights/search",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params={"departure_id": "JFK", "arrival_id": "LAX", "outbound_date": "2026-12-12", "type": "2", "currency": "USD"},
    timeout=60,
)
resp.raise_for_status()
payload = resp.json()
print("request_id:", payload.get("request_id"), "keys:", list(payload.get("data", {}).get("content", {}).keys()))

Expected output: request_id: req_... keys: [...] showing top-level keys inside content.

Step-by-Step Guide: Autocomplete, Filtered Search, and Deals

Travel apps and AI booking assistants typically chain these three endpoints: resolve city names into IATA codes, query filtered itineraries, and explore flexible low-fare destinations.

Step 1: Resolve Airport Codes with /autocomplete ($0.0003/call)

Never pass free-text city names like "New York" directly to /search. Call GET /v1/google-flights/autocomplete first to resolve 3-letter IATA airport codes (JFK) or Google Travel entity IDs (/m/02_286). Add exclude_regions=true to filter out country-level entries:

import os
import requests

r = requests.get(
    "https://api.apihop.ai/v1/google-flights/autocomplete",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params={"query": "New York", "exclude_regions": "true", "limit": 5, "language": "en"},
    timeout=60,
)
r.raise_for_status()
print("Autocomplete X-Request-Id:", r.headers.get("X-Request-Id"), "status:", r.json().get("success"))

Expected output: Autocomplete X-Request-Id: ... status: True. You can pass comma-separated codes such as JFK,LGA,EWR into departure_id or arrival_id on /search.

Step 2: Query Round-Trip Fares with Cabin and Airline Filters ($0.0003/call)

GET /v1/google-flights/search supports over 30 filters including stops=1 (nonstop), travel_class (economy, premium_economy, business, first), alliance codes (STAR_ALLIANCE, SKYTEAM, ONEWORLD), and carry-on bags (cannot exceed adults + children + infants_in_seat):

import os
import requests

params = {
    "departure_id": "SFO",
    "arrival_id": "NRT",
    "outbound_date": "2026-12-10",
    "return_date": "2026-12-20",
    "type": "1",
    "adults": 1,
    "travel_class": "economy",
    "stops": 1,
    "sort_by": "price",
    "currency": "USD",
    "zero_trace": "true",
}
r = requests.get(
    "https://api.apihop.ai/v1/google-flights/search",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params=params,
    timeout=60,
)
r.raise_for_status()
print("Search success:", r.json().get("success"), "req:", r.headers.get("X-Request-Id"))

Expected output: Search success: True req: .... Passing zero_trace=true tells the gateway not to archive source or parsed artifacts for sensitive enterprise queries.

Step 3: Discover Flexible Destinations with /deals ($0.0003/call)

When travelers want the cheapest destinations from a hub without fixed destinations, call GET /v1/google-flights/deals. departure_id is required, paired either with natural-language query (e.g., "Week long trip to a city with great food") or with travel_duration (1 one week, 2 weekend, 3 two weeks) and max_price:

import os
import requests

r = requests.get(
    "https://api.apihop.ai/v1/google-flights/deals",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params={
        "departure_id": "JFK",
        "travel_duration": 2,
        "stops": 1,
        "max_price": 450,
        "currency": "USD",
        "limit": 10,
    },
    timeout=60,
)
r.raise_for_status()
print("Deals status:", r.json().get("success"), "req:", r.headers.get("X-Request-Id"))

Expected output: Deals status: True req: .... Note that travel_duration cannot be combined with query or exact dates. Review full parameter rules in the Google Flights Endpoint Reference.

Complete Working Example: Resolve Airport, Search Fares, Retry, and Save JSON

This production-ready Python script resolves an origin city, fetches round-trip fares with 429/5xx exponential backoff, saves the JSON response, and reports exact request spend:

import json
import os
import time
import requests

API_KEY = os.environ["APIHOP_API_KEY"]
BASE_URL = "https://api.apihop.ai/v1/google-flights"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}


def call_flights(path: str, params: dict, max_retries: int = 3) -> dict:
    for attempt in range(max_retries):
        resp = requests.get(f"{BASE_URL}{path}", headers=HEADERS, params=params, timeout=60)
        req_id = resp.headers.get("X-Request-Id")
        if resp.status_code == 200:
            body = resp.json()
            if body.get("success") is False:
                raise RuntimeError(f"API business error: {body} (req={req_id})")
            return body
        if resp.status_code in (429, 500, 502, 503, 504) and attempt < max_retries - 1:
            wait = 2 ** (attempt + 1)
            print(f"[Retry {attempt + 1}] HTTP {resp.status_code}, sleep {wait}s (req={req_id})")
            time.sleep(wait)
            continue
        resp.raise_for_status()
    raise RuntimeError("Max retries exceeded")


def search_route(origin_city: str, dest_iata: str, out_date: str, ret_date: str | None = None):
    requests_used = 0
    ac = call_flights("/autocomplete", {"query": origin_city, "exclude_regions": "true", "limit": 3})
    requests_used += 1
    content_ac = ac.get("data", {}).get("content", {})
    print(f"Resolved origin '{origin_city}' keys: {list(content_ac.keys())}")

    # In production parse the top IATA from content_ac; using JFK here as an example
    search_params = {
        "departure_id": "JFK",
        "arrival_id": dest_iata,
        "outbound_date": out_date,
        "currency": "USD",
        "sort_by": "price",
        "type": 1 if ret_date else 2,
    }
    if ret_date:
        search_params["return_date"] = ret_date

    flights = call_flights("/search", search_params)
    requests_used += 1

    out_file = f"flights_JFK_{dest_iata}_{out_date}.json"
    with open(out_file, "w", encoding="utf-8") as f:
        json.dump(flights, f, ensure_ascii=False, indent=2)

    cost = requests_used * 0.0003
    print(f"Saved {out_file} | Requests: {requests_used} | Est. Cost: ${cost:.4f}")


if __name__ == "__main__":
    search_route("New York", "LAX", "2026-12-12", "2026-12-19")

Expected output: prints Resolved origin 'New York' keys: [...], writes flights_JFK_LAX_2026-12-12.json, and prints Requests: 2 | Est. Cost: $0.0006.

Round-trip outbound results return a departure_token on each flight option. To retrieve matching return legs or final booking_token checkout links, repeat all original itinerary parameters alongside the fresh token on GET /v1/google-flights/search:

import os
import requests

# Each token lookup counts as one separate $0.0003 request
r = requests.get(
    "https://api.apihop.ai/v1/google-flights/search",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params={
        "departure_id": "JFK",
        "arrival_id": "LAX",
        "outbound_date": "2026-12-12",
        "return_date": "2026-12-19",
        "type": "1",
        "departure_token": "PASTE_FRESH_DEPARTURE_TOKEN_HERE",
    },
    timeout=60,
)
print("HTTP:", r.status_code)

Keep two rules in mind: first, departure_token and booking_token are mutually exclusive in a single request. Second, tokens expire quickly, so always copy the exact string from a fresh response.

Error Handling

Log the X-Request-Id response header on every call to speed up diagnostics:

HTTP StatusMeaning & Common CauseRecommended Action
400Validation failure (e.g., return_date with type=2, unsupported html/output/no_cache, both tokens sent, >9 travelers)Check constraints in the Google Flights Endpoint Reference
401Missing or invalid Authorization: Bearer keyVerify APIHOP_API_KEY environment variable
402Insufficient prepaid creditsTop up on the API Hop Pricing page
403Gateway access denied for this API keyCheck key permissions in your dashboard
405Sent POST or a request body to a GET-only endpointUse GET with query parameters and body = null
429Rate or concurrency limit reachedAdd pacing delays and 2s / 4s exponential backoff
5xx / 60s timeoutUpstream or service failure (hold released, not billed)Retry 1–2 times and keep X-Request-Id

Common Issues and Gotchas

  1. Sending return_date with type=2 or omitting it with type=1: Validation enforces type=1 requires return_date while type=2 forbids return_date. Omitting type lets the gateway infer round-trip or one-way from whether return_date is present.
  2. Combining travel_duration with query or exact dates on /deals: travel_duration (1/2/3) is strictly for flexible date discovery and triggers 400 if paired with query or fixed outbound_date/return_date values.
  3. Passing generic SERP flags like html, output, json_restrictor, or no_cache: All four parameters are explicitly unsupported and cause an immediate HTTP 400 rejection.
  4. Using exclude_basic=true outside US economy routes: Documentation specifies exclude_basic=true requires country=us (default) and travel_class=economy (default).
  5. Sending both departure_token and booking_token together: The contract enforces NOT (departure_token AND booking_token) and requires repeating the original departure_id, arrival_id, and date fields on every token call.

Cost Estimation

At API Hop’s published rate of $0.0003 per successful request ($0.30 per 1,000 calls), compare four real-world workloads against SerpApi’s monthly plans ($75/mo for 5,000 calls = $0.015/call; $150/mo for 15,000 calls = $0.010/call):

$$\text{Task Cost} = (N_{\text{autocomplete}} + N_{\text{search}} + N_{\text{deals}} + N_{\text{token}}) \times $0.0003$$

WorkloadCost FormulaAPI Hop SpendSerpApi Plan Est. (Ref.)
Run This Tutorial Script (1 autocomplete + 1 search)2 × $0.0003$0.0006 (<0.1 cent)Requires $75/mo minimum plan
Daily Fare Monitor for 20 Routes (monthly)20 × 30 days = 600 × $0.0003$0.18 / month$75 / month (Developer tier)
AI Travel Assistant (300 searches + 100 deals/day)400 × 30 = 12,000 × $0.0003$3.60 / month$150 / month (Production 15K tier)
OTA Fare Calendar (2,000 date-matrix queries/day)60,000 × $0.0003$18.00 / monthHigher enterprise tier ($600+/mo)

A $10 minimum top-up on the API Hop Pricing page covers 33,333 Google Flights requests with credits that never expire. The same balance also works across the API Hop Data API Catalog—including Google Hotels, Airbnb, and Google Travel Explore—plus LLMs like DeepSeek and Claude for end-to-end trip planners.

What to Watch Next

  • deep_search Compatibility: Both deep_search=true and false already execute the full streaming search under the hood, so legacy integrations require no extra parameter tuning.
  • Two-Step Round-Trip Token Budgets: Fetching outbound flights, return flights (departure_token), and checkout links (booking_token) consumes 3 /search calls ($0.0009 total). Cache identical route lookups in Redis to avoid duplicate charges.

FAQ

Is the Google Flights API free?

No. Google shut down its official developer QPX Express API in April 2018 and provides no free self-serve Google Flights API. Community Python libraries like fast_flights are free to install, but direct cloud IP scraping frequently gets blocked. For reliable REST access with zero monthly fee, a $10 non-expiring top-up on the API Hop Pricing page prices every call at $0.0003—running this tutorial costs just $0.0006.

How does API Hop Google Flights API pricing work?

There is no monthly subscription. GET /v1/google-flights/search, GET /v1/google-flights/autocomplete, and GET /v1/google-flights/deals all cost $0.0003 per successful request (300 credits, or $0.30 per 1,000 calls). Token lookups (departure_token or booking_token) and empty successful results each bill 1 request, while failed or timed-out upstream calls release the credit hold.

Can this API book or issue airline tickets directly?

No. The Google Flights Data API is read-only for fare discovery, flight schedules, and booking_token links. If your product requires passenger PNR creation and payment checkout, integrate an NDC or GDS ticketing API such as Duffel or Amadeus alongside fare search.

/search validates departure_id and arrival_id strictly against 3-letter uppercase IATA airport codes (like JFK) or Google Travel /m/ or /g/ entity IDs. Passing plain city text triggers HTTP 400, so calling /autocomplete ($0.0003) first ensures clean, multi-airport identifiers.

What payment methods are supported without a US credit card?

API Hop supports self-serve prepaid top-ups globally without a US credit card or business KYC. On the API Hop Pricing page, you can pay with USDT/USDC crypto as well as regional wallets including Brazil PIX and Indonesia QRIS, GoPay, and DANA.

Verification note: The 3 Google Flights endpoint paths, validation rules, and $0.0003 per successful request rate were verified on 2026-11-28 against API Hop reference docs and public market pricing (account-specific rates take precedence).