Visual Search API

Integrate Visual Search Functionality with Unbxd Visual Search API

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.

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

Reque

{  
curl -X POST 
'https://search.unbxd.io/v2.0/sites/{site_key}/images' 
-H 'Authorization: API Key' 
-H 'Content-Type: application/json'
}
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
    Authentication is done using API Keys and Sitekeys, which are generated during the account creation process and can be found in the Console under Manage -> Configure Site -> Keys.
  • Uploading Images : Upload Using Public Image URL
    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" }'
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

Make sure you replace (site_key) with your actual site key, and API Key with the API key you’re using for authorisation.

Here is how an Image to Base64 Encoder splits out data

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

Here’s how to read this data

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 raw-image-data within the body.

Here are the supported mime types

image/jpeg;base64
image/png;base64
image/tiff;base64

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:
    PNG: image/png JPEG/JPG: image/jpg TIFF: image/tiff

Request Parameters

The values of the request parameters are defined below:

ParameterDescriptionData TypePossible Values / Format
versionSpecifies the API version. Always pass v2 to access latest features.StringSupported: v2
user-typeIndicates visit frequency of user.StringFormat: "first-time"<br>Values: first-time, frequent
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.

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.