openapi: 3.0.0
info:
  title: Google Finance Markets API
  description: |
    The Google Finance markets overview: market indexes by region, currencies, cryptocurrencies and futures, the day's top gainers, losers and most active stocks for a country, the latest market news and the equity sector lists.

    **Key Features:**
    - Market indexes for the US, Europe, Asia and Latin America, plus currencies, crypto and futures
    - Top gainers, losers and most active stocks for the `gl` country
    - Latest market news with source, link and publication time
    - Equity sector lists with price, change, previous close, open, high and low

    **Cross-linking**: Every market and mover row can be opened in full with the Google Finance API (`engine=google_finance`):
    - Pass `stock` and `exchange` joined by a colon (e.g., `.DJI:INDEXDJX`) as `q`
    - Pass the pair in `stock` (e.g., `EUR-USD`, `BTC-USD`) as `q` for currency and crypto rows
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Finance Markets Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to query
          schema:
            type: string
            enum: ["google_finance_markets"]
        - name: hl
          in: query
          required: false
          description: Interface language code
          schema:
            type: string
            enum: ["af", "ak", "sq", "am", "ar", "hy", "az", "eu", "be", "bem", "bn", "bh", "xx-bork", "bs", "br", "bg", "km", "ca", "chr", "ny", "zh-cn", "zh-tw", "co", "hr", "cs", "da", "nl", "xx-elmer", "en", "eo", "et", "ee", "fo", "tl", "fi", "fr", "fy", "gaa", "gl", "ka", "de", "el", "kl", "gn", "gu", "xx-hacker", "ht", "ha", "haw", "iw", "hi", "hu", "is", "ig", "id", "ia", "ga", "it", "ja", "jw", "kn", "kk", "rw", "rn", "xx-klingon", "kg", "ko", "kri", "ku", "ckb", "ky", "lo", "la", "lv", "ln", "lt", "loz", "lg", "ach", "mk", "mg", "my", "ms", "ml", "mt", "mv", "mi", "mr", "mfe", "mo", "mn", "sr-me", "ne", "pcm", "nso", "no", "nn", "oc", "or", "om", "ps", "fa", "xx-pirate", "pl", "pt", "pt-br", "pt-pt", "pa", "qu", "ro", "rm", "nyn", "ru", "gd", "sr", "sh", "st", "tn", "crs", "sn", "sd", "si", "sk", "sl", "so", "es", "es-419", "su", "sw", "sv", "tg", "ta", "tt", "te", "th", "ti", "to", "lua", "tum", "tr", "tk", "tw", "ug", "uk", "ur", "uz", "vu", "vi", "cy", "wo", "xh", "yi", "yo", "zu"]
            default: "en"
        - name: gl
          in: query
          required: false
          description: Country code. Returns the markets overview Google Finance shows in that country, with its gainers, losers and most active stocks and, for many countries, the currency and crypto pairs quoted in its local currency. Some countries get a regional index tab in place of another (`india` replaces `asia` for `in`, `americas` replaces `us` for `ca`). A country without a market of its own gets the overview Google Finance maps it to, usually the US one.
          schema:
            type: string
            enum: ["af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "be", "bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "iq", "ie", "il", "it", "jm", "jp", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "rw", "sh", "kn", "lc", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sk", "si", "sb", "so", "za", "gs", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "uk", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw", "gg", "je", "im", "me"]
            default: "us"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        markets:
          $ref: '#/components/schemas/Markets'
        gainers:
          type: array
          description: Stocks with the largest price gain of the day
          items:
            $ref: '#/components/schemas/Mover'
        losers:
          type: array
          description: Stocks with the largest price drop of the day
          items:
            $ref: '#/components/schemas/Mover'
        most_active:
          type: array
          description: The most actively traded stocks of the day
          items:
            $ref: '#/components/schemas/Mover'
        news:
          type: array
          description: Market news sections
          items:
            $ref: '#/components/schemas/NewsSection'
        lists:
          type: array
          description: Lists of related symbols (e.g., Equity sectors)
          items:
            $ref: '#/components/schemas/ListSection'
        error:
          type: string
          description: Error message when Google Finance returns no markets overview, such as for a country it does not serve
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: Google Finance URL for this search
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        hl:
          type: string
          description: Interface language used
        gl:
          type: string
          description: Country used
    Markets:
      type: object
      description: Market rows grouped by region tab
      properties:
        us:
          type: array
          description: US market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        americas:
          type: array
          description: Americas market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        europe:
          type: array
          description: European market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        asia:
          type: array
          description: Asian market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        india:
          type: array
          description: Indian market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        latin_america:
          type: array
          description: Latin American market indexes
          items:
            $ref: '#/components/schemas/MarketQuote'
        currencies:
          type: array
          description: Currency exchange rates
          items:
            $ref: '#/components/schemas/MarketQuote'
        crypto:
          type: array
          description: Cryptocurrency prices
          items:
            $ref: '#/components/schemas/MarketQuote'
        futures:
          type: array
          description: Futures prices
          items:
            $ref: '#/components/schemas/MarketQuote'
    MarketQuote:
      type: object
      # Currency and crypto rows have no exchange, `name` is English-only, Google occasionally
      # omits `company` for a foreign index, and only futures rows carry `currency`.
      required: [stock, link, price, price_change]
      properties:
        stock:
          type: string
          description: Ticker symbol, or the pair for currency and crypto rows (e.g., `EUR-USD`)
        exchange:
          type: string
          description: Exchange the symbol is listed on
        company:
          type: string
          description: Full name of the index, instrument or pair
        link:
          type: string
          description: Google Finance page of the quote
        name:
          type: string
          description: Short display name
        price:
          type: number
          description: Current price
        price_change:
          $ref: '#/components/schemas/PriceChange'
        date:
          type: string
          description: Time of the price with its UTC offset
        currency:
          type: string
          description: Currency code of the price, such as `USD`
    Mover:
      type: object
      required: [stock, exchange, company, link, price, price_change, currency]
      properties:
        stock:
          type: string
          description: Ticker symbol
        exchange:
          type: string
          description: Exchange the stock is listed on
        company:
          type: string
          description: Company name
        link:
          type: string
          description: Google Finance page of the stock
        price:
          type: number
          description: Current price
        price_change:
          $ref: '#/components/schemas/PriceChange'
        date:
          type: string
          description: Time of the price with its UTC offset
        currency:
          type: string
          description: Currency code of the price, such as `USD`, or a minor unit such as `GBX` (pence), `ILA` (agorot) or `ZAC` (South African cents)
    PriceChange:
      type: object
      required: [percentage]
      properties:
        percentage:
          type: number
          description: Price change percentage
        amount:
          type: number
          description: Price change amount
        movement:
          type: string
          description: Price movement direction
          enum: ["Up", "Down"]
    NewsSection:
      type: object
      required: [title, articles]
      properties:
        title:
          type: string
          description: News section title
        articles:
          type: array
          description: Articles in this section
          items:
            $ref: '#/components/schemas/Article'
    Article:
      type: object
      required: [title, link, source, date, favicon]
      properties:
        title:
          type: string
          description: Article headline
        link:
          type: string
          description: Article URL
        source:
          type: string
          description: News source
        date:
          type: string
          description: Relative publication time in the `hl` language
        favicon:
          type: string
          description: Source favicon URL
    ListSection:
      type: object
      required: [title, items]
      properties:
        title:
          type: string
          description: List title (e.g., "Equity sectors")
        items:
          type: array
          description: Symbols in this list
          items:
            $ref: '#/components/schemas/ListItem'
    ListItem:
      type: object
      required: [stock, price]
      properties:
        stock:
          type: string
          description: Symbol
        name:
          type: string
          description: Symbol name
        price:
          type: number
          description: Current price
        price_change:
          $ref: '#/components/schemas/PriceChange'
        previous_close:
          type: number
          description: Previous close price
        open:
          type: number
          description: Open price
        high:
          type: number
          description: High price
        low:
          type: number
          description: Low price
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
