# Integrate HasData Google Flights API
## Task
Add the flight-search or deal-discovery function this project needs using HasData Google Flights API.
Inspect project instructions, the server-side runtime, existing HTTP client, and tests first.
Follow the project's conventions and preserve unrelated code. No new SDK is required.
Choose the endpoint for the requested task; do not build both workflows unless needed.
Do not replace the REST integration with an MCP connection or a custom Google Flights scraper.
## References
Read the relevant endpoint documentation before implementing:
- Routes and itineraries: https://docs.hasdata.com/apis/google-travel/flights.md
- Natural-language deal search: https://docs.hasdata.com/apis/google-travel/flights-deals.md
- Error handling: https://docs.hasdata.com/api-codes.md
- Documentation index: https://docs.hasdata.com/llms.txt
- Full documentation (fallback): https://docs.hasdata.com/llms-full.txt
Start with the endpoint references. Use `llms.txt` to find additional pages.
Use `llms-full.txt` only when needed; extract relevant sections instead of loading everything into context.
If a `.md` reference is unavailable, try its HTML URL without `.md`.
If it is still unavailable, ask for the missing documentation rather than guessing.
## Optional agent skill
If the official `hasdata` skill is already available, use its relevant guidance.
Otherwise, if this agent supports skills, ask before installing it in this project:
```sh
npx skills add hasdata/agent-skills --skill hasdata
```
Run from the project directory and select the coding agent in use.
The `hasdata-cli` skill is not required. If installation is declined or unsupported, continue with the docs.
Flag conflicts between skill guidance and current API docs rather than guessing.
## Implementation
- Route search: `GET https://api.hasdata.com/scrape/google/flights`. Use documented `departureId`, `arrivalId`, and `outboundDate` for a dated route search. Airport identifiers can be IATA codes or supported location IDs.
- Set `type` explicitly: `oneWay`, `roundTrip`, or `multiCity`. A round trip requires `returnDate`; multi-city uses the documented `multiCityJson` structure. Implement only the trip types the project needs.
- For route search, keep dates in YYYY-MM-DD format and validate future dates and ordering. Preserve currency, passenger counts, and cabin class throughout a search and follow-up requests.
- Treat `bestFlights`, `otherFlights`, `priceInsights`, and `airports` as optional response blocks. Preserve returned itinerary prices, flight legs, layovers, and their local-time strings. Do not infer missing return-leg details.
- If needed, use a returned `departureToken` for return or onward flights, or `bookingToken` for booking options. Never combine these tokens. Each follow-up is a separate request; do not automatically expand every result.
- Deal discovery: `GET https://api.hasdata.com/scrape/google/flights-deals` with required `q` (natural-language travel request) and `departureId` (one uppercase three-letter IATA airport code, not a city name or a list). Read its own parameters; use a verified response fixture when available rather than reusing route-search field assumptions.
- For Deals, use `arrivalId` when the user needs documented structured filters. Google ignores those filters without an explicit destination; do not silently claim they were applied. Preserve returned dates, destination, duration, currency, and price basis together.
- Deals dates accept an exact date or a comma-separated date window. Its `returnDate`, `travelDuration`, and `tripLength` options are mutually exclusive; `returnDate` requires `outboundDate`. Implement only the documented combinations needed for the task.
- Preserve `searchInformation` and `flightDeals`. Each deal can contain `destination`, `outboundDate`, `returnDate`, `price`, `typicalPrice`, `discountPercent`, and `bookingLink`. Preserve currency and each deal’s dates; do not assume all suggestions cover the same stay or recalculate reported discounts. One-way deals can omit return dates.
- Treat an empty `flightDeals` array as a valid result. Do not silently relax the user's constraints or retry to force matches.
- Add only documented filters needed for the task. Avoid incompatible airline filters and handle opaque tokens without decoding or modifying them.
- Handle timeouts, documented errors, empty results, and missing optional price, baggage, emissions, or historical data. Unknown does not mean zero or false.
- Price alerts, scheduled monitoring, saved search history, and recommendations belong to this application. The API retrieves results; do not implement ticket purchases or promise guaranteed fares.
- Keep requests server-side. If there is no suitable server-side runtime, discuss options before changing the architecture.
## Credentials
- Implement the integration and mocked tests without requiring a live API key.
- Read `HASDATA_API_KEY` from the project's existing environment or secret store and send it as `x-api-key`.
- If the key is missing before live verification, ask the user to configure it from https://app.hasdata.com/api-keys.
- Never ask the user to paste the key into chat. Check only that it is configured, without printing its value.
- Never put the key in browser code, logs, or version control. Add only a placeholder to example configuration.
- If using a local `.env` file, make sure it is gitignored.
- Send the key only to `https://api.hasdata.com`. Never forward it to documentation, Google, airline URLs, or redirects to another origin.
## Verification
- Add mocked tests for the chosen endpoint: success, empty results, missing optional blocks, documented errors, and parameter encoding. Test date validation and token handling only for the implemented workflow.
- Include a usage example and run local checks without paid API calls. If no verified response fixture is available, ask for one instead of inventing a schema.
- Only after explicit user approval and with a configured key, make one live verification request with agreed travel inputs. Successful requests consume credits, including empty results.
- Validate HTTP status, documented API status, and response structure. Do not automatically repeat paid requests to obtain data.
- Report changed files, setup commands, and test results. State separately whether live verification passed, failed, or was skipped.
- Ask before deploying.Google Flights API
for fares, itineraries, and flight deals
Get Google Flights fares and itineraries as JSON. Search routes and dates, or discover deals from a trip description.
of requests succeed
median response
95% finish faster
per 1k flight searches at volume
Performance figures cover route searches, not Flights Deals.
Fares change by the minute. Your code shouldn't care.
- Session tokens that expire
- Itineraries buried in nested JSON
- Prices in a dozen formats
- Headless browsers to keep warm
- Fix the parsers again next week
One GET Request. That's the whole integration.
Start with just a query. Add more parameters when your use case needs them.
Google Flights API
curl -G 'https://api.hasdata.com/scrape/google/flights' \
--data-urlencode 'departureId=LHR' \
--data-urlencode 'arrivalId=JFK' \
--data-urlencode 'outboundDate=2026-10-19' \
--data-urlencode 'returnDate=2026-10-26' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json'departureId * Departure airport code / location kgmidarrivalId * Arrival airport code / location kgmidoutboundDate * Outbound DatereturnDate Return Datetype Flight TypemultiCityJson Multi-city JSONgl Countryhl Languagecurrency CurrencytravelClass Travel ClassshowHidden Show Hidden Faresadults Adultschildren ChildreninfantsInSeat Infants in SeatinfantsOnLap Infants on LapsortBy Sort Bystops StopsexcludeAirlines Exclude AirlinesincludeAirlines Include Airlinesbags Number of BagsmaxPrice Maximum PriceoutboundTimes Outbound TimesreturnTimes Return TimeslessEmissions Fewer EmissionslayoverDuration Maximum Layover DurationincludeConnections Include ConnectionsexcludeConnections Exclude ConnectionsmaxDuration Maximum Flight DurationdeepSearch Deep SearchdepartureToken Departure TokenbookingToken Booking TokenGoogle Flights Deals API
curl -G 'https://api.hasdata.com/scrape/google/flights-deals' \
--data-urlencode 'q=I would like to see cherry blossom in Japan' \
--data-urlencode 'departureId=LAX' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json'q * Trip descriptiondepartureId * Departure airport codearrivalId Arrival airport code / location kgmidtype Flight typetravelClass Travel classoutboundDate Departure date or windowreturnDate Return date or windowtravelDuration Trip duration presettripLength Trip length in daysstops StopsmaxDuration Maximum flight durationmaxPrice Maximum priceincludeAirlines Include airlinesexcludeAirlines Exclude airlinesadults Adultschildren ChildreninfantsInSeat Infants in seatinfantsOnLap Infants on lapgl Countryhl Languagecurrency CurrencyAdd Google Flights API with your AI agent
Paste a ready-to-use integration prompt into your coding agent. It includes API references, setup requirements, and testing instructions.
Build with Google Flights API
Build airfare comparisons, trip discovery, and fare alerts with structured Google Flights data.
Compare airfare with travel time
Build flight comparison tools that weigh ticket prices against airlines, stops, and outbound travel time.
- LHR to JFK
- Departure: 20 Sep 2026
- USD · saved response
| Itinerary | Reported round-trip fare | Outbound duration |
|---|---|---|
| JetBlue · BOS | $1,140 | 12h 20m |
| Virgin Atlantic · Nonstop | $1,561 | 8h 10m |
| Royal Air Maroc · CMN | $902 | 29h 35m |
- API data
bestFlights[].priceotherFlights[].pricebestFlights[].totalDurationbestFlights[].flights[]- Your app
- Combine returned itineraries into a shortlist using the traveler's price and journey-time limits.
Flag long and overnight layovers
Use connection airports and layover durations to filter flight itineraries for business travel tools and trip planners.
- LHR to JFK
- Departure: 20 Sep 2026
- USD · saved response
| Connection airport | Layover | Overnight reported |
|---|---|---|
| BOS | 3h 26m | Not specified |
| CMN | 18h 25m | Yes |
- API data
bestFlights[].layovers[]otherFlights[].layovers[].durationotherFlights[].layovers[].overnight- Your app
- Apply connection-time rules and flag reported overnight layovers before showing a traveler's shortlist.
Build fare alerts with price context
Use Google Flights price insights and historical fares to explain current prices and power your own monitoring rules.
- LHR to JFK
- Departure: 20 Sep 2026
- USD · saved response
| Signal | Value |
|---|---|
| Lowest returned fare | $902 |
| Typical price range | $425–$810 |
| Reported price level | high |
| Your app's alert decision | No alert |
- API data
priceInsights.lowestPricepriceInsights.typicalPriceRangepriceInsights.priceLevelpriceInsights.priceHistory- Your app
- Schedule searches, store snapshots, and trigger your own notifications when a matching fare crosses the traveler's threshold.
Match flight options to cabin preferences
Compare cabin classes, aircraft, and reported legroom to build flight search experiences that go beyond the lowest fare.
- LHR to JFK
- Departure: 20 Sep 2026
- USD · saved response
| Flight | Cabin | Aircraft | Legroom |
|---|---|---|---|
| B6 1621 | Economy | Airbus A321neo | 32 in |
| VS 3 | Economy | Airbus A330-900neo | 31 in |
- API data
bestFlights[].flights[].travelClassbestFlights[].flights[].airplanebestFlights[].flights[].legroom- Your app
- Display per-leg comfort details alongside fares; keep each aircraft and seat-pitch value attached to its flight.
Compare reported flight emissions
Add carbon emission estimates and route benchmarks to travel dashboards so users can compare options alongside fare and duration.
- LHR to JFK
- Departure: 20 Sep 2026
- USD · saved response
| Itinerary | Estimated CO₂ | Versus typical |
|---|---|---|
| JetBlue · BOS | 608 kg | +86% |
| Virgin Atlantic · Nonstop | 267 kg | -18% |
- API data
bestFlights[].carbonEmissions.thisFlightbestFlights[].carbonEmissions.typicalForThisRoutebestFlights[].carbonEmissions.differencePercent- Your app
- Convert reported grams to kilograms and show Google's comparison with the typical route estimate.
Find flight deals from a trip idea
Turn a natural-language travel request into destination suggestions with dates, fares, and reported discounts for your trip-planning app.
- beach escape
- From LAX
- 1 adult · USD
| Destination | Travel dates | Reported fare | Below typical |
|---|---|---|---|
| Gold Coast (OOL) | 7 Dec 2026 – 13 Dec 2026 | $943 | 42% |
| Honolulu (HNL) | 5 Oct 2026 – 13 Oct 2026 | $229 | 37% |
| Saint Lucia (SLU) | 31 Jan 2027 – 9 Feb 2027 | $1,110 | 32% |
- API data
flightDeals[].destinationflightDeals[].outboundDateflightDeals[].returnDateflightDeals[].priceflightDeals[].discountPercent- Your app
- Present the returned destinations and dates as travel ideas, with links to inspect each flight offer.
Every route, one predictable schema
Explore itineraries, connections, price insights, and flight deals. Available fields depend on the endpoint and search.
bestFlights
[
{
"price": 758,
"type": "Round trip",
"totalDuration": 490,
"flights": [
{
"departureAirport": {
"id": "LHR",
"name": "Heathrow Airport",
"time": "2026-08-15 8:20"
},
"arrivalAirport": {
"id": "JFK",
"name": "John F. Kennedy International Airport",
"time": "2026-08-15 11:30"
},
"airline": "Virgin Atlantic",
"airplane": "Airbus A350",
"flightNumber": "VS 3",
"travelClass": "Economy",
"legroom": "31 in",
"duration": 490
}
],
"carbonEmissions": {
"thisFlight": 243000,
"typicalForThisRoute": 326000,
"differencePercent": -25
},
"departureToken": "W1t7ImRlcGFydHVyZUlkIjoiTEhSI…"
}
]price numberTotal price for the itinerary
type stringRound trip | One way
totalDuration numberTotal travel time in minutes
flights[] object[]Each leg of the itinerary
flights[].departureAirport / arrivalAirport objectid, name, and local time
flights[].airline / airplane stringCarrier and aircraft
flights[].travelClass / legroom stringCabin and seat pitch
carbonEmissions.thisFlight / typicalForThisRoute numberEstimated emissions in grams: this flight and the typical route
carbonEmissions.differencePercent numberReported percentage difference from the typical route estimate
departureToken stringToken to fetch return/onward options
otherFlights
[
{
"price": 744,
"type": "Round trip",
"totalDuration": 945,
"layovers": [
{
"id": "CLT",
"name": "Charlotte Douglas International Airport",
"duration": 284
}
]
}
]price numberTotal price for the itinerary
totalDuration numberTotal travel time in minutes
layovers[] object[]Connection stops on this itinerary
layovers[].id / name stringLayover airport code and name
layovers[].duration numberLayover length in minutes
priceInsights
{
"lowestPrice": 744,
"typicalPriceRange": [
510,
880
],
"priceLevel": "typical",
"priceHistory": [
[
1779577200,
916
],
[
1779663600,
916
]
]
}lowestPrice numberCheapest fare found
typicalPriceRange number[]Usual low-high band for this route
priceLevel stringlow | typical | high right now
priceHistory array[]Timestamped price points over time
airports
[
{
"departures": [
{
"id": "LHR",
"name": "Heathrow Airport",
"city": "London",
"country": "United Kingdom",
"countryCode": "GB"
}
],
"arrivals": [
{
"id": "JFK",
"name": "John F. Kennedy International Airport",
"city": "New York",
"country": "United States",
"countryCode": "US"
}
]
}
]departures / arrivals object[]Airports matched for each end of the route
id stringIATA code
name stringAirport name
city / country / countryCode stringLocation
flightDeals
Flights Deals response for "beach escape" from LAX, one adult, USD. Captured September 17, 2026; dates and fares are observations, not guaranteed offers.
{
"searchInformation": {
"query": "beach escape",
"departure": {
"airport": "LAX",
"name": "Los Angeles International Airport",
"city": "Los Angeles",
"latitude": 33.9425,
"longitude": -118.40806,
"countryCode": "US",
"country": "United States"
}
},
"flightDeals": [
{
"outboundDate": "2026-12-07",
"returnDate": "2026-12-13",
"price": {
"value": 943,
"currency": "USD"
},
"typicalPrice": {
"value": 1622,
"currency": "USD"
},
"discountPercent": 42,
"durationMinutes": 1185,
"tripLengthDays": 6,
"stops": 1,
"airline": "Air New Zealand",
"multipleAirlines": false,
"departureAirport": "LAX",
"arrivalAirport": "OOL",
"destination": {
"city": "Gold Coast",
"country": "Australia"
},
"bookingLink": "https://www.google.com/travel/flights?tfs=CCoQAhojEgoyMDI2LTEyLTA3agcIARIDTEFYcgwIAhIIL20vMGc0ZzcaIxIKMjAyNi0xMi0xM2oMCAISCC9tLzBnNGc3cgcIARIDTEFYUgNVU0R6fENqUkliVmhVTWxwdGIwWmFha1ZCUTBKdVgzZENSeTB0TFMwdExTMHRMWEJtYW1jeE9VRkJRVUZCUjNGeWJ6Wm5UMngxV0V0QkVoSkVaV0ZzUTI5dWMzUnlZV2x1ZEhNd0xUQWFDd2laNEFVUUFob0RWVk5FT0Rod21lQUY&curr=USD&hl=en-US&gl=US&gsas=1"
},
{
"outboundDate": "2026-10-05",
"returnDate": "2026-10-13",
"price": {
"value": 229,
"currency": "USD"
},
"typicalPrice": {
"value": 362,
"currency": "USD"
},
"discountPercent": 37,
"durationMinutes": 349,
"tripLengthDays": 8,
"stops": 0,
"airline": "Alaska",
"multipleAirlines": false,
"departureAirport": "LAX",
"arrivalAirport": "HNL",
"destination": {
"city": "Honolulu",
"country": "United States"
},
"bookingLink": "https://www.google.com/travel/flights?tfs=CCoQAholEgoyMDI2LTEwLTA1agcIARIDTEFYcg4IAhIKL20vMDJocmgwXxolEgoyMDI2LTEwLTEzag4IAhIKL20vMDJocmgwX3IHCAESA0xBWFIDVVNEenxDalJJYlZoVU1scHRiMFphYWtWQlEwSnVYM2RDUnkwdExTMHRMUzB0TFhCbWFtY3hPVUZCUVVGQlIzRnlielpuVDJ4MVdFdEJFaEpFWldGc1EyOXVjM1J5WVdsdWRITXdMVEVhQ3dpanNnRVFBaG9EVlZORU9EaHdvN0lC&curr=USD&hl=en-US&gl=US&gsas=1"
},
{
"outboundDate": "2027-01-31",
"returnDate": "2027-02-09",
"price": {
"value": 1110,
"currency": "USD"
},
"typicalPrice": {
"value": 1622,
"currency": "USD"
},
"discountPercent": 32,
"durationMinutes": 2249,
"tripLengthDays": 9,
"stops": 2,
"multipleAirlines": true,
"departureAirport": "LAX",
"arrivalAirport": "SLU",
"destination": {
"city": "Saint Lucia",
"country": "St. Lucia"
},
"bookingLink": "https://www.google.com/travel/flights?tfs=CCoQAhojEgoyMDI3LTAxLTMxagcIARIDTEFYcgwIAhIIL20vMDZzMGwaIxIKMjAyNy0wMi0wOWoMCAISCC9tLzA2czBscgcIARIDTEFYUgNVU0R6fENqUkliVmhVTWxwdGIwWmFha1ZCUTBKdVgzZENSeTB0TFMwdExTMHRMWEJtYW1jeE9VRkJRVUZCUjNGeWJ6Wm5UMngxV0V0QkVoSkVaV0ZzUTI5dWMzUnlZV2x1ZEhNd0xUSWFDd2pMNGdZUUFob0RWVk5FT0Rod3krSUc&curr=USD&hl=en-US&gl=US&gsas=1"
}
]
}searchInformation.query / departure string / objectTrip description and resolved departure airport
flightDeals[].destination objectSuggested destination, with city and country
flightDeals[].outboundDate / returnDate stringDates selected for this suggestion; one-way deals omit the return date
flightDeals[].price / typicalPrice objectReported fare and typical fare, each with value and currency
flightDeals[].discountPercent numberGoogle’s reported discount against its typical fare
flightDeals[].durationMinutes / tripLengthDays / stops numberReported flight duration, trip length, and stop count
flightDeals[].bookingLink stringGoogle Flights link to inspect the offer, not a ticket purchase
An all-in-one scraping service
Every feature you need to collect data from thousands to millions of requests.
Discover similar
scrapers and APIs
to expand your projects.
Google Hotels API
Travel Data • $0.83 / 1k Request
Booking.com Scraper
Travel Data • $0.08 / 1k Rows
Fits right into your stack.
Works with the tools you already use.
View Documentation ->Teams that deleted their scraper
Now it's the part of the pipeline they don't think about
Their ability to handle dynamic content, including time-sensitive flight pricing, was particularly impressive.
HasData delivers exactly what we need: speed and comprehensive search features. It's the fastest API we've used in this space. Plus, their customer support is fantastic.
We rely on HasData for search performance data and broader scraping needs. Their APIs deliver highly structured data that integrates directly into our platforms.
Great web scraping API which is incredibly easy to use. It requires minimal effort to get up and running, and the documentation is very clear and helpful.
I needed to scrape some information they didn't already support, and they wrote the code for me right away, which was super nice of them.
Plans that get cheaper at scale
Fixed price, fixed volume, no surprises at the end of the month. Upgrade when you need more.
Free
Startup
Basic
RecommendedGrowth
Monthly flight search volume
Custom price based on required volume
Past 20M credits a month, or terms the self-serve plans do not cover. We shape the contract around your workload. Past 20M credits a month, or need terms the self-serve plans do not cover? We shape the contract, concurrency, and support around your workload.
HasData accesses publicly available data only. Google Flights' terms may restrict automated access; you are responsible for compliance. Where data includes personal information, ensure a lawful basis under GDPR/CCPA.
Questions, answered
Per successful request. Route searches return flight itineraries and can include price insights; Deals searches return matching flight deals. A failed request costs nothing.
Yes. The free plan renews 1,000 credits every month, enough for up to 66 flight requests, depending on the endpoint. No credit card required. When you outgrow it, pick a plan that fits your volume.
A route search costs 15 credits; a Deals search costs 15 credits. With monthly billing in USD, paid plans start at $59 per month for 13,333 route searches and scale to 1,333,333 a month. For route searches, the unit price drops with volume from $4.43 to $1.25 per 1,000 searches.
Best and other itineraries with per-leg detail, layovers, cabin and legroom, carbon estimates, matched airports, and price insights for the route.
Yes. Google Flights Deals accepts a trip description and a departure airport, then lets Google suggest matching destinations and dates. Use the regular Flights endpoint when you already know the route and travel dates. Neither endpoint purchases tickets.
Yes. priceInsights returns the lowest fare, the typical price range for the route, whether prices are low or high right now, and a price history over time.
Both. Set type=oneWay with departureId, arrivalId, and outboundDate for a one-way route. For a round trip, use type=roundTrip and include returnDate. Return-leg options are retrieved separately using departureToken.
Nothing on your side. We track the changes and keep the response schema stable. Fields keep their names and types, and existing keys don't disappear.
No. Requests run on HasData's infrastructure, so there's nothing to provision or maintain. You're responsible for using the results in line with each target site's terms and applicable law.
Yes, you can cancel your subscription at any time from your dashboard in a few seconds. Once cancelled, there are no recurring payments.
Your first Google Flights response
is minutes away
66 flight searches free · no credit card