openapi: 3.0.0
info:
  title: Shopify Collections API
  description: |
    Get the collections of a Shopify store, up to 250 per page.

    Pass a collection's handle to the Shopify Products API to get its products.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Shopify Collections Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `shopify_collections`'
          schema:
            type: string
            enum: ["shopify_collections"]
        - name: domain
          in: query
          required: true
          description: The store's domain, such as `allbirds.com` or `kith.com`, or any link on the store. A `myshopify.com` domain also works.
          schema:
            type: string
        - name: page
          in: query
          required: false
          description: Page of results, at the size `num` sets.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: num
          in: query
          required: false
          description: Number of results per page, from 1 to 250.
          schema:
            type: integer
            minimum: 1
            maximum: 250
            default: 30
        - name: zero_retention
          in: query
          required: false
          description: Set to true to disable logging and persistent storage for this request. Enterprise plans only.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Successful response. A domain that is not a Shopify store or a password protected store returns `error`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. A parameter is missing or invalid, or the domain cannot be reached.
          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'
        '403':
          description: Forbidden. Zero data retention is not available to the account, or the account requires `zero_retention=true`.
          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
      required: [search_metadata, search_parameters]
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        store_information:
          $ref: '#/components/schemas/StoreInformation'
        collections:
          type: array
          items:
            $ref: '#/components/schemas/Collection'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why there are no collections to return.
    Collection:
      type: object
      required: [position, collection_id, title, handle, link, products_count]
      properties:
        position:
          type: integer
          description: Position of the collection across pages.
        collection_id:
          type: integer
          description: Shopify identifier of the collection.
        title:
          type: string
          description: Collection title.
        handle:
          type: string
          description: The collection's handle, to pass to the Shopify Products API as `collection_handle`.
        link:
          type: string
          description: Link to the collection page.
        description:
          type: string
          description: Collection description as plain text.
        thumbnail:
          type: string
          description: Collection image.
        products_count:
          type: integer
          description: Number of products the store reports for the collection, which can be more than the products it lists.
        published_at:
          type: string
          format: date-time
          description: Time the collection was published.
        updated_at:
          type: string
          format: date-time
          description: Time the collection was last updated.
    StoreInformation:
      type: object
      required: [store_id, myshopify_domain]
      properties:
        store_id:
          type: integer
          description: Shopify identifier of the store.
        name:
          type: string
          description: Store name.
        domain:
          type: string
          description: The store's primary domain.
        myshopify_domain:
          type: string
          description: The store's myshopify.com domain.
        link:
          type: string
          description: Link to the store.
        description:
          type: string
          description: Store description.
        currency:
          type: string
          description: ISO 4217 code of the currency the store prices in.
        country:
          type: string
          description: ISO 3166-1 alpha-2 code of the store's country.
        province:
          type: string
          description: The store's province or state.
        city:
          type: string
          description: The store's city.
        ships_to_countries:
          type: array
          description: ISO 3166-1 alpha-2 codes of the countries the store ships to.
          items:
            type: string
        products_count:
          type: integer
          description: Number of products the store has published.
        collections_count:
          type: integer
          description: Number of collections the store has published.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page.
        next_page:
          type: integer
          description: Value to pass as `page` for the next page, shown after any full page within the store's first 25,000 collections, even the last one.
    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: Shopify URL for this search
        html_url:
          type: string
          description: URL to view the raw results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
        domain:
          type: string
        page:
          type: integer
        num:
          type: integer
        zero_retention:
          type: boolean
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
