Constructor Image Search API

AI-optimized search results retrieved by uploaded image, with optional multi-item detection (segmentation) support.

OpenAPI Specification

constructorio-image-search-openapi.yml Raw ↑
openapi: 3.1.0
info:
  contact:
    email: support@constructor.io
  title: Image Search
  version: '0.1'
servers:
- url: https://image-search.cnstrc.com
security: []
tags:
- name: Image Search results
paths:
  /v1/image_search:
    post:
      tags:
      - Image Search results
      operationId: v1-image-search-get-search-results
      summary: Retrieve by image (Deprecated)
      description: Retrieve AI optimized search results for products (or optionally other sections) by image
      deprecated: true
      parameters:
      - name: key
        in: query
        schema:
          title: Key
          description: The key of the index to use.
          maxLength: 100
          minLength: 1
          type: string
        required: true
      - name: section
        in: query
        schema:
          title: Section
          description: The section of the index to use.
          default: Products
          maxLength: 100
          minLength: 1
          type: string
        required: false
      - name: variations_map
        in: query
        schema:
          title: Variations Map
          description: A JSON string containing a instructions on how to map item variation data in the response (typically used for swatches). More details, including the exact schema for this value can be found [here](/reference/shared-variations-mapping)
          format: json
          type: string
          examples:
          - '{"group_by":[{"name":"color","field":"data.color"}],"values":{"price":{"aggregation":"min","field":"data.price"}},"dtype":"array"}'
          allOf:
          - $ref: '#/components/schemas/VariationsMap'
        required: false
      - name: fmt_options
        in: query
        schema:
          title: Fmt Options
          description: An object containing options to format different aspect of the response.
          allOf:
          - $ref: '#/components/schemas/FmtOptions'
        required: false
        style: deepObject
        explode: true
      - name: c
        in: query
        schema:
          title: C
          description: The ID of the client and version that the request is coming from, such as `cio-js-2.90`.
          maxLength: 100
          minLength: 1
          examples:
          - cio-js-client-2.35.2
          type: string
        required: false
      - name: us
        in: query
        schema:
          title: us
          description: A customer defined context (such as `vip-club-member`) used to evaluate redirect or refined tag rules. Pass multiple segments by passing multiple `us` arguments.
          type: array
          items:
            type: string
            minLength: 1
            examples:
            - vip-member
            - us-east-region
        required: false
      - name: ui
        in: query
        schema:
          title: Ui
          description: A customer generated anonymized identifier for a user on a customer website. It should only be sent for logged in customers and helps Constructor to tie multiple client and session IDs together to form a behavioral data profile across devices.
          examples:
          - customer-user-id-456
          type: string
        required: false
      - name: s
        in: query
        schema:
          title: S
          description: An integer representing the users session number (starting with `1`), incremented after a 30 minute period of inactivity.
          examples:
          - 1
          type: integer
        required: false
      - name: i
        in: query
        schema:
          title: I
          description: A globally unique identifier for the user browser (or mobile application instance) making the request.
          examples:
          - user-device-id-123
          type: string
        required: false
      requestBody:
        required: true
        description: 'Raw image bytes. Supported formats: JPEG, PNG, WebP, GIF. Maximum size: 6 MB.'
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageSearchPostResponse'
        '400':
          description: Validation Error
      security: []
  /v2/image_search:
    post:
      tags:
      - Image Search results
      operationId: v2-image-search-retrieve-search-results
      summary: Retrieve by image
      description: Retrieve AI optimized search results for products (or optionally other sections) by image with optional multi-item detection (segmentation) support.
      parameters:
      - name: key
        in: query
        schema:
          title: Key
          description: The key of the index to use.
          examples:
          - key_K2pX7vBnU0bgA5xp
          maxLength: 100
          minLength: 1
          type: string
        required: true
      - name: section
        in: query
        schema:
          title: Section
          description: The section of the index to use.
          default: Products
          maxLength: 100
          minLength: 1
          type: string
        required: false
      - name: search_crop_type
        in: query
        schema:
          title: Search Crop Type
          description: How to crop detected segments for visual search. Only relevant when `use_segmentation` is `true`.
          default: bbox
          enum:
          - bbox
          - segment
          type: string
        required: false
        examples:
          bbox:
            summary: Bounding-box crop (default)
            description: Each detected object is cropped as a full rectangle including background pixels.
            value: bbox
          segment:
            summary: Masked segment crop
            description: Each detected object is cropped with the background removed, so only the object pixels are used for visual search.
            value: segment
      - name: variations_map
        in: query
        schema:
          title: Variations Map
          description: A JSON string containing a instructions on how to map item variation data in the response (typically used for swatches). More details, including the exact schema for this value can be found [here](/reference/shared-variations-mapping)
          format: json
          type: string
          examples:
          - '{"group_by":[{"name":"color","field":"data.color"}],"values":{"price":{"aggregation":"min","field":"data.price"}},"dtype":"array"}'
          allOf:
          - $ref: '#/components/schemas/VariationsMap'
        required: false
      - name: fmt_options
        in: query
        schema:
          title: Fmt Options
          description: An object containing options to format different aspect of the response.
          allOf:
          - $ref: '#/components/schemas/FmtOptions'
        required: false
        style: deepObject
        explode: true
      - name: c
        in: query
        schema:
          title: C
          description: The ID of the client and version that the request is coming from, such as `cio-js-2.90`.
          maxLength: 100
          minLength: 1
          examples:
          - cio-js-client-2.35.2
          type: string
        required: false
      - name: us
        in: query
        schema:
          title: us
          description: A customer defined context (such as `vip-club-member`) used to evaluate redirect or refined tag rules. Pass multiple segments by passing multiple `us` arguments.
          type: array
          items:
            type: string
            minLength: 1
            examples:
            - vip-member
            - us-east-region
        required: false
      - name: use_segmentation
        in: query
        schema:
          title: Use Segmentation
          description: Whether to detect and individually search multiple objects in the image. When `true`, the image is split into detected objects and each is searched separately; results are merged.
          default: false
          type: boolean
        required: false
        examples:
          enabled:
            summary: Segmentation on
            description: The image is split into detected objects, each searched separately; results are merged.
            value: true
          disabled:
            summary: Segmentation off (default)
            description: The whole image is searched as-is.
            value: false
      - name: ui
        in: query
        schema:
          title: Ui
          description: A customer generated anonymized identifier for a user on a customer website. It should only be sent for logged in customers and helps Constructor to tie multiple client and session IDs together to form a behavioral data profile across devices.
          examples:
          - customer-user-id-456
          type: string
        required: false
      - name: return_segments
        in: query
        schema:
          title: Return Segments
          description: Whether to include per-segment metadata in the response. Only applicable when `use_segmentation` is `true`.
          default: false
          type: boolean
        required: false
        examples:
          enabled:
            summary: Include segments
            description: Response includes a segments array with bounding boxes, class names, confidence scores, interior points for visualization and per-segment neighbours lists.
            value: true
          disabled:
            summary: Omit segments (default)
            description: No per-segment metadata in the response. Merged results are still returned when `use_segmentation` is `true`.
            value: false
      - name: s
        in: query
        schema:
          title: S
          description: An integer representing the users session number (starting with `1`), incremented after a 30 minute period of inactivity.
          examples:
          - 1
          type: integer
        required: false
      - name: i
        in: query
        schema:
          title: I
          description: A globally unique identifier for the user browser (or mobile application instance) making the request.
          examples:
          - user-device-id-123
          type: string
        required: false
      requestBody:
        required: true
        description: 'Raw image bytes. Supported formats: JPEG, PNG, WebP, GIF. Maximum size: 6 MB.'
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageSearchPostResponseV2'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    VariationsMapRange:
      title: VariationsMapRange
      type: object
      properties:
        field:
          title: Field
          description: Path to a metadata field (dot-separated)
          minLength: 1
          type: string
        range:
          title: Range
          description: This filter matches items where the specified field is within the specified range (min and max). The values are inclusive. Use "inf" for an unbounded upper limit or "-inf" for an unbounded lower limit.
          minItems: 2
          maxItems: 2
          type: array
          items:
            anyOf:
            - enum:
              - inf
              - -inf
              type: string
            - type: integer
            - type: number
      required:
      - field
      - range
      additionalProperties: false
    VariationsMapSingleFilter:
      title: VariationsMapSingleFilter
      type: object
      properties:
        field:
          title: Field
          description: Path to a metadata field (dot-separated)
          minLength: 1
          type: string
        value:
          title: Value
          description: The value of this field to filter by
          anyOf:
          - type: boolean
          - type: integer
          - type: number
          - type: string
      required:
      - field
      - value
      additionalProperties: false
    VariationsMapOr:
      title: VariationsMapOr
      type: object
      properties:
        or_:
          title: Or
          type: array
          items:
            type: array
      required:
      - or_
      additionalProperties: false
    VariationsMapAnd:
      title: VariationsMapAnd
      type: object
      properties:
        and_:
          title: And
          type: array
          items:
            type: array
      required:
      - and_
      additionalProperties: false
    VariationsMapNot:
      title: VariationsMapNot
      type: object
      properties:
        not_:
          type: object
      required:
      - not_
      additionalProperties: false
    VariationsMapFilterBy:
      title: VariationsMapFilterBy
      discriminator:
        propertyName: type
        mapping:
          range: '#/components/schemas/VariationsMapRange'
          single: '#/components/schemas/VariationsMapSingleFilter'
          or: '#/components/schemas/VariationsMapOr'
          and: '#/components/schemas/VariationsMapAnd'
          not: '#/components/schemas/VariationsMapNot'
      oneOf:
      - $ref: '#/components/schemas/VariationsMapRange'
      - $ref: '#/components/schemas/VariationsMapSingleFilter'
      - $ref: '#/components/schemas/VariationsMapOr'
      - $ref: '#/components/schemas/VariationsMapAnd'
      - $ref: '#/components/schemas/VariationsMapNot'
    VariationsMapGrouping:
      title: VariationsMapGrouping
      type: object
      properties:
        name:
          title: Name
          pattern: ^\w+([ ]?[\w]+)*$
          type: string
        field:
          title: Field
          minLength: 1
          type: string
      required:
      - name
      - field
    VariationsMapSimpleAggregation:
      title: VariationsMapSimpleAggregation
      type: object
      properties:
        aggregation:
          title: Aggregation
          enum:
          - first
          - all
          - distinct
          - min
          - max
          - field_count
          type: string
        field:
          title: Field
          minLength: 1
          type: string
      required:
      - aggregation
      - field
    VariationsMapCountAggregation:
      title: VariationsMapCountAggregation
      type: object
      properties:
        aggregation:
          title: Aggregation
          enum:
          - count
          type: string
      required:
      - aggregation
    VariationsMapValueCountAggregation:
      title: VariationsMapValueCountAggregation
      type: object
      properties:
        aggregation:
          title: Aggregation
          enum:
          - value_count
          type: string
        field:
          title: Field
          minLength: 1
          type: string
        value:
          title: Value
          anyOf:
          - type: boolean
          - type: integer
          - type: number
          - type: string
      required:
      - aggregation
      - field
      - value
    VariationsMap:
      title: VariationsMap
      type: object
      properties:
        filter_by:
          title: Filter By
          description: A filtering expression that should be used to filter variations before doing any aggregations
          allOf:
          - $ref: '#/components/schemas/VariationsMapFilterBy'
        group_by:
          title: Group By
          description: An array of fields that should be used to group variations. Variations which share the value of all fields specified here will all fall under one group
          minItems: 0
          maxItems: 5
          type: array
          items:
            $ref: '#/components/schemas/VariationsMapGrouping'
        values:
          title: Values
          description: A set of aggregations that should be applied to each variation group. The object keys specify the name of the field under which each aggregated value will be returned in the response
          type: object
          additionalProperties:
            discriminator:
              propertyName: aggregation
              mapping:
                first: '#/components/schemas/VariationsMapSimpleAggregation'
                all: '#/components/schemas/VariationsMapSimpleAggregation'
                distinct: '#/components/schemas/VariationsMapSimpleAggregation'
                min: '#/components/schemas/VariationsMapSimpleAggregation'
                max: '#/components/schemas/VariationsMapSimpleAggregation'
                field_count: '#/components/schemas/VariationsMapSimpleAggregation'
                count: '#/components/schemas/VariationsMapCountAggregation'
                value_count: '#/components/schemas/VariationsMapValueCountAggregation'
            oneOf:
            - $ref: '#/components/schemas/VariationsMapSimpleAggregation'
            - $ref: '#/components/schemas/VariationsMapCountAggregation'
            - $ref: '#/components/schemas/VariationsMapValueCountAggregation'
        dtype:
          title: Dtype
          description: The expected data type of the variations_map objects in the response
          enum:
          - array
          - object
          type: string
      required:
      - values
      - dtype
    VariationsReturnType:
      title: VariationsReturnType
      enum:
      - default
      - all
      - matched
      type: string
    FacetOptionSortOrder:
      title: FacetOptionSortOrder
      enum:
      - relevance
      - value
      - num_matches
      type: string
    SortOrderType:
      enum:
      - ascending
      - descending
      title: SortOrderType
      type: string
    FmtOptions:
      title: FmtOptions
      type: object
      properties:
        fields:
          title: Fields
          description: A list of specific item fields to return in the response. Allows the request to control which fields are returned.
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 300
            examples:
            - image_url
            - price
            - brand
          maxItems: 20
        show_hidden_fields:
          title: Show Hidden Fields
          description: A flag to return all `hidden` fields in the response.
          default: false
          examples:
          - false
          - true
          type: boolean
        hidden_fields:
          title: Hidden Fields
          description: A list of specific hidden fields to return in the response. Unlike `show_hidden_fields` this parameter allows the request to control which `hidden` fields are returned.  Used to return item fields for a particular store or user segment.
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 300
            examples:
            - inventory_count
            - store_availability
          maxItems: 30
        variations_return_type:
          description: A flag to return `default`, `all`, or `matched` variations.
          examples:
          - default
          allOf:
          - $ref: '#/components/schemas/VariationsReturnType'
        groups_max_depth:
          title: Groups Max Depth
          description: The maximum depth of the group hierarchy in the response.
          default: 1
          examples:
          - 1
          - 3
          type: integer
        groups_start:
          title: Groups Start
          description: A flag to specify the start of the group hierarchy returned in the response. `current` returns groups starting from the currently selected one. `top` returns groups starting from the root category in the hierarchy. `group_id:{id}`, returns the whole tree starting from group with the provided ID.
          default: current
          examples:
          - current
          - top
          - group_id:jeans
          type: string
        groups_sort_by:
          description: A string indicating the option to sort results by. Sorting options are created from item fields and facets in the product catalog.
          examples:
          - relevance
          allOf:
          - $ref: '#/components/schemas/FacetOptionSortOrder'
        groups_sort_order:
          description: A flag to sort either `ascending` or `descending`.
          examples:
          - descending
          allOf:
          - $ref: '#/components/schemas/SortOrderType'
        show_hidden_facets:
          title: Show Hidden Facets
          description: A flag to return all facets configured as `hidden` in `response.facets`.
          default: false
          examples:
          - false
          - true
          type: boolean
        hidden_facets:
          title: Hidden Facets
          description: A list of specific hidden facets to return in the response. Unlike `show_hidden_facets` this parameter allows the request to control which hidden facets are returned.  Used to return facets for a particular store or user segment.
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
            examples:
            - store_id
            - region
          maxItems: 50
        show_hidden_facet_options:
          title: Show Hidden Facet Options
          description: A flag to return all `hidden` facets options in the response.
          examples:
          - true
          - false
          type: boolean
        show_protected_facets:
          title: Show Protected Facets
          description: A flag to return all `protected` facets in the response. Requires authentication.
          default: false
          examples:
          - false
          - true
          type: boolean
        facet_options:
          title: Facet Options
          description: A list of specific facet options per facet to return in the response. This parameter accepts up to 5 facets and works only with facets of type `multiple`. Invalid facet options will be ignored. Used to return facet options for a particular facet like store or user segment.
          examples:
          - color:
            - red
            - blue
            brand:
            - nike
            - adidas
          type: object
          additionalProperties:
            type: array
            items:
              type: string
              minLength: 1
              maxLength: 100
            maxItems: 15
        facet_groups_limit:
          title: Facet Groups Limit
          description: The maximum limit of the facet groups returned in the response.
          minimum: 0
          examples:
          - 10
          type: integer
        show_hidden_sort_options:
          title: Show Hidden Sort Options
          description: A flag to return all sort options configured as `hidden` in `response.sort_options`.
          examples:
          - true
          - false
          type: boolean
        hidden_sort_options:
          title: Hidden Sort Options
          description: A list of `sort_by` fields whose hidden sort options should be included in the response. Unlike `show_hidden_sort_options` this parameter allows you to specify exactly which hidden sort options are returned.
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
            examples:
            - price
            - rating
          maxItems: 25
      additionalProperties: false
    ErrorResponse:
      title: ErrorResponse
      type: object
      properties:
        message:
          type: string
          description: Human-readable error summary.
        errors:
          type: array
          description: List of individual errors.
          items:
            type: object
            properties:
              code:
                type: string
                description: Machine-readable error code.
              message:
                type: string
                description: Human-readable error description.
              source:
                type: string
                description: The parameter or field that caused the error.
            required:
            - code
            - message
        trace_id:
          type: string
          description: A server-generated identifier for tracing this request, useful for debugging and support.
      required:
      - message
    ImageSearchPostResponse:
      title: ImageSearchPostResponse
      type: object
      properties:
        request:
          title: Request
          description: The request arguments how they were interpreted by the API. This field is of arbitrary type, ie it doesn't have a guaranteed schema, and data from it shouldn't be used programmatically, it is for debugging purposes only.
          type: object
        result_id:
          title: Result ID
          description: A unique identifier for this search request, used for analytics and behavioral tracking.
          type: string
        response:
          allOf:
          - $ref: '#/components/schemas/BrowseItemsResponse'
          - type: object
            properties:
              browse_url:
                type: string
                description: The browse results URL.
      required:
      - request
      - response
      additionalProperties: false
    Segment:
      title: Segment
      description: A single detected segment with per-segment search results.
      type: object
      properties:
        id:
          type: integer
          description: Zero-based index of this segment in the detection list.
        x1:
          type: integer
          description: Left x coordinate of the bounding box.
        y1:
          type: integer
          description: Top y coordinate of the bounding box.
        x2:
          type: integer
          description: Right x coordinate of the bounding box.
        y2:
          type: integer
          description: Bottom y coordinate of the bounding box.
        class_id:
          type: integer
          description: Numeric class identifier from the segmentation model.
        class_name:
          type: string
          description: Human-readable class name (e.g. 'top', 'pants').
        confidence:
          type: number
          format: float
          description: Detection confidence score in the range [0.0, 1.0], where 1.0 is maximum confidence.
        centroid_x:
          type: integer
          description: X coordinate of the segment interior point.
        centroid_y:
          type: integer
          description: Y coordinate of the segment interior point.
        neighbours:
          type: array
          description: Nearest-neighbour search results for this segment.
          items:
            type: object
            properties:
              id:
                type: string
                description: Product ID.
              distance:
                type: number
                format: float
                description: Distance from the segment embedding to the product embedding.
              data:
                type: object
                description: Catalog data for this product from the Browse API. Same shape as response.results[].data.
            required:
            - id
            - distance
      required:
      - id
      - x1
      - y1
      - x2
      - y2
      - class_id
      - class_name
      - confidence
      - centroid_x
      - centroid_y
      - neighbours
      additionalProperties: false
    ImageSearchPostResponseV2:
      title: ImageSearchPostResponseV2
      type: object
      properties:
        request:
          title: Request
          description: The request arguments how they were interpreted by the API. This field is of arbitrary type, ie it doesn't have a guaranteed schema, and data from it shouldn't be used programmatically, it is for debugging purposes only.
          type: object
        result_id:
          title: Result ID
          description: A unique identifier for this search request, used for analytics and behavioral tracking.
          type: string
        response:
          allOf:
          - $ref: '#/components/schemas/BrowseItemsResponse'
          - type: object
            properties:
              browse_url:
                type: string
                description: The browse results URL.
        segmentation_used:
          type: boolean
          description: Whether segmentation was actually used to produce results. `false` when `use_segmentation` was not requested or when segmentation failed and the system fell back to whole-image search.
        whole_image_search_fallback:
          type: boolean
          description: Whether the service fell back to whole-image search after segmentation was requested but failed to produce usable results. Always `false` when `use_segmentation` was not requested.
        segments:
          type: array
          description: Per-segment search results. Present when `use_segmentation` is `true` and `return_segments` is `true`.
          items:
            $ref: '#/components/schemas/Segment'
      required:
      - request
      - response
      - segmentation_used
      - whole_image_search_fallback
      additionalProperties: false
    ResultSourceValue:
      additionalProperties: false
      properties:
        count:
          description: Number of results returned from their respective sources
          minimum: 0
          title: Count
          type: integer
      required:
      - count
      title: ResultSourceValue
      type: object
    ResultSources:
      additionalProperties: false
      properties:
        token_match:
          description: The summary of results that came from matching a keyword
          allOf:
          - $ref: '#/components/schemas/ResultSourceValue'
          title: Token Match
        embeddings_match:
          description: The summary of results that originated from cognitive embeddings
          allOf:
          - $ref: '#/components/schemas/ResultSourceValue'
          title: Embeddings Match
      required:
      - token_match
      - embeddings_match
      title: ResultSources
      type: object
    HierarchicalFacetOption:
      additionalProperties: false
      properties:
        display_name:
          description: The name of the facet option as it is displayed to end users. Note that in `filters` parameter you need to use not `display_name` but `name`.
          title: Display Name
          type: string
        status:
          description: '`selected` if this option is selected in the current search request, empty string otherwise.'
          enum:
          - selected
          - ''
          title: Status
          type: string
        value:
          description: 'The value that should be passed in `filters` to select this option: `filters[name]=value`'
          title: Value
          type: string
        count:
          description: Number of items in the current search that match this option.
          minimum: 0
          title: Count
          type: integer
        data:
          description: Object containing custom data associated with this facet option. An empty object (`{}`) if no data is currently associated with this option.
          title: Data
          type: object
        range:
          description: 'Array containing 2 values: the parsed `min` & `max` values that are represented by this facet option. The field exists only for options of a facet with type `range` or `single` if it is configured specially.'
          title: Range
          items:
            anyOf:
            - type: number
            - type: integer
            - enum:
              - -inf
              - +inf
              - inf
              type: string
          type: array
        options:
          description: An array of possible facet values matching this search. By default, facet options are sorted by relevance. The field exists only for options of a facet with type `hierarchical`.
          title: Options
          items:
            type: object
          type: array
      required:
      - display_name
      - status
      - value
      - count
      title: HierarchicalFacetOption
      type: object
    HierarchicalFacet:
      additionalProperties: false
      properties:
        type:
          title: Type
          type: string
          enum:
          - hierarchical
        name:
          description: The name of the facet. This should be passed in 

# --- truncated at 32 KB (52 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/constructorio/refs/heads/main/openapi/constructorio-image-search-openapi.yml