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);
    })();
</script>
<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 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.

Note

All parameters must be specified in the PriceFormat array.

Updated on October 4, 2022

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you

Let us improve this post!

Please tell us how we can improve this post

Related Articles

Back to top