openapi: 3.0.0
info:
  title: Google Shopping Filters API
  description: |
    The Google Shopping Filters API retrieves available filter options for Google Shopping searches. It requires an `all_filters_token` which encodes filter parameters from a Google Shopping search.

    **Cross-linking**: The `shoprs` values returned by this API can be used with the Google Shopping Search API to apply filters to product searches. Pass the `shoprs` value as the `shoprs` parameter in Google Shopping searches.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Shopping Filters Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["google_shopping_filters"]
            default: "google_shopping_filters"
        - name: all_filters_token
          in: query
          required: true
          description: Encoded token containing filter parameters from a Google Shopping search
          schema:
            type: string
      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'
        filters:
          type: array
          description: List of available filters
          items:
            $ref: '#/components/schemas/Filter'
        error:
          type: string
          description: Error message if filters could not be retrieved
    SearchMetadata:
      type: object
      required: [id, 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 Shopping Filters 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:
        all_filters_token:
          type: string
          description: Encoded token containing filter parameters
    Filter:
      type: object
      properties:
        type:
          type: string
          description: Type of filter (e.g., Carrier, Storage Capacity, Color, Stores)
        options:
          type: array
          description: Available options for this filter
          items:
            $ref: '#/components/schemas/FilterOption'
      required:
        - options
    FilterOption:
      type: object
      properties:
        text:
          type: string
          description: Display text for the filter option
        shoprs:
          type: string
          description: Encoded value to use with Google Shopping Search API
      required:
        - text
        - shoprs
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong