> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hasdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Flights Deals API

The Google Flights Deals API turns a plain-language trip description into concrete flight deals, letting Google's AI work out the destinations and travel dates on its own.

## Get Your API Key

Sign in at [hasdata.com](https://app.hasdata.com/sign-in), go to your account settings, and copy your API key.
All requests must include your key in the `x-api-key` header.

## Request Cost and API Credits

Each request to the Google Flights Deals API consumes **API Credits** from your account balance.

* **Cost per request:** 15 API Credits
* Credits are deducted only for successful requests.
* Your total available credits depend on your active plan.

<Tip>You can use your credits across all HasData APIs. The same credit balance is shared platform-wide.</Tip>
<Warning>**Unused credits do not roll over.** Any remaining credits expire at the end of the current billing period.</Warning>

To monitor your credit usage and remaining balance, sign in to your account dashboard at [app.hasdata.com](https://app.hasdata.com/sign-in).

## Make Your First Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET -G \
    --url '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 'Content-Type: application/json' \
    --header 'x-api-key: <your-api-key>'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios').default;

  const options = {
    method: 'GET',
    url: 'https://api.hasdata.com/scrape/google/flights-deals',
    params: {q: 'I would like to see cherry blossom in Japan', departureId: 'LAX'},
    headers: {'Content-Type': 'application/json', 'x-api-key': '<your-api-key>'}
  };

  try {
    const { data } = await axios.request(options);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.hasdata.com/scrape/google/flights-deals"

  querystring = {"q":"I would like to see cherry blossom in Japan","departureId":"LAX"}

  headers = {
      "Content-Type": "application/json",
      "x-api-key": "<your-api-key>"
  }

  response = requests.get(url, headers=headers, params=querystring)

  print(response.json())
  ```

  ```php PHP theme={null}
  <?php

  $params = [
      "q" => "I would like to see cherry blossom in Japan",
      "departureId" => "LAX",
  ];

  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.hasdata.com/scrape/google/flights-deals?" . http_build_query($params),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
      "Content-Type: application/json",
      "x-api-key: <your-api-key>",
    ],
  ]);

  $response = curl_exec($curl);
  curl_close($curl);

  echo $response;
  ```

  ```java Java theme={null}
  OkHttpClient client = new OkHttpClient();

  HttpUrl url = HttpUrl.parse("https://api.hasdata.com/scrape/google/flights-deals")
    .newBuilder()
    .addQueryParameter("q", "I would like to see cherry blossom in Japan")
    .addQueryParameter("departureId", "LAX")
    .build();

  Request request = new Request.Builder()
    .url(url)
    .get()
    .addHeader("Content-Type", "application/json")
    .addHeader("x-api-key", "<your-api-key>")
    .build();

  Response response = client.newCall(request).execute();
  ```

  ```csharp C# theme={null}
  using System.Net.Http;
  using System.Web;

  var client = new HttpClient();

  var query = HttpUtility.ParseQueryString(string.Empty);
  query["q"] = "I would like to see cherry blossom in Japan";
  query["departureId"] = "LAX";

  var url = $"https://api.hasdata.com/scrape/google/flights-deals?{query}";

  var request = new HttpRequestMessage(new HttpMethod("GET"), url);
  request.Headers.Add("x-api-key", "<your-api-key>");

  using var response = await client.SendAsync(request);
  response.EnsureSuccessStatusCode();
  var content = await response.Content.ReadAsStringAsync();
  Console.WriteLine(content);
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'

  uri = URI("https://api.hasdata.com/scrape/google/flights-deals")
  params = {
    "q" => "I would like to see cherry blossom in Japan",
    "departureId" => "LAX",
  }
  uri.query = URI.encode_www_form(params)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Get.new(uri)
  request["Content-Type"] = 'application/json'
  request["x-api-key"] = '<your-api-key>'

  response = http.request(request)
  puts response.read_body
  ```

  ```rust Rust theme={null}
  use reqwest::blocking::Client;

  fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Client::new();
      let res = client
          .get("https://api.hasdata.com/scrape/google/flights-deals")
          .query(&[("q", "I would like to see cherry blossom in Japan")])
          .query(&[("departureId", "LAX")])
          .header("Content-Type", "application/json")
          .header("x-api-key", "<your-api-key>")
          .send()?
          .text()?;
      println!("{}", res);
      Ok(())
  }
  ```

  ```go Go theme={null}
  package main

  import (
  	"fmt"
  	"io"
  	"net/http"
  	"net/url"
  )

  func main() {
  	params := url.Values{}
  	params.Set("q", "I would like to see cherry blossom in Japan")
  	params.Set("departureId", "LAX")

  	u := "https://api.hasdata.com/scrape/google/flights-deals?" + params.Encode()

  	req, _ := http.NewRequest("GET", u, nil)
  	req.Header.Add("Content-Type", "application/json")
  	req.Header.Add("x-api-key", "<your-api-key>")

  	res, _ := http.DefaultClient.Do(req)
  	defer res.Body.Close()

  	body, _ := io.ReadAll(res.Body)
  	fmt.Println(string(body))
  }
  ```
</CodeGroup>

## API Parameters

| Parameter         | Default Value                               | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------- | ------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `q`               | I would like to see cherry blossom in Japan | Yes      | Free-text trip description, from a bare place name to a full sentence:<br /><br />  - **Destination**: `Tokyo`<br />  - **Type of trip**: `beach escape`, `weekend getaway in Europe`<br />  - **Season or event**: `I would like to see cherry blossom in Japan`<br /><br />When the query implies a time of year, Google dates it itself and reports the range in `searchInformation.dateRange`.<br />                                                                                                                                |
| `departureId`     | LAX                                         | Yes      | Departure airport as a 3-letter uppercase IATA code, e.g. `LAX` or `LHR`. Search on [IATA](https://www.iata.org/en/publications/directories/code-search).<br /><br />One airport per search; city names are not accepted.<br />                                                                                                                                                                                                                                                                                                         |
| `arrivalId`       | -                                           | No       | Pins the search to one destination instead of letting Google pick from the query.<br /><br />  - **IATA code**: 3 uppercase letters, e.g. `NRT` for Tokyo Narita.<br />  - **Location kgmid**: starts with `/m/`, found in Wikidata under "Freebase ID", e.g. `/m/07dfk` for Tokyo.<br /><br />Required by every filter: `type`, `travelClass`, `stops`, `outboundDate`, `returnDate`, `travelDuration`, `tripLength`, `maxPrice`, `maxDuration`, `includeAirlines` and `excludeAirlines`. Without it Google drops them silently.<br /> |
| `type`            | -                                           | No       | Flight type. Requires `arrivalId`.<br /><br />  - `1` / `roundTrip` — round trip (default)<br />  - `2` / `oneWay` — one way<br /><br />A one-way deal carries no `returnDate` and no `tripLengthDays`.<br />                                                                                                                                                                                                                                                                                                                           |
| `travelClass`     | -                                           | No       | Travel class. Requires `arrivalId`.<br /><br />  - `1` / `economy` — economy (default)<br />  - `2` / `premiumEconomy` — premium economy<br />  - `3` / `business` — business<br />  - `4` / `first` — first<br /><br />Fares climb steeply: on LAX-NRT the same search ran $730 in economy against $2882 in business.<br />                                                                                                                                                                                                            |
| `outboundDate`    | -                                           | No       | When to depart. Requires `arrivalId`.<br /><br />  - **Exact date**: `2026-12-10`<br />  - **Window**: `2026-12-01,2026-12-10` — any day within it<br /><br />Omitted, Google picks the dates from the query, or from whatever is cheapest.<br />                                                                                                                                                                                                                                                                                       |
| `returnDate`      | -                                           | No       | When to return, in the same exact-or-window spelling as `outboundDate`, which is required alongside it.<br /><br />Cannot be combined with `travelDuration` or `tripLength` — all three set the trip length. Ignored when `type` is `oneWay`.<br />                                                                                                                                                                                                                                                                                     |
| `travelDuration`  | -                                           | No       | Preset trip length. Requires `arrivalId`. Cannot be combined with `returnDate` or `tripLength`.<br /><br />  - `1` / `week` — about a week (6-8 days)<br />  - `2` / `weekend` — a weekend (2-3 days)<br />  - `3` / `twoWeeks` — about two weeks (13-15 days)<br /><br />Pairs with `outboundDate` to limit the departure period. Ignored when `type` is `oneWay`.<br />                                                                                                                                                               |
| `tripLength`      | -                                           | No       | Trip length in days. Requires `arrivalId`. Cannot be combined with `returnDate` or `travelDuration`.<br /><br />  - **Exact**: `7`<br />  - **Range**: `5,10` — min first<br /><br />Pairs with `outboundDate` to limit the departure period. Ignored when `type` is `oneWay`.<br />                                                                                                                                                                                                                                                    |
| `stops`           | -                                           | No       | Maximum number of stops. Requires `arrivalId`. Omitted, any number is allowed.<br /><br />  - `1` / `nonStop` — direct flights only<br />  - `2` / `oneStopOrFewer` — at most one connection<br />  - `3` / `twoStopsOrFewer` — at most two connections<br /><br />A route with nothing at that depth returns an empty `flightDeals` array, not an error — `nonStop` on a route without a direct flight is a valid, empty answer.<br />                                                                                                 |
| `maxDuration`     | -                                           | No       | Maximum flight duration in minutes — `1500` for 25 hours. Requires `arrivalId`. Omitted, it is unbounded. Applies to each leg, not to the round trip.<br /><br />Google measures against a longer figure than the `durationMinutes` it returns, so set the ceiling above the flight you want: on a route whose shortest deal is 635 minutes, `635` comes back empty and `680` returns it. On an empty result, raise `maxDuration` by up to 200 before concluding the route has nothing.<br />                                           |
| `maxPrice`        | -                                           | No       | Maximum ticket price, inclusive. Requires `arrivalId`. Omitted, it is unbounded.<br /><br />Read in the currency of the request: `650` means 650 EUR when `currency` is `EUR`, and 650 USD by default.<br />                                                                                                                                                                                                                                                                                                                            |
| `includeAirlines` | -                                           | No       | Keeps only these airlines. Requires `arrivalId`. Cannot be combined with `excludeAirlines`.<br /><br />Comma-separated 2-character IATA codes (`AF`, `UA`, `B6`) and Google's alliances `STAR_ALLIANCE`, `SKYTEAM`, `ONEWORLD`. The two can be mixed.<br /><br />An airline that does not serve the route returns an empty `flightDeals` array, not an error.<br />                                                                                                                                                                     |
| `excludeAirlines` | -                                           | No       | Drops these airlines from the deals. Requires `arrivalId`. Cannot be combined with `includeAirlines`.<br /><br />Takes the same values as `includeAirlines`.<br />                                                                                                                                                                                                                                                                                                                                                                      |
| `adults`          | -                                           | No       | Number of adults. Prices cover the whole party, so raising this raises every deal price.<br /><br />Passenger counts reprice rather than narrow the search, so they need no `arrivalId`. The whole party must not exceed 9.<br />                                                                                                                                                                                                                                                                                                       |
| `children`        | -                                           | No       | Number of children, priced at their own fare. Counts towards the limit of 9 passengers.<br />                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `infantsInSeat`   | -                                           | No       | Number of infants in their own seat. Counts towards the limit of 9 passengers.<br />                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `infantsOnLap`    | -                                           | No       | Number of infants on an adult's lap. Counts towards the limit of 9 passengers.<br /><br />Google prices a lap infant above one in its own seat — the opposite of how airlines usually charge.<br />                                                                                                                                                                                                                                                                                                                                     |
| `gl`              | -                                           | No       | The two-letter country code for the country you want to limit the search to.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `hl`              | -                                           | No       | The two-letter language code for the language you want to use for the search.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `currency`        | -                                           | No       | Parameter defines the currency of the returned prices                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
