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

# Google flights API

> Search flights with prices and times. Call the Google flights API and get JSON back in one request. 1 credit per call. Failed calls cost nothing.

Searches flights with prices and times.

## Request

`origin`, `destination` and `departDate` are required.

<CodeGroup>
  ```typescript TypeScript icon="https://mintlify.s3.us-west-1.amazonaws.com/sirathic/images/icons/typescript.svg" theme={null} theme={null}
  import { Stophy } from "stophy";

  const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
  const result = await stophy.google.flights({ origin: "JFK", destination: "LAX", departDate: "2026-11-19" });
  console.log(result.data.results);
  ```

  ```python Python icon="python" theme={null} theme={null}
  from stophy import Stophy

  stophy = Stophy()  # reads STOPHY_API_KEY
  result = stophy.google.flights(origin="JFK", destination="LAX", depart_date="2026-11-19")
  print(result["data"]["results"])
  ```

  ```bash cURL icon="terminal" theme={null} theme={null}
  curl -X POST https://api.stophy.dev/v1/google/flights \
    -H "Authorization: Bearer $STOPHY_API_KEY" \
    -H "content-type: application/json" \
    -d '{"origin":"JFK","destination":"LAX","departDate":"2026-11-19"}'
  ```

  ```bash CLI icon="square-terminal" theme={null} theme={null}
  stophy google flights --origin JFK --destination LAX --departDate 2026-11-19
  ```
</CodeGroup>

## Response

If successful, the response body contains the standard envelope. `data.results[]` contains the flight options, each with its price, airlines, stops, times and legs.

The following example is a real response, truncated: each list shows one item and long strings are cut.

```json theme={null}
{
  "success": true,
  "data": {
    "cabin": "economy",
    "tripType": "oneWay",
    "adults": 1,
    "results": [
      {
        "isBest": true,
        "price": 139,
        "priceCurrency": "USD",
        "airlines": ["JetBlue"],
        "stops": 1,
        "durationSeconds": 40440,
        "departureLocalTime": "2026-11-19T15:45",
        "arrivalLocalTime": "2026-11-19T23:59",
        "legs": [
          {
            "flightNumber": "B6 618",
            "airline": "JetBlue",
            "originCode": "JFK",
            "originName": "John F. Kennedy International Airport",
            "destinationCode": "BOS",
            "destinationName": "Boston Logan International Airport",
            "departureLocalTime": "2026-11-19T15:45",
            "arrivalLocalTime": "2026-11-19T17:03",
            "durationSeconds": 4680,
            "aircraft": "Airbus A220-300 Passenger",
            "legroom": "32 inches"
          }
        ],
        "layovers": [
          {
            "airport": "BOS",
            "name": "Boston Logan International Airport",
            "city": "Boston",
            "durationSeconds": 12360
          }
        ],
        "emissionsGrams": 478000,
        "typicalEmissionsGrams": 320000
      }
    ]
  },
  "creditsUsed": 1,
  "requestId": "2fe9dbad-fc48-4890-9751-0b24b596035b"
}
```

| Field | Type | Description |
| - | - | - |
| `price` | number | Total fare in USD for all adults together. For a round trip it covers both directions. |
| `legs` | object\[] | The outbound journey only, including a return search. |
| `departureLocalTime` | string | Local time at the airport, YYYY-MM-DDTHH:mm, no time zone. |
| `isBest` | boolean | `true` for the options Google marks as best. |
| `durationSeconds` | integer | The duration, in seconds. |

For every field, see the response schema on this page.

## Optional parameters

| Parameter | Type | Description |
| - | - | - |
| `returnDate` | string | The return date. Leave it out for a one-way trip. Format: `YYYY-MM-DD`. |
| `adults` | integer | The number of adults. Must be between 1 and 9. If unset, defaults to `1`. |
| `cabin` | string | The cabin class. Acceptable values are `economy`, `premiumEconomy`, `business` and `first`. If unset, defaults to `economy`. |
| `stops` | string | The number of stops to allow. Acceptable values are `any`, `nonstop`, `oneStopOrFewer` and `twoStopsOrFewer`. If unset, defaults to `any`. |
| `airlines` | string\[] | Restricts results to these airlines, as codes such as `KQ` or `EK`. Accepts up to 10 values. |
| `carryOnBags` | integer | Include this many carry-on bags in the price. Must be between 0 and 1. If unset, defaults to `0`. |
| `checkedBags` | integer | Include this many checked bags in the price. Must be between 0 and 2. If unset, defaults to `0`. |
| `maxPrice` | integer | The maximum price, in USD, for all adults. |
| `departureTime` | object | Limit the outbound departure to these hours of the day. An object with `earliest` and `latest`, each an hour from 0 to 24. |
| `arrivalTime` | object | Limit the outbound arrival to these hours of the day. An object with `earliest` and `latest`, each an hour from 0 to 24. |
| `maxDurationHours` | integer | Longest trip, in hours. Must be between 1 and 48. |

## Billing

Each successful request consumes 1 credit, regardless of the number of items returned. Requests that fail, or that return no items, are not billed.

## Pagination

This method is not paginated. A single request returns the complete result.

## Related methods

* [Google Hotels](/api-reference/endpoint/google-hotels): Accepts a leg's `destinationName` as `query`. Searches Google Hotels with prices, ratings and Google's own filters.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/google/flights
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Every endpoint is a POST that takes its input as a JSON object body. Unknown
    fields are rejected with 400.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    x-credits is what one call costs. Every call costs the same, whatever it
    returns, unless an operation's description says it costs per 10 results, or
    per second of audio. Then x-credits is the lowest price and x-credits-max
    the most one call can cost. Where an operation takes limit, send it to
    return fewer results and pay for fewer.


    When a response has a cursor, send it back unchanged with the same input to
    get the next page. When it has a page, send the next page number.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/google/flights:
    post:
      summary: Search flights with prices and times
      description: Costs 1 credit per call.
      operationId: googleFlights
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                origin:
                  type: string
                  pattern: ^[A-Za-z]{3}$
                  description: IATA airport code, e.g. JFK. Any case is accepted.
                destination:
                  type: string
                  pattern: ^[A-Za-z]{3}$
                  description: IATA airport code, e.g. JFK. Any case is accepted.
                departDate:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}$
                returnDate:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}$
                adults:
                  default: 1
                  type: integer
                  minimum: 1
                  maximum: 9
                cabin:
                  default: economy
                  type: string
                  enum:
                    - economy
                    - premiumEconomy
                    - business
                    - first
                stops:
                  default: any
                  description: Google Flights' Stops filter.
                  type: string
                  enum:
                    - any
                    - nonstop
                    - oneStopOrFewer
                    - twoStopsOrFewer
                airlines:
                  default: []
                  description: >-
                    Google Flights' Airlines filter, as airline codes like KQ or
                    EK.
                  maxItems: 10
                  type: array
                  items:
                    type: string
                    pattern: ^[A-Z0-9]{2}$
                carryOnBags:
                  default: 0
                  description: >-
                    Google Flights' Bags filter: prices include this many
                    carry-on bags.
                  type: integer
                  minimum: 0
                  maximum: 1
                checkedBags:
                  default: 0
                  description: >-
                    Google Flights' Bags filter: prices include this many
                    checked bags.
                  type: integer
                  minimum: 0
                  maximum: 2
                maxPrice:
                  description: Google Flights' Price filter, in USD for all adults.
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 9007199254740991
                departureTime:
                  description: Google Flights' Times filter for the outbound departure.
                  type: object
                  properties:
                    earliest:
                      default: 0
                      type: integer
                      minimum: 0
                      maximum: 24
                    latest:
                      default: 24
                      type: integer
                      minimum: 0
                      maximum: 24
                arrivalTime:
                  description: Google Flights' Times filter for the outbound arrival.
                  type: object
                  properties:
                    earliest:
                      default: 0
                      type: integer
                      minimum: 0
                      maximum: 24
                    latest:
                      default: 24
                      type: integer
                      minimum: 0
                      maximum: 24
                maxDurationHours:
                  description: Google Flights' Duration filter.
                  type: integer
                  minimum: 1
                  maximum: 48
              required:
                - origin
                - destination
                - departDate
              additionalProperties: false
            example:
              origin: JFK
              destination: LAX
              departDate: '2026-11-19'
      responses:
        '200':
          description: The data, and the credits this call used.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            x-credits-used:
              $ref: '#/components/headers/CreditsUsed'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            x-cache:
              $ref: '#/components/headers/Cache'
            x-cache-age:
              $ref: '#/components/headers/CacheAge'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  data:
                    type: object
                    additionalProperties: false
                    properties:
                      cabin:
                        type: string
                        enum:
                          - economy
                          - premiumEconomy
                          - business
                          - first
                      tripType:
                        type: string
                        enum:
                          - oneWay
                          - roundTrip
                      adults:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                      results:
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          properties:
                            isBest:
                              type: boolean
                            price:
                              description: >-
                                Total fare in USD for all adults together. For a
                                round trip it covers both directions.
                              type: number
                            priceCurrency:
                              type: string
                              const: USD
                            airlines:
                              type: array
                              items:
                                type: string
                            stops:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            durationSeconds:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            departureLocalTime:
                              description: >-
                                Local time at the airport, YYYY-MM-DDTHH:mm, no
                                time zone.
                              type: string
                            arrivalLocalTime:
                              description: >-
                                Local time at the airport, YYYY-MM-DDTHH:mm, no
                                time zone.
                              type: string
                            legs:
                              type: array
                              items:
                                type: object
                                additionalProperties: false
                                properties:
                                  flightNumber:
                                    type: string
                                  airline:
                                    type: string
                                  originCode:
                                    type: string
                                  originName:
                                    type: string
                                  destinationCode:
                                    type: string
                                  destinationName:
                                    type: string
                                  departureLocalTime:
                                    description: >-
                                      Local time at the airport,
                                      YYYY-MM-DDTHH:mm, no time zone.
                                    type: string
                                  arrivalLocalTime:
                                    description: >-
                                      Local time at the airport,
                                      YYYY-MM-DDTHH:mm, no time zone.
                                    type: string
                                  durationSeconds:
                                    type: integer
                                    minimum: -9007199254740991
                                    maximum: 9007199254740991
                                  aircraft:
                                    type: string
                                  legroom:
                                    type: string
                                required: []
                              description: >-
                                The outbound journey only, including a return
                                search.
                            layovers:
                              type: array
                              items:
                                type: object
                                additionalProperties: false
                                properties:
                                  airport:
                                    type: string
                                  name:
                                    type: string
                                  city:
                                    type: string
                                  durationSeconds:
                                    type: integer
                                    minimum: -9007199254740991
                                    maximum: 9007199254740991
                                required: []
                            emissionsGrams:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            typicalEmissionsGrams:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                          required:
                            - isBest
                            - stops
                        description: >-
                          Outbound flight options. With returnDate, each price
                          is the round-trip total for that outbound choice.
                    required:
                      - cabin
                      - tripType
                      - adults
                      - results
                  creditsUsed:
                    type: integer
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    CreditsUsed:
      description: Credits this call used.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    Cache:
      description: hit if this result came from the cache, miss if it was fetched live.
      schema:
        type: string
    CacheAge:
      description: Seconds since the returned result was written to the cache.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. retryable says whether trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          const: false
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - requestId
          properties:
            code:
              type: string
              enum:
                - cliSessionCompleted
                - cliSessionExists
                - cliSessionNotFound
                - forbidden
                - insufficientCredits
                - internalError
                - inviteClaimed
                - inviteDisabled
                - inviteExpired
                - inviteUsedUp
                - invalidCliSession
                - invalidCliVerifier
                - invalidRequest
                - notFound
                - rateLimited
                - sourceChanged
                - sourceRefused
                - sourceTimeout
                - sourceUnavailable
                - tooManyInFlight
                - unauthorized
                - unsupportedMediaType
            message:
              type: string
            retryable:
              type: boolean
            retryAfterSeconds:
              type: integer
            requestId:
              type: string
            requiredCredits:
              type: number
            availableCredits:
              type: number
            billingUrl:
              type: string
              const: https://stophy.dev/billing
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.