5

I'm not sure if this is the place to ask, but the Etsy developer support is stupidly slow to reply (been waiting 4 days, and that was just to see if I could go ahead with the project - as I didn't want to break their TOS). Anyway, that aside...

I have a script I'm going to offer to our users, that would call the following feed: (using the details here: https://www.etsy.com/developers/documentation/getting_started/requests )

https://openapi.etsy.com/v2/shops/%s/listings/active?method=GET&api_key=$etsy_key&limit=200

That would then get the items they have for sale on their shop. So far, so good. One slight problem... there are no images!!! Now, based on their documentation (https://www.etsy.com/developers/documentation/getting_started/images) it says that you have to do a single request for EVERY item!

https://openapi.etsy.com/v2/listings/ITEM_ID/images/?api_key=xxxx

Surely that can't be right? So we have to do:

  • 1 api key request to get the feed
  • 200 x api requests to get the image urls

There has to be a better way, surely?

I'm all ears to suggestions, as this is driving me nuts.

Andrew Newby
  • 4,941
  • 6
  • 40
  • 81

4 Answers4

8

According to the etsy forums, you should be able to get the images by adding "includes=MainImage" to the end of your call.

thesasha
  • 81
  • 4
  • Thanks - that only seems to get part of the info though: `"url_75x75":"https:\/\/img1.etsystatic.com\/030\/0\/8478804\/il_75x75.573032795_fn12.jpg","url_170x135":"https:\/\/img1.etsystatic.com\/030\/0\/8478804\/il_170x135.573032795_fn12.jpg","url_570xN":"https:\/\/img1.etsystatic.com\/030\/0\/8478804\/il_570xN.573032795_fn12.jpg","url_fullxfull":"https:\/\/img1.etsystatic.com\/030\/0\/8478804\/il_fullxfull.573032795_fn12.jpg","full_height":null,"full_width":null}` ... doesn't include any of the other images we need. – Andrew Newby Nov 05 '15 at 12:14
  • How do you know this? Can you share the link? – AK-35 Jul 07 '21 at 21:06
3

If you're using (or can use) jQuery, then I'd recommend looping through each listing and displaying them via AJAX. The JSON data that gets returned from an API call looks something like this:

Etsy Data

This is all one big JSON object that includes specific data for each listing, including the image/dimensions, so you need to grab each one individually (see results array).

One way you can do this is with a for loop inside the success callback. You'd then assign variables for each value you want (using dot notation to parse though the JSON) and then build out your HTML using those variables.

$(document).ready(function () {
    // global variables
    var url = 'https://openapi.etsy.com/v2/listings/active.js?includes=MainImage',
        key = '9njigunpqge5htjynd9uu52f',
        limit = 25; // etsy api maximum

    // get data
    $.ajax({
        url: url,
        data: {
            api_key: key,
            limit: limit,
        },
        dataType: 'jsonp',
        success: function (data) {
            // log etsy data
            console.log(data);

            // for each listing... *
            for (var i = 0; i < data.results.length; i++) {
                // * assign listing variables
                var item = data.results[i];
                var url = item.url;
                var image = item.MainImage.url_570xN; // 75x75, 170x135, 570xN, fullxfull
                var title = item.title;
                var price = item.price;
                var quantity = item.quantity;

                // * build html structure for each listing
                var result = $('<div class="item">\
                    <div class="item-image">\
                        <a href="' + url + '"><img src="' + image + '"/></a>\
                    </div>\
                    <div class="item-details">\
                        <p class="item-title">' + title + '</p>\
                        <p class="item-price">$' + price + '</p>\
                        <p class="item-quantity">' + quantity + ' left</p>\
                    </div>\
                </div>');

                // * append listings
                $('#some-element').append(result);
            }
        }
    });
});

The available image sizes from the API are outlined here: https://www.etsy.com/developers/documentation/reference/listingimage.

I recently created a more fully featured Etsy Shop with pagination at http://codepen.io/markhillard/pen/mErRPk if you want to take a look.

Hope this helps.

Mark Hillard
  • 202
  • 3
  • 9
  • Thanks for the reply. Unfortunately this needed to be done in a backend Perl script (not AJAX). I ended up doing it using the API request for each item. Not ideal, but we have not hit any limit blocks yet - so hoping it'll work for the future as well :) – Andrew Newby Jul 11 '16 at 06:05
  • 1
    No problem Andrew. I don't know Perl so I can't help you there, but I hope it continues to work for you. – Mark Hillard Jul 11 '16 at 16:55
2

This is the correct answer.

According to the etsy api documentation, you should be able to get the images by adding "includes=Images" to the end of your call.

This will return the listings with all of their images.

helloJello
  • 196
  • 2
  • 9
0

For getting the Item details you can use -- getListing method of the ETSY API and getInventory call for getting variations and other details.

For getting the Images for an item use --- findAllListingImages call of the ETSY API

CedCommerce
  • 1
  • 4
  • 11