# Google Flights

## Google Flights API

The Google Flights API enables retrieval of Google Flights search results and returns structured JSON output. It supports flight search queries with filters such as departure and return dates, origin and destination, number of passengers, cabin class, number of stops, and more.

***

### API Setup

#### Endpoint

```
https://serp-api.netnut.io/search
```

#### Authentication

Use HTTP Basic Authentication:

```
Authorization: Basic <base64(username:password)>
```

Where `<base64(username:password)>` is the Base64-encoded string of your NetNut credentials.

***

### Request Format

The request is sent as a GET request. All parameters are passed directly in the URL query string.

#### Example Request

```
https://serp-api.netnut.io/search?engine=google_flights&flightFrom=ny&flightTo=lax&departureTime=2026-06-01&returnTime=2026-06-05&adults=1&hl=en&gl=us
```

***

### Request Parameters

| Parameter       | Type    | Required | Description                                                                                                            |
| --------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
| `engine`        | string  | Yes      | Must be set to `google_flights`                                                                                        |
| `flightFrom`    | string  | Yes      | Origin location. Accepts city name, airport code, or region (e.g., `ny`, `JFK`, `New York`)                            |
| `flightTo`      | string  | Yes      | Destination location. Accepts city name, airport code, or region (e.g., `lax`, `LAX`, `Los Angeles`)                   |
| `departureTime` | string  | Yes      | Departure date in `YYYY-MM-DD` format                                                                                  |
| `returnTime`    | string  | No       | Return date in `YYYY-MM-DD` format. Omit for one-way searches                                                          |
| `adults`        | integer | No       | Number of adult passengers. Defaults to `1`                                                                            |
| `children`      | integer | No       | Number of child passengers (ages 2-11). Defaults to `0`                                                                |
| `infants`       | integer | No       | Number of lap infant passengers (under 2). Defaults to `0`                                                             |
| `travelClass`   | integer | No       | Cabin class. `1` = Economy (default), `2` = Premium Economy, `3` = Business, `4` = First                               |
| `stops`         | integer | No       | Maximum number of stops. `0` = Nonstop only, `1` = 1 stop or fewer, `2` = 2 stops or fewer. Omit to return all results |
| `currency`      | string  | No       | Currency code for prices (e.g., `USD`, `EUR`, `GBP`). Defaults to `USD`                                                |
| `hl`            | string  | No       | Language code for results (e.g., `en`, `es`, `fr`). Defaults to `en`                                                   |
| `gl`            | string  | No       | Country code for localization (e.g., `us`, `gb`). Defaults to `us`                                                     |
| `rawHtml`       | integer | No       | `1` = Return both parsed JSON and raw HTML. `2` = Return raw HTML only. Omit for JSON only                             |

***

### Code Examples

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X GET "https://serp-api.netnut.io/search?engine=google_flights&flightFrom=ny&flightTo=lax&departureTime=2026-06-01&returnTime=2026-06-05&adults=1&hl=en&gl=us" \
  -u "username:password"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from base64 import b64encode

headers = {
    "Authorization": "Basic " + b64encode(b"username:password").decode()
}

params = {
    "engine": "google_flights",
    "flightFrom": "ny",
    "flightTo": "lax",
    "departureTime": "2026-06-01",
    "returnTime": "2026-06-05",
    "adults": 1,
    "hl": "en",
    "gl": "us"
}

response = requests.get("https://serp-api.netnut.io/search", headers=headers, params=params)
print(response.json())
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const username = "username";
const password = "password";

const params = new URLSearchParams({
  engine: "google_flights",
  flightFrom: "ny",
  flightTo: "lax",
  departureTime: "2026-06-01",
  returnTime: "2026-06-05",
  adults: 1,
  hl: "en",
  gl: "us"
});

const response = await fetch(`https://serp-api.netnut.io/search?${params}`, {
  method: "GET",
  headers: {
    "Authorization": "Basic " + Buffer.from(`${username}:${password}`).toString("base64")
  }
});

const data = await response.json();
console.log(data);
```

{% endtab %}
{% endtabs %}

***

### Response Format

The Google Flights API returns structured JSON. No HTML is returned by default. When `rawHtml=1`, the response includes both the parsed JSON and the raw HTML. When `rawHtml=2`, the response returns only the raw HTML.

***

### Example JSON Response

```json
{
  "url": "https://www.google.com/travel/flights/search?hl=en&gl=US&tfs=CBwQAhorEgoyMDI2LTA2LTAxag0IAxIJL20vMDJfMjg2cg4IAxIKL20vMDMwcWIzdBorEgoyMDI2LTA2LTA1ag4IAxIKL20vMDMwcWIzdHINCAMSCS9tLzAyXzI4NkABSAFwAYIBCwj___________8BmAEB&curr=USD",
  "general": {
    "searchEngine": "google_flights",
    "language": "en",
    "device": "desktop",
    "searchType": "text",
    "pageTitle": "New York to Los Angeles | Google Flights",
    "timestamp": "2026-06-01T16:02:22.487780767Z",
    "render": false
  },
  "input": {
    "originalUrl": "https://www.google.com/travel/flights/search?hl=en&gl=US&tfs=CBwQAhorEgoyMDI2LTA2LTAxag0IAxIJL20vMDJfMjg2cg4IAxIKL20vMDMwcWIzdBorEgoyMDI2LTA2LTA1ag4IAxIKL20vMDMwcWIzdHINCAMSCS9tLzAyXzI4NkABSAFwAYIBCwj___________8BmAEB&curr=USD",
    "jobId": "203e0593-8bfd-49ea-a75c-8136da9d04b5"
  },
  "organic": [],
  "flights": [
    {
      "departure_time": "8:05 AM",
      "total_duration": "6 hr 15 min",
      "stops": 0,
      "total_emissions": "277 kg CO2e",
      "price": "$468",
      "price_raw": 468,
      "legs": [
        {
          "departure_airport": {
            "name": "John F. Kennedy International Airport",
            "id": "JFK",
            "time": "8:05 AM"
          },
          "arrival_airport": {
            "name": "Los Angeles International Airport",
            "id": "LAX",
            "time": "11:20 AM"
          },
          "duration": "6 hr 15 min",
          "overnight": false,
          "airplane": "Boeing 777",
          "airline": "American",
          "airline_logo": "https://www.gstatic.com/flights/airline_logos/70px/AA.png",
          "travel_class": "Economy",
          "flight_number": "AA 255",
          "amenities": [
            "Average legroom (31 in)",
            "Wi-Fi for a fee",
            "On-demand video",
            "Emissions estimate: 277 kg CO2e",
            "Contrail warming potential: Low"
          ]
        }
      ],
      "rank": 1
    },
    {
      "departure_time": "5:25 AM",
      "total_duration": "6 hr 2 min",
      "stops": 0,
      "total_emissions": "407 kg CO2e",
      "price": "$577",
      "price_raw": 577,
      "legs": [
        {
          "departure_airport": {
            "name": "John F. Kennedy International Airport",
            "id": "JFK",
            "time": "5:25 AM"
          },
          "arrival_airport": {
            "name": "Los Angeles International Airport",
            "id": "LAX",
            "time": "8:27 AM"
          },
          "duration": "6 hr 2 min",
          "overnight": true,
          "airplane": "Airbus A320",
          "airline": "JetBlue",
          "airline_logo": "https://www.gstatic.com/flights/airline_logos/70px/B6.png",
          "travel_class": "Economy",
          "flight_number": "B6 123",
          "amenities": [
            "Above-average legroom (33 in)",
            "Free Wi-Fi",
            "Emissions estimate: 408 kg CO2e",
            "Contrail warming potential: Low"
          ]
        }
      ],
      "rank": 2
    },
    {
      "departure_time": "7:55 AM",
      "total_duration": "10 hr 28 min",
      "stops": 1,
      "total_emissions": "384 kg CO2e",
      "price": "$447",
      "price_raw": 447,
      "legs": [
        {
          "departure_airport": {
            "name": "LaGuardia Airport",
            "id": "LGA",
            "time": "7:55 AM"
          },
          "arrival_airport": {
            "name": "Charlotte Douglas International Airport",
            "id": "CLT",
            "time": "10:01 AM"
          },
          "duration": "2 hr 6 min",
          "overnight": false,
          "airplane": "Airbus A320",
          "airline": "American",
          "airline_logo": "https://www.gstatic.com/flights/airline_logos/70px/AA.png",
          "travel_class": "Economy",
          "flight_number": "AA 1023",
          "amenities": [
            "Average legroom (31 in)",
            "Free Wi-Fi",
            "Stream media to your device",
            "Emissions estimate: 106 kg CO2e",
            "Contrail warming potential: Low"
          ]
        },
        {
          "departure_airport": {
            "name": "Charlotte Douglas International Airport",
            "id": "CLT",
            "time": "1:20 PM"
          },
          "arrival_airport": {
            "name": "Los Angeles International Airport",
            "id": "LAX",
            "time": "3:23 PM"
          },
          "duration": "5 hr 3 min",
          "overnight": false,
          "airplane": "Airbus A321",
          "airline": "American",
          "airline_logo": "https://www.gstatic.com/flights/airline_logos/70px/AA.png",
          "travel_class": "Economy",
          "flight_number": "AA 352",
          "amenities": [
            "Average legroom (30 in)",
            "Free Wi-Fi",
            "Stream media to your device",
            "Emissions estimate: 279 kg CO2e",
            "Contrail warming potential: Low"
          ]
        }
      ],
      "rank": 3
    }
  ],
  "pagesProcessed": 1
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.netnut.io/netnut-documentation/netnut-scraper-apis/serp-api/google-scraper/google-flights.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
