Widgets JS API

To display the Instant Search Widget and Search Results Widget, add the JS code below.

An example of connection

<script type="text/javascript">
    Searchanise = {};
    Searchanise.host = 'https://searchserverapi.com';
    Searchanise.ApiKey = 'XXXXXXXXXX';
    Searchanise.SearchInput = '#search_input';

    Searchanise.AutoCmpParams = {};
    Searchanise.AutoCmpParams.restrictBy = {};
    Searchanise.AutoCmpParams.restrictBy.status = 'A';

    Searchanise.ResultsParams = {};
    Searchanise.ResultsParams.restrictBy = {};
    Searchanise.ResultsParams.restrictBy.status = 'A';

    Searchanise.options = {};
    Searchanise.options.ResultsDiv = '#snize_results';
    Searchanise.options.PriceFormat = {
        rate : 1.0,
        symbol: '$',
        decimals: 2,
        decimals_separator: '.',
        thousands_separator: ',', 
        after: false

    (function() {
        var __se = document.createElement('script');
        __se.src = 'https://searchserverapi.com/widgets/v1.0/init.js';
        __se.setAttribute('async', 'true');
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(__se, s);
<input type="text" id="search_input" name="q" value="">
<div id="snize_results"><div>

Connection parameters

Parameter Description Value type
ApiKey Required parameter, public API key string (api key)
SearchInput Required parameter, jQuery selector for search fields string (valid jQuery selector)
AutoCmpParams Object with parameters that will be used in a string for requesting results for the instant search widget, see Search API object
ResultsParams Object with parameters that will be used in a string for requesting results for the search results widget, see Search API object
options Object with parameters of the widget settings object
options.ResultsDiv jQuery selector for div for displaying results widget string (valid jQuery selector)
options.PriceFormat Object with parameters of formatting price display; used to display prices based on location. (See the list of parameters below.) object

Parameters for PriceFormat object

Parameter Description Value type
rate Currency exchange rate float
symbol Currency symbol string
decimals Number of symbols after the comma int
decimals_separator A symbol used to separate the integer part from the fractional part  string
thousands_separator Thousands separator symbol string
after Defines whether to show the currency symbol before or after bool

Support HTTP and HTTPS addresses.


All parameters must be specified in the PriceFormat array.

Updated on March 23, 2022

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support
Back to top