# Google Flights Reference

## Search URL

Google Flights uses an encoded `tfs` parameter for complex searches. The easiest approach is to construct searches via the UI or use the direct URL for simple one-way/return trips.

### Simple approach — navigate via UI

```bash
PROXY_URL=$(tc proxy)
agent-browser close
agent-browser --proxy "$PROXY_URL" open "https://www.google.com/travel/flights"
sleep 4
agent-browser screenshot /workspace/group/flights_home.png
```

Then interact with the search form using snapshots:
```bash
agent-browser snapshot -i   # identify fields
agent-browser click @e1     # origin field
agent-browser fill @e1 "London"
sleep 1
agent-browser snapshot -i   # pick autocomplete
agent-browser click @e2     # destination field
# etc.
```

### Encoded search URL (from browser)

The `tfs` param is base64-encoded protobuf — easiest to get by doing a search manually in the browser, copying the URL, and reusing it:

```bash
PROXY_URL=$(tc proxy)
agent-browser --proxy "$PROXY_URL" open "https://www.google.com/travel/flights/search?tfs=CBwQAhoeEgoyMDI2LTA3LTAxagcIARIDTUFEcgcIARIDTEhSQAFIAXABggELCP___________wGYAQI"
sleep 4
agent-browser screenshot /workspace/group/flights.png
```

## Key Selectors

```bash
# Flight results list
agent-browser get text "[data-resulttype='FLIGHT']"

# Price
agent-browser get text "[aria-label*='price']"

# Flight details snapshot
agent-browser snapshot -s "li[class*='pIav2d']"
```

## Tips

- Google Flights is JS-heavy — always `sleep 4+` after opening
- If results don't load, try scrolling: `agent-browser scroll 0 500`
- Use `agent-browser snapshot -s` on result cards to extract structured data
- The `tfs` URL param encodes origin, destination, date, cabin class — best reused from a real search
