JavaScript SDK

Search
Response
Search

Sending search requests

To use the SDK the awAddGift.js script has to be present and initialized. When the script is run the ADDWISH_PARTNER_NS variable is available on window. At this point you can call a method ADDWISH_PARTNER_NS.search.search(). That method takes three parameters:

Parameter #

Type

Description

#1

required

String

The key of the search config.

#2

required

String

The search word or phrase.

#3

optional

JSON

A JSON object with options that are sent with the search request. A little farther below you can see details about which options are available.

Options available

Field

Type

Description

format

String

A string value of either two options: "json" or "html".

filters

String[]

Limit product results to those matching the specified filter(s). By default, you can filter by price, inStock, hierarchies (categories), isOnSale, brand & created.

If you want to filter by other product attributes, then just contact support.

For more information about filters see documentation below.

return_filters

boolean

If set to true it will return all filter value results that you requested in options.filters.

Default is: false

product_fields

String

(Only works if options.format is "json") A comma separated list of what fields you would like to have returned in the response.

Defaults is: all fields.

engine_options.product.start

integer

This is used for pagination, and is the offset.

Default is: 0

engine_options.product.current_count

integer

The number of product results you want to have returned. Default is: 10

engine_options.category.start

integer

This is used for pagination, and is the offset.

Default is: 0

engine_options.category.current_count

integer

The number of category results you want to have returned. Default is: 0

engine_options.site_page.start

integer

This is used for pagination, and is the offset.

Default is: 0

engine_options.site_page.current_count

integer

The number of site page results you want to have returned. Default is: 0

engine_options.blog_post.start

integer

This is used for pagination, and is the offset.

Default is: 0

engine_options.blog_post.current_count

integer

The number of blog post results you want to have returned. Default is: 0

engine_options.brand.start

integer

This is used for pagination, and is the offset.

Default is: 0

engine_options.brand.current_count

integer

The number of brand results you want to have returned. Default is: 0

Example

var options = {
callback: function(products) {
console.log(products);
},
format: "json",
return_filters: true,
filters:["hierarchies:shoes$female$running-shoes$"],
engine_options: {
product: {
current_count: 10,
start: 0
},
category: {
current_count: 4,
start: 0
},
site_page: {
current_count: 2,
start: 0
},
blog_post: {
current_count: 1,
start: 0
},
brand: {
current_count: 2,
start: 0
}
}
};
ADDWISH_PARTNER_NS.search.search(
"1a41bcd8-bdff-4b4c-a6cf-59bc61d90371", // the search config key
"Red running shoes", // the search phrase
options
);
Response

{
"results": 33,
"start": 0,
"didTrackSearch": true,
"results": [
{
"title": "A specific shoe",
"imgUrl": "http://example.com/shoe/shoe_img.png",
"price": 100.0,
"currency": "DKK",
"url": "http://example.com/shoe/specificOne",
"priceFormatted": "100,00",
"description": "A shoe that is good for running",
"keywords": "shoes, running",
"inStock": true,
"extraData": {
"itemNumber": "0001"
},
"productNumber": "21"
},
...
...
],
categories: [
{
"title": "Running shoes",
"description": "Our collection of running shoes",
"url": "http://example.com/shoes/running/female",
"keywords": "shoes, running, female",
"hierarchy": [
"shoes",
"running",
"female"
]
],
brands: [
{
"title": "Rus",
"description": "Rus, professional shoes for running",
"url": "http://example.com/rus",
"keywords": "rus, shoes, running",
"hierarchy": [
"rus"
]
]
}

You can read about filters here.

You can find the response values here.