Integrate Gunfinder on your own website
The Gunfinder widget lets website operators display Gunfinder search results on their own website. A good example is the Gunfinder integration on Geartester (at the very bottom of the page).
Below, we’ll briefly explain how to add the Gunfinder widget to your own website. The process basically consists of 2 steps: First, you add a JavaScript file. Then you can write a small amount of HTML code that the JavaScript file will recognize and process.
Including the JavaScript file
The following code snippet must be included in either the head or body of the HTML document:
<script src="https://widgets.gunfinder.de/js/search.js" async></script>
Adding the HTML snippet
Once the JavaScript file has been included, you can add a new DIV element with an attribute named data-gunfinder-search-widget so the JavaScript code can recognize it. Here's a simple example:
<div data-gunfinder-search-widget data-gunfinder-search-query="{Search query}"></div>
This starts a search on Gunfinder for {Search query} and displays the results on the page. data-gunfinder-search-query is the only required attribute. You can find other possible attributes in the table below. All attributes must have the prefix data-gunfinder-search-.
Attribute |
Description |
Possible values |
Required |
query |
Search query |
Text |
Yes |
count |
Maximum number of results. Integer. Default: 5 |
> 0 < 30 |
No |
price-min |
Minimum price. Integer. |
> 0 < price-max (if specified) |
No |
price-max |
Maximum price. Integer. |
> 0 > price-min (if specified) |
No |
condition |
Item condition |
new or used |
No |
available |
Available for immediate delivery. Default: false |
true or false |
No |
category |
Limit the search to a specific category |
weapon, ammunition, optics, apparel, equipment |
No |
style |
Styling. See description below. |
JSON object |
No |
sources |
Comma-separated list of source names to search. By default, all sources are searched. |
Please [email protected]">contact us |
No |
exclude-sources |
Comma-separated list of source names not to search. By default, all sources are searched. |
Please [email protected]">contact us |
No |
marketplace |
If true, only marketplace results are shown. If false, marketplace results are not shown. |
true or false |
No |
More examples:
<div data-gunfinder-search-widget data-gunfinder-search-query="{Suchanfrage}" data-gunfinder-search-price-min="2500"></div>
<div data-gunfinder-search-widget data-gunfinder-search-query="{Suchanfrage}" data-gunfinder-search-available="true"></div>
Styling
If you don't want to style the widget using CSS rules, you can pass a few simple variables to the widget as a JSON object to change its appearance.
Variable |
Description |
Possible values |
fontSize |
Base font size. Affects the entire widget. |
Standard CSS size values |
itemTitleColor |
Color of the listing title |
Standard CSS color values |
itemPriceColor |
Color of the listing price |
Standard CSS color values |
moreColor |
Text and border color of the "more listings" button |
Standard CSS color values |
Example:
<div data-gunfinder-search-widget data-gunfinder-search-query="{Search query}" data-gunfinder-search-style='{"fontSize": "15px", "itemTitleColor": "red"}'></div>