Open API v2 will be deprecated on April 3, 2023. Please begin transitioning to Open API v3 as soon as possible. As of September 29, 2022 all new apps will only be permitted to use Open API v3.
jQuery Search App
This application uses jQuery and the Etsy API to display simple search results.
<html> <head> <title>Etsy jQuery Demo</title> <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript"> (function($){ $(document).ready(function(){ $('#etsy-search').bind('submit', function() { api_key = "your_api_key"; terms = $('#etsy-terms').val(); etsyURL = "https://openapi.etsy.com/v2/listings/active.js?keywords="+ terms+"&limit=12&includes=Images:1&api_key="+api_key; $('#etsy-images').empty(); $('<p></p>').text('Searching for '+terms).appendTo('#etsy-images'); $.ajax({ url: etsyURL, dataType: 'jsonp', success: function(data) { if (data.ok) { $('#etsy-images').empty(); if (data.count > 0) { $.each(data.results, function(i,item) { $("<img/>").attr("src", item.Images[0].url_75x75).appendTo("#etsy-images").wrap( "<a href='" + item.url + "'></a>" ); if (i%4 == 3) { $('<br/>').appendTo('#etsy-images'); } }); } else { $('<p>No results.</p>').appendTo('#etsy-images'); } } else { $('#etsy-images').empty(); alert(data.error); } } }); return false; }) }); })(jQuery); </script> </head> <body> <form id="etsy-search"> <input id="etsy-terms" size="32"> <button>Search!</button> </form> <div id="etsy-images"></div> </body> </html>