Given {origin}, {destination}, concrete dates or inclusive bounded departure and return-date windows, optional traveler count, airline, stops, cabin, fare type, departure-time window, baggage requirement, currency, locale, and result limit, search Google Flights directly and return currently rendered itineraries sorted by visible price. Support bounded date lists, flexible return windows, multiple origins or destinations, and top-{limit} comparisons. Preserve route, dates, segment times, duration, airline, stops, price, currency, cabin/fare evidence, baggage evidence, passenger-count evidence, and bounded raw card evidence. Do not enter traveler information, select seats, submit payment, or complete a booking.
Use Cases
- Finding the cheapest one-way or round-trip fare.
- Comparing every departure or return date in an explicitly bounded inclusive window.
- Comparing several explicitly supplied date pairs or multiple origins and destinations.
- Returning separate one-way prices for outbound and return legs.
- Filtering visible departures by time, airline, stops, cabin, fare type, or baggage.
- Verifying a requested adult or passenger count from rendered Google Flights controls.
- Returning the top
{limit}cheapest visible itineraries. - Opening fare/provider options for a matching rendered itinerary without purchasing.
Automation Flow
Resolve the requested date set locally. A phrase such as
{return-date} ± {days}means the inclusive calendar window from{return-date minus days}through{return-date plus days}. Never search outside caller bounds. For multiple origins, destinations, or date pairs, create one clean URL per combination.Navigate directly to each URL; do not visit the homepage or type into search controls:
https://www.google.com/travel/flights/search?q={url-encoded-One-way flights from {origin} to {destination} on {departure-date}}&curr={currency}&hl={language}&gl={country}For a fixed round trip:
https://www.google.com/travel/flights/search?q={url-encoded-Round trip flights from {origin} to {destination} on {departure-date} returning {return-date}}&curr={currency}&hl={language}&gl={country}For a bounded flexible return window, enumerate each return date and use the fixed round-trip form for each date. The observed durable form uses returning {YYYY-MM-DD}; it does not require a flexible-date parameter. Omit locale parameters when not requested. Do not retain opaque tfs, tfu, session, continuation, redirect, or challenge parameters.
- For every navigation, wait for dynamic cards to render, normally about 8–20 seconds, then run this evaluator in the same browser-agent call, substituting
{airlines-json}with the caller's requested airline names as a JSON array (for example["Emirates","Lufthansa"], or[]when none were requested),{max-stops}with the caller's maximum stop count as an integer (0for nonstop) ornull, and{cabin-json}with the requested cabin as a JSON string ("economy","premium economy","business", or"first") ornull, and{fare-type}with the requested fare type as a JSON string (for example"basic economy"or"refundable") ornull, and{baggage-req}with the requested baggage allowance as a JSON string (for example"carry-on"or"checked bag") ornull. The evaluator fillsairlineonly from that list and otherwise leaves itnull; read airline, stops, and baggage from each card'sraw/ariaLabelper step 6 rather than trusting a guessed value. Whenmax-stopsorcabinis set, the evaluator returns only cards whose visible evidence satisfies it and excludes cards lacking that evidence, soresults-foundholds only when a qualifying card remains — otherwisestatusisno-constraint-matchandcandidateCountreports the unfiltered flight count. The evaluator matches stop and cabin evidence against English card text, so whenever{max-stops}or{cabin-json}is set, search withhl=en(keeping the caller'sglandcurr); a non-Englishhlleaves these cards without recognizable evidence and drops every one of them. Fare type and baggage allowance cannot be verified from rendered list cards; when{fare-type}or{baggage-req}is set and matching flights are found, the evaluator returnsstatus: constraints-unverified(successfalse) and listsfareTypeand/orbaggageinunverifiedConstraints(empty for every other status), and each must be confirmed by opening the card's fare detail (step 10) before treating a result as matching:
(()=>{const airlines={airlines-json},maxStops={max-stops},cabinReq={cabin-json},fareType={fare-type},bagReq={baggage-req};const clean=s=>(s||'').replace(/\s+/g,' ').trim(),normCab=s=>{s=(s||'').toLowerCase();return /premium\s*economy/.test(s)?'premium economy':/business/.test(s)?'business':/first/.test(s)?'first':/economy|coach|main cabin/.test(s)?'economy':null;},visible=e=>!!e&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)>0,u=new URL(location.href),body=clean(document.body?.innerText),blocked=/^\/sorry(?:\/|$)/i.test(u.pathname)||/captcha|unusual traffic|automated queries|verify you are human|robot check|sign in|consent/i.test(body)&&!/flight|flights|airport|airline|€|\$|£|¥|₹|\b(?:EUR|USD|GBP|JPY|INR|CAD|AUD|CHF)\b/i.test(body),allow=new Set(['q','hl','gl','curr']),safeQs=new URLSearchParams([...u.searchParams].filter(([k])=>allow.has(k))).toString(),prov=blocked?'':(u.pathname+(safeQs?'?'+safeQs:'')),safeUrl=blocked?null:(u.origin+u.pathname+(safeQs?'?'+safeQs:'')),timeRe=/\b(?:[01]?\d|2[0-3]):[0-5]\d(?:\s*[ap]m)?\b/ig,priceRe=/(?:([$€£¥₹]|CA\$|US\$|AU\$|TRY\s*)\s*[0-9][0-9.,]*|[0-9][0-9.,]*\s*(?:CA\$|CAD|EUR|USD|GBP|JPY|INR|AUD|CHF|TRY|€|\$|£|¥|₹))/i,num=s=>{if(!s)return null;const x=s.replace(/[^0-9.,]/g,''),l=x.lastIndexOf('.'),c=x.lastIndexOf(','),y=l>=0&&c>=0?(l>c?x.replace(/,/g,''):x.replace(/\./g,'').replace(',','.')):c>=0?(/,\d{2}$/.test(x)?x.replace(/\./g,'').replace(',','.'):x.replace(/,/g,'')):(/\.\d{3}$/.test(x)||(x.match(/\./g)||[]).length>1?x.replace(/\./g,''):x),n=Number(y);return Number.isFinite(n)?n:null},nodes=[...document.querySelectorAll('li.pIav2d,li[role="button"],div[aria-label*="Select flight" i],[aria-label^="From" i]')].filter(visible),rows=nodes.map(e=>{const aria=clean(e.getAttribute('aria-label')),vis=clean(e.innerText||e.textContent||''),raw=vis||aria,hay=clean([vis,aria].join(' ')),times=[...hay.matchAll(timeRe)].map(m=>m[0]),priceHay=hay.replace(timeRe,' '),pm=priceHay.match(priceRe),allP=[...priceHay.matchAll(new RegExp(priceRe.source,'ig'))].map(m=>m[0]),totalM=priceHay.match(new RegExp('(?:round[\\s-]?trip|trip total|total)[^0-9$€£¥₹]{0,24}('+priceRe.source+')','i')),airline=(Array.isArray(airlines)&&airlines.length?(airlines.find(a=>new RegExp('\\b'+String(a).replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\b','i').test(hay))||null):null),stops=(hay.match(/\b(nonstop|direct|\d+\s*stops?|\d+\s*connections?)\b/i)||[])[1]||null,stopNum=(stops==null?null:(/nonstop|direct/i.test(stops)?0:(Number.isFinite(parseInt(stops,10))?parseInt(stops,10):null))),cabinEv=(hay.match(/\b(premium economy|business class|first class|economy|business|first|coach|main cabin)\b/i)||[])[0]||null,duration=(hay.match(/\b(?:\d+\s*h(?:ours?)?|\d+\s*hr)(?:\s*\d+\s*min)?\b/i)||[])[0]||null,bag=(hay.match(/\b(no bags?|personal item|carry[- ]?on|hand baggage|cabin bag|checked bag|1 checked|2 checked|bag included|baggage included)\b/i)||[])[0]||null;return{raw:raw.slice(0,2400),ariaLabel:aria||null,times,departureTime:times[0]||null,arrivalTime:times[1]||null,price:(totalM?totalM[1]:pm?.[0])||null,priceValue:(totalM?num(totalM[1]):(allP.length<=1?num(pm?.[0]):null)),multiPrice:allP.length>1,airline,stops,stopNum,cabinEvidence:cabinEv,duration,baggageEvidence:bag,key:[prov,aria,raw].join('|')}}),candidates=rows.filter(r=>r.price&&r.times.length>=2),unique=[...new Map(candidates.filter(r=>(!(Array.isArray(airlines)&&airlines.length)||r.airline)&&(maxStops==null||(r.stopNum!=null&&r.stopNum<=maxStops))&&(normCab(cabinReq)==null||normCab(r.cabinEvidence)===normCab(cabinReq))).map(x=>[x.key,x])).values()],selected=[...document.querySelectorAll('button[aria-label*="Selected" i]')].filter(visible).map(e=>e.getAttribute('aria-label'));const isGoogleFlights=/(^|\.)google\.com$/i.test(u.hostname)&&/\/travel\/(flights|explore)/i.test(u.pathname);const unv=[...(fareType!=null?['fareType']:[]),...(bagReq!=null?['baggage']:[])];const status=blocked?'blocked':!isGoogleFlights?'wrong-page':unique.length?(unv.length?'constraints-unverified':'results-found'):candidates.length?'no-constraint-match':'unresolved';return{success:status==='results-found',status,isGoogleFlights,url:safeUrl,query:u.searchParams.get('q')||null,blocked,unverifiedConstraints:status==='constraints-unverified'?unv:[],requestedFareType:fareType||null,requestedBaggage:bagReq||null,passengerLabel:[...document.querySelectorAll('button[aria-label*="passenger" i]')].filter(visible)[0]?.getAttribute('aria-label')||null,selectedFilters:selected,resultCount:unique.length,candidateCount:candidates.length,flightCards:unique.slice(0,100),bodyExcerpt:body.slice(0,2400)}})()Stitch together every page output whose
statusisresults-foundorconstraints-unverified— the latter hassuccess: falsebut still carries matchingflightCardsthat Step 10 must verify, so do not discard it — retaining departure date, return date, route, and search-URL provenance for every card. Deduplicate by the returned card key, preserving search-URL provenance so cards from different routes or date pairs remain distinct. For a flexible return window, compare all requested return-date pages rather than only the final navigation.Sort only cards with consistently parseable prices in the requested currency and return the first
{limit}cheapest rows, defaulting to 3. If currency or numeric formats are inconsistent, preserve visible order and report the comparison limitation. Do not treat separate one-way prices as a combined round-trip fare.Resolve exact airports only from caller input or explicit rendered evidence when a city has multiple airports; never infer an airport solely from a city name. Interpret airline, duration, cabin, fare type, stops, baggage, and airport only from
raworariaLabel.If a traveler count is requested, verify the visible passenger label matches it. Do not silently use another count. For one adult, require rendered evidence equivalent to one adult rather than relying on query text.
If departure-time bounds are requested, use the visible
Timescontrol and range inputs commonly namedEarliest departureandLatest departure, dispatch bubblinginputandchangeevents, wait for refresh, close the dialog, and verify the selected filter. No durable time-filter URL parameter is established. The Bags control may be applied for baggage requirements, but its effect cannot be confirmed from rendered list cards; baggage is therefore returned as an unverified constraint (step 3) and must be confirmed per-card via fare detail (step 10). Preserve explicit per-card baggage evidence.If more results are explicitly requested, expand a visible
View more flightscontrol once, then scroll only the visible results area in bounded increments and rerun the evaluator until no new card keys appear or the limit is reached.When fare or booking options are requested, identify the exact rendered card using its accessible
From ...label, open it, and inspect the rendered detail view. If a visibleView optionscontrol appears, inspect fare/provider results without clicking provider links or beginning checkout.Treat consent, login, CAPTCHA, unusual-traffic, reload-required, and empty dynamic pages as blocked or unresolved. Do not retain challenge URLs, tokens, cookies, continuation parameters, or opaque session state.
Possible Friction Points
- The durable direct surface is
/travel/flightsor/travel/flights/search; a natural-languageqreaches a one-way or round-trip state in one navigation. - Fixed round trips use
Round trip flights from {origin} to {destination} on {departure-date} returning {return-date}. For a flexible return window, enumerate each inclusive return date locally; no durable flexible-return URL parameter was established. - An inclusive bounded departure window likewise requires one URL per departure date.
- The observed result cards used
li.pIav2d; markup may change, so require visible bounded flight evidence and deduplicate nested or responsive copies. - Dynamic cards may require roughly 8–20 seconds after navigation. An empty initial DOM is unresolved, not proof that no flights exist.
- Departure-time filtering is exposed through the interactive
Timesdialog and range inputs namedEarliest departureandLatest departure; no durable time-filter URL parameter was established. - Applying filters may produce session-generated URLs containing opaque
tfuortfsvalues. Never fabricate, save, or replay them. - No stable baggage or price-sort URL parameter was established. Use visible controls when explicitly requested and otherwise sort parseable displayed prices locally.
- Flight cards can contain multiple segment times, airports, airlines, prices, baggage labels, and fare labels in localized order. Map the first two times to departure and arrival only when the card clearly presents them in that order; otherwise preserve
timesand leave derived fields null. curr,hl, andglare optional durable locale settings; preserve caller-specified values. When{max-stops}or{cabin-json}is set, search withhl=enso stop and cabin evidence is recognizable; a non-Englishhldrops every constrained card. Keep the caller'sglandcurr.- Prices, schedules, rankings, baggage rules, provider availability, passenger pricing, and time-filter results are time-dependent rendered evidence.
- Consent, login, CAPTCHA, and unusual-traffic pages are blocked states. Do not bypass them or retain challenge state.
- Do not select a fare, start booking, enter traveler or payment data, or submit a purchase.
Example Result
{
"success": true,
"status": "results-found",
"isGoogleFlights": true,
"url": "https://www.google.com/travel/flights?q=example",
"query": "example",
"blocked": false,
"unverifiedConstraints": [],
"requestedFareType": null,
"requestedBaggage": null,
"passengerLabel": null,
"selectedFilters": [],
"resultCount": 1,
"candidateCount": 1,
"flightCards": [
{
"raw": "Example Airline 08:00 10:00 $123 nonstop Economy 2h",
"ariaLabel": "Select flight with Example Airline",
"times": [
"08:00",
"10:00"
],
"departureTime": "08:00",
"arrivalTime": "10:00",
"price": "$123",
"priceValue": 123,
"multiPrice": false,
"airline": "Example Airline",
"stops": "nonstop",
"stopNum": 0,
"cabinEvidence": "Economy",
"duration": "2h",
"baggageEvidence": null,
"key": "/travel/flights?q=example|Select flight with Example Airline|Example Airline 08:00 10:00 $123 nonstop Economy 2h"
}
],
"bodyExcerpt": "Example Title"
}