Visual Search API

Integrate Visual Search Functionality with Unbxd Visual Search API

Overview

The Visual Search API allows you to seamlessly integrate with the Unbxd platform and effortlessly incorporate all functionalities related to visual search. It enables you to display search results for an image from the array of products that match the visual cues.

📘

Image Requirements And Best Practices

To ensure optimal performance and accurate results, follow these image guidelines:

  1. Recommended Limits File Size.
  • Ideal: ≤ 500 KB

  • Maximum recommended: ≤ 1 MB

  1. Resolution
  • Recommended: ≤ 1000px (longest side) (Avoid: Images larger than 2000px)
  1. Large images (like 3–4MB, 4000px+) may result in API timeouts Return 0 results. In this case, be routed to alternate processing pipelines like mimir.image_search.
  2. Supported formats include JPEG, PNG, TIFF, HEIC, and HEIF.

❗Recommended : Approach Resize images on the client side before uploading Maintain ≤1000px resolution on the longest side Compress images before Base64 encoding

You can use the JSON /XML response format and leverage various built-in features. All API requests must be made over HTTPS.

Sample Request: Method POST

{  
curl -X POST 
'https://search.unbxd.io/v2.0/sites/{site_key}/images' 
-H 'Authorization: API Key' 
-H 'Content-Type: application/json'
}

Sample Request: Method GET

{  
curl -X GET "https://search.unbxd.io/v2.0/sites/(site_key)/images?imageUrl=https://some.site/images/image.png" 
-H "Authorization: API Key"
}

Authentication

Log in to Netcore Unbxd console and naviagte to Configure Site > Keys.

Authentication is done using API Keys and Sitekeys, which are generated during the account creation process.

Uploading Images

Upload Using Public Image URL.

Sample Request: Method POST

curl --location '/v2.0/sites/{site_key}/images' 
--header 'Content-Type: application/json' 
--header 'Authorization: API Key' 
--data '{ "imageUrl": "http://example.com/img/1.jpg" }'

Sample Request: Method GET

curl --location 'v2/sites/(site_key)/images?imageUrl=http%3A%2F%2Fexample.com%2Fimages%2F1.jpg' \\\
\--header 'Authorization: API Key'

Image Uploaded as Multipart/ Form-data

curl --location '/v2.0/sites/(site_key)/images' \\\
\--header 'Authorization: API Key' \
\--form 'image=@"./scripts/test/test.png"'

Upload Image by Sending Base64 Encoding

curl --location '/v2.0/sites/(site_key)/images' \\\
\--header 'Content-Type: image/png;base64' \
\--header 'Authorization: API Key' \
\--data 'iVBORw0KGgoAAAANSUhEUgAAAq4AAAIdCAYAAAD8of/......'
📘

Note

Ensure (site_key) is replaced with your actual site key, and API Key with the API key you are using for authorisation.

Here is how an Image to Base64 Encoder splits out data

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QC2.....TP/9k=

Read this data as:

 data:<mime-type>,<raw-image-data>
  </raw-image-data></mime-type>

When using this API, emit the mime-type within the content-type header as shown above, along with raw-image-data within the body.

Here are the supported mime types:

  • image/jpeg;base64
  • image/png;base64
  • image/tiff;base64
  • image/heic
  • image/heif

Headers

The following parameters are available:

ParameterDescription
unbxd-user-idThe Unbxd Analytics JavaScript sets a unique identifier in your browser’s cookie referred to as the user ID. Example: uid-1466015353887-20419.
user-agentIn each HTTPS request, the user-agent identification information is passed to the web server.
unbxd-device-typeA custom Unbxd header that identifies if the request originated from an app.
X-Forwarded-ForIn this header, the IP address of the end user is identified. Crucial for backend integrations, since Unbxd cannot get the IP directly from the browser.
Content-TypeThis header signifies the content type of the request being sent. Supported types include application/json, image/*, base64image/* (JPG/JPEG, PNG, TIFF).

unbxd-device-type

{ "type":"tablet" , "os": "iOS" , "source": "app" }

  • Possible values of “type” : “desktop”, “tablet”, “mobile”
  • Possible values of “os” : “android”, “ios”, “windows”
  • Possible values of “source” : “browser”, “app”`
  • Supported Image Types (Refer the table below)
FormatMIME Type
PNGimage/png
JPEG/JPGimage/jpg
TIFFimage/tiff
HEICimage/heic
HEIFimage/heif

Request Parameters

The values of the request parameters are defined below:

ParameterDescriptionData TypePossible Values / Format
versionSpecifies the API version. Always pass v2 to access the latest features.StringSupported: v2
user-typeIndicates the visit frequency of the user.String
  • Format: `"first-time"
  • Values: first-time, Repeat
uidUnique ID to identify visitors. Obtained from unbxd.userId cookie.StringFormat: &uid=uid-1666356549013-78531
formatSpecifies response format.StringFormat: &format=xml<br>Values: JSON, XML<br>Default: JSON
startOffsets the results by a specific number.IntegerFormat: &start=2<br>Default: 0
pageDisplays the right set of products per page (rows determines how many).IntegerFormat: &page=2
rowsPaginates query results OR sets number of buckets when used with bucketing.IntegerFormat: &rows=2<br>Default: 10
variantsDisplays variants of the same product.BooleanFormat: &variants=True<br>Values: True, False<br>Default: False
variants.countNumber of defined variants to show for a product.IntegerFormat: &variants.count=5
fieldsDefines which product attributes to return (e.g., color, size).StringFormat: &fields=color,size<br>Default: returns all fields
bucket.fieldGroups products by a common field value into buckets.StringFormat: &bucket.field=brand
bucket.limitNumber of products to show in each bucket.IntegerFormat: &bucket.limit=10<br>Default: 10
bucket.offsetPaginates to the next set of products within a bucket.IntegerFormat: &bucket.offset=10
analyticsEnables or disables tracking for analytics.StringDefault: Tracking is enabled
statsReturns product info with highest and lowest field values (numerical fields only).Format: fieldName (e.g., price, rating)

API Response

"searchMeta"
...
"queryParams": { ... },
"image": {
"id": "ad85491c-9d2b-4cab-900a-df96aa11f0d9",
"boxes": [{
"id": 1089,
"vertices": [{
"x": 164.07107543945312,
"y": 352.81292724609375
},
{
"x": 188.38121032714844,
"y": 384.0833435058594
}
],
"url": "/v2.0/sites//images/ad85491c-9d2b-4cab-900a-df96aa11f0d9/boxes/1089"
}{
"id": 811,
"vertices": [{
"x": 147.3377685546875,
"y": 68.75267028808594
},
{
"x": 255.28317260742188,
"y": 340.2548522949219
}]
"url": "/v2.0/sites//images/ad85491c-9d2b-4cab-900a-df96aa11f0d9/boxes/811"
},
...
...
],
"selected": 1089
},
...

A search API response comprises of

  • searchMetaData
  • response
  • And some other high level fields of the response.

The above JSON gets added in searchMetaData block, besides queryParams.

📘

Note

The dd.tag field is an internal Datadog logging tag used for monitoring and observability. It does not affect request routing or search results.

All image search requests are handled by the mimir pipeline, which orchestrates calls to downstream AI services. f an image doesn't meet these requirements, the API returns a specific error code. See Error Handling for details.

Response Components

Unbxd returns the list of products that match the search criteria. The response would be in application/JSON or application/XML content type format.

ComponentDescription
ID"id": "ad85491c-9d2b-4cab-900a-df96aa11f0d9" – A unique UUID assigned to each uploaded image.
BoxesAn array of bounding boxes for the image. Each box contains a URL (boxes: [{ box.url }]) which can be used to retrieve results specific to that region.
Selected (Box)Stores the ID of the selected bounding box that the user has clicked or interacted with.
StatusHTTP response status code (e.g., 200 for OK, 404 for Not Found, 500 for Server Error).
QueryTimeTime taken by the system to process the shopper’s request.
QueryParamsParameters that were sent as part of the image search request.
NumberOfProductsTotal number of products returned in the response.
StartOffset value in the result set — determines from which point products are returned.
ProductsContains the product details that match the request; structure mirrors the product feed schema.
RelevantDocumentIndicates whether to display the parent or variant product in the UI. Values can be: "parent" or "variant".
FacetsRefers to filters shown in the UI that help users narrow down the product list based on specific fields (e.g., brand, price, color).
BreadcrumbRepresents the hierarchical position of a field (e.g., Category → Subcategory → Product).
Selected (Filter)Represents currently selected filters by the user in the UI.

Error Handling

Visual Search validates the uploaded image before processing it. If the image cannot be processed, the API returns a specific error code that identifies the reason for the failure.

Use the error code from the API response to identify the issue and display an appropriate message to the user.

Error codes

The following error codes are returned when an image cannot be processed:

Error codeErrorDescription
4101IMAGE_DOWNLOAD_FAILEDThe system could not download or access the uploaded image.
4102IMAGE_SIZE_EXCEEDEDThe image file size exceeds the maximum allowed size of 8 MB.
4103UNSUPPORTED_FORMATThe uploaded image is in an unsupported format.
4104IMAGE_TOO_SMALLThe image dimensions are smaller than the minimum supported dimensions of 224 × 224 pixels.
4105POOR_IMAGE_QUALITYThe image quality is insufficient for Visual Search processing. This can occur when the image is too blurry, dark, or cluttered.

Error code details

4101: IMAGE_DOWNLOAD_FAILED

This error occurs when Visual Search cannot download or access the image provided in the request.

Possible causes:

  • The image URL is invalid.
  • The image is no longer available.
  • The image cannot be accessed by the Visual Search service.
  • The image server returns an error while attempting to download the image.

What to do: Verify that the image URL is valid and publicly accessible, then retry the request.

4102: IMAGE_SIZE_EXCEEDED

This error occurs when the uploaded image exceeds the maximum supported file size of 8 MB.

What to do: Reduce the image file size to 8 MB or less and retry the request.

Tip: Compress or resize the image before sending it to Visual Search to avoid exceeding the file-size limit.

4103: UNSUPPORTED_FORMAT

This error occurs when the uploaded image is in a format that Visual Search does not support.

For example, formats such as GIF, BMP, and WebP are not supported.

What to do: Convert the image to a supported image format and retry the request.

For the complete list of supported image formats, see Image Requirements.

4104: IMAGE_TOO_SMALL

This error occurs when the image dimensions are smaller than the minimum supported size of 224 × 224 pixels.

What to do: Upload an image with dimensions of at least 224 × 224 pixels and retry the request.

Note: Increasing the image dimensions does not necessarily improve search accuracy. For best results, use a clear image with sufficient resolution.

4105: POOR_IMAGE_QUALITY

This error occurs when the image quality is insufficient for Visual Search to identify the visual characteristics of the image.

This can happen when the image is:

  • Too blurry
  • Too dark
  • Too cluttered
  • Otherwise unclear for visual processing

What to do: Upload a clearer image with better lighting and a well-defined subject, then retry the request.

Handling Errors in Your Application

When the API returns an error, use the error code to determine the appropriate action or message to display to the user. For example:

Error codeSuggested user message
4101We couldn't access the image. Please try again with a valid image.
4102The image is too large. Please upload an image smaller than 8 MB.
4103This image format isn't supported. Please upload a supported image.
4104The image is too small. Please upload an image of at least 224 × 224 pixels.
4105We couldn't process this image. Please upload a clearer image.

Note: These error codes help you identify why an image could not be processed and provide meaningful feedback to users.

Image requirements

To minimize image-processing errors, make sure the image meets the Visual Search requirements before sending the request.

RequirementSupported value
Maximum file size8 MB
Minimum dimensions224 × 224 pixels
Image qualityClear, well-lit, and minimally cluttered
Image formatSupported image formats

If an image does not meet these requirements, the API returns the corresponding error code.

Switch Between Detected Products

Multi-Object Detection: Switching Between Detected Products

When an uploaded image contains multiple distinct items, a rug and a sofa in a room photo, or a shirt and jeans in an outfit photo, the API detects each item as its own box in the boxes array. There are three ways to handle this on the frontend:

  • Keep default behavior: The system automatically returns results for the box with the largest area. No extra integration work needed.

  • Let users switch between auto-detected boxes: Surface the detected boxes in the UI so a user can toggle between, e.g., rug results and sofa results, or shirt results and jeans results.

1..Initial Upload

Use any of the upload methods:

  • Via imageUrl

  • Via Base64

  • Via multipart form-data

2..Read the Detected Boxes from the Response

From the response's image block, pull out:

FieldUse
idThe image-id — needed for every subsequent boxes-endpoint call
boxes[].idThe box-id for each detected product
boxes[].verticesThe bounding-box coordinates for that product — use these to draw/highlight the region on the image in the UI (e.g., outline the shirt vs. the jeans on the photo itself)
selectedThe box-id currently active by default

Render one thumbnail/toggle per entry in boxes[], using vertices to crop or outline each region in the preview image.

3..Fetch Results for a Specific Box

Use the image-id and a box-id together:

curl --location --request GET 'https://search.unbxd.io/v2.0/sites/{site_key}/images/{image-id}/boxes/{box-id}' \
  --header 'Authorization: {api_key}' \
  --header 'Content-Type: application/json'

On user toggle, re-call this same endpoint with the newly chosen boxId (same image-id) - no re-upload needed.

Pagination

The boxes endpoint supports the same pagination parameters as the main search API (page, start, rows). Append them the same way, on top of whichever box-id is currently selected:

curl --location --request GET 'https://search.unbxd.io/v2.0/sites/{site_key}/images/{image-id}/boxes/{box-id}?page=2' \
  --header 'Authorization: {api_key}' \
  --header 'Content-Type: application/json'

Paginating does not change the selected box - it only pages through that box's own result set. Switching boxes and paginating are independent actions against the same endpoint.


Did this page help you?