Get Your API Key
Sign in at hasdata.com, go to your account settings, and copy your API key. All requests must include your key in thex-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.
You can use your credits across all HasData APIs. The same credit balance is shared platform-wide.
Unused credits do not roll over. Any remaining credits expire at the end of the current billing period.
Make Your First Request
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>'
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);
}
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
$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;
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();
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);
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
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(())
}
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))
}
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: - Destination: Tokyo- Type of trip: beach escape, weekend getaway in Europe- Season or event: I would like to see cherry blossom in JapanWhen the query implies a time of year, Google dates it itself and reports the range in searchInformation.dateRange. |
departureId | LAX | Yes | Departure airport as a 3-letter uppercase IATA code, e.g. LAX or LHR. Search on IATA.One airport per search; city names are not accepted. |
arrivalId | - | No | Pins the search to one destination instead of letting Google pick from the query. - IATA code: 3 uppercase letters, e.g. NRT for Tokyo Narita.- Location kgmid: starts with /m/, found in Wikidata under “Freebase ID”, e.g. /m/07dfk for Tokyo.Required by every filter: type, travelClass, stops, outboundDate, returnDate, travelDuration, tripLength, maxPrice, maxDuration, includeAirlines and excludeAirlines. Without it Google drops them silently. |
type | - | No | Flight type. Requires arrivalId.- 1 / roundTrip — round trip (default)- 2 / oneWay — one wayA one-way deal carries no returnDate and no tripLengthDays. |
travelClass | - | No | Travel class. Requires arrivalId.- 1 / economy — economy (default)- 2 / premiumEconomy — premium economy- 3 / business — business- 4 / first — firstFares climb steeply: on LAX-NRT the same search ran 730ineconomyagainst2882 in business. |
outboundDate | - | No | When to depart. Requires arrivalId.- Exact date: 2026-12-10- Window: 2026-12-01,2026-12-10 — any day within itOmitted, Google picks the dates from the query, or from whatever is cheapest. |
returnDate | - | No | When to return, in the same exact-or-window spelling as outboundDate, which is required alongside it.Cannot be combined with travelDuration or tripLength — all three set the trip length. Ignored when type is oneWay. |
travelDuration | - | No | Preset trip length. Requires arrivalId. Cannot be combined with returnDate or tripLength.- 1 / week — about a week (6-8 days)- 2 / weekend — a weekend (2-3 days)- 3 / twoWeeks — about two weeks (13-15 days)Pairs with outboundDate to limit the departure period. Ignored when type is oneWay. |
tripLength | - | No | Trip length in days. Requires arrivalId. Cannot be combined with returnDate or travelDuration.- Exact: 7- Range: 5,10 — min firstPairs with outboundDate to limit the departure period. Ignored when type is oneWay. |
stops | - | No | Maximum number of stops. Requires arrivalId. Omitted, any number is allowed.- 1 / nonStop — direct flights only- 2 / oneStopOrFewer — at most one connection- 3 / twoStopsOrFewer — at most two connectionsA 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. |
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.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. |
maxPrice | - | No | Maximum ticket price, inclusive. Requires arrivalId. Omitted, it is unbounded.Read in the currency of the request: 650 means 650 EUR when currency is EUR, and 650 USD by default. |
includeAirlines | - | No | Keeps only these airlines. Requires arrivalId. Cannot be combined with excludeAirlines.Comma-separated 2-character IATA codes ( AF, UA, B6) and Google’s alliances STAR_ALLIANCE, SKYTEAM, ONEWORLD. The two can be mixed.An airline that does not serve the route returns an empty flightDeals array, not an error. |
excludeAirlines | - | No | Drops these airlines from the deals. Requires arrivalId. Cannot be combined with includeAirlines.Takes the same values as includeAirlines. |
adults | - | No | Number of adults. Prices cover the whole party, so raising this raises every deal price. Passenger counts reprice rather than narrow the search, so they need no arrivalId. The whole party must not exceed 9. |
children | - | No | Number of children, priced at their own fare. Counts towards the limit of 9 passengers. |
infantsInSeat | - | No | Number of infants in their own seat. Counts towards the limit of 9 passengers. |
infantsOnLap | - | No | Number of infants on an adult’s lap. Counts towards the limit of 9 passengers. Google prices a lap infant above one in its own seat — the opposite of how airlines usually charge. |
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 |