openapi: 3.0.0
info:
  title: Google Images Related Content API
  description: |
    The Google Images Related Content API returns the related content Google Images shows when you open an image:
    visually related images (with their source, original size and, for products, price and rating) and related searches.

    **Cross-linking**: Take `related_content_id` from an image in a Google Images or Google Images Light response
    (`images[].related_content_id`) and pass it with the same `q`. Every related image carries its own
    `related_content_id`, so you can pass it back to this API to open that image's related content.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Images Related Content
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["google_images_related_content"]
            default: "google_images_related_content"
        - name: related_content_id
          in: query
          required: true
          description: Identifier of the image, taken from images[].related_content_id of a Google Images or Google Images Light response, or from related_content[].related_content_id of a previous response
          schema:
            type: string
            maxLength: 128
        - name: q
          in: query
          required: false
          description: Search query that returned the image, which keeps the related content in the context of that search
          schema:
            type: string
        - name: hl
          in: query
          required: false
          description: Language for the search interface
          schema:
            type: string
            default: "en"
            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"]
        - name: gl
          in: query
          required: false
          description: Country code for search results
          schema:
            type: string
            default: "us"
            enum: ["af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "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", "ir", "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", "ru", "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"]
      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'
        related_content:
          type: array
          description: Images Google shows as related to the requested image
          items:
            $ref: '#/components/schemas/RelatedContent'
        related_searches:
          type: array
          description: Searches Google suggests for the requested image
          items:
            $ref: '#/components/schemas/RelatedSearch'
        see_more_link:
          type: string
          description: Google Images URL listing more images related to the requested image
        error:
          type: string
          description: Error message when Google has no related content for the image
    RelatedContent:
      type: object
      required: [position, title, source, original, thumbnail, related_content_id]
      properties:
        position:
          type: integer
          description: Position of the image in the related content
        title:
          type: string
          description: Title of the page containing the image
        source:
          $ref: '#/components/schemas/ImageSource'
        original:
          $ref: '#/components/schemas/OriginalImage'
        thumbnail:
          type: string
          description: URL of the thumbnail image
        related_content_id:
          type: string
          description: Identifier to pass as related_content_id to get this image's related content
        tag:
          type: string
          description: Label Google shows on the image, such as "Licensable"
        is_product:
          type: boolean
          description: Whether Google lists the image as a product
        price:
          type: string
          description: Product price as displayed
        extracted_price:
          type: number
          description: Product price as a number
        currency:
          type: string
          description: Currency of the product price (ISO 4217)
        stock_information:
          type: string
          description: Stock availability as displayed
        rating:
          type: number
          description: Product rating
        reviews:
          type: integer
          description: Number of product reviews
    ImageSource:
      type: object
      required: [name, link, favicon]
      properties:
        name:
          type: string
          description: Name of the source website
        link:
          type: string
          description: URL of the page containing the image
        favicon:
          type: string
          description: Favicon of the source website, as an image URL or an inline data URI
    OriginalImage:
      type: object
      required: [link, width, height]
      properties:
        link:
          type: string
          description: URL of the original image
        width:
          type: integer
          description: Width of the original image in pixels
        height:
          type: integer
          description: Height of the original image in pixels
    RelatedSearch:
      type: object
      required: [position, query, link, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the related search
        query:
          type: string
          description: Related search query text
        link:
          type: string
          description: Google Images URL for the related search
        thumbnail:
          type: string
          description: Thumbnail image URL for the related search
    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
          nullable: true
          description: Google Images 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 identifier
        related_content_id:
          type: string
          description: Identifier of the image
        q:
          type: string
          description: Search query that returned the image
        hl:
          type: string
          description: Language for the search interface
        gl:
          type: string
          description: Country code for search results
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
