4

Using the Etsy Listing API, i have listings returned that match a keyword and I can paginate through them no problems.

However, I want to find only listings that deliver to the UK.

I have tried to use the region URL parameter, but i still get items that can only be delivered to the USA.

Can someone help me to understand what I need to pass in order to get UK shippable items please?

Andrew Hall
  • 3,058
  • 21
  • 30
  • Seems to be working fine for me [here](https://openapi.etsy.com/v2/listings/active?region=GB&api_key=) *API KEY EXCLUDED* – owenvoke Feb 15 '16 at 10:32
  • @PXgamer whilst your URL does work, it doesnt seem to be limiting as expected. For example, try [link](https://openapi.etsy.com/v2/listings/active?keywords=ISBN&region=GB&api_key=) and some of the items (2nd at time of posting), `Only ships to United States from Alabama, United States.` – Andrew Hall Feb 15 '16 at 14:24

2 Answers2

2

If you want to use only listings that can ship to UK, you have to look at the listsing's ShippingInfo. Here's how I did it:

$json = file_get_contents("https://openapi.etsy.com/v2/listings/active?keywords=ISBN&region=GB&includes=ShippingInfo(destination_country_id)&api_key=");
$listings = json_decode($json, true);
foreach($listings['results'] as $listing) {
    if (isset($listing['ShippingInfo'])) {
        foreach ($listing['ShippingInfo'] as $shipping) {
            if ($shipping['destination_country_id'] == 105) {
                //this listing ships to UK
                print_r($listing);
            }       
        }

    }
}
pabl0rg
  • 171
  • 8
1

Here is the code to get listing that ships/deliver to "United Kingdom"

<?php
$apiContent = file_get_contents("https://openapi.etsy.com/v2/listings/active?api_key=YOUR-API-KEY-HERE&includes=ShippingInfo(destination_country_name)");
        $contentDecode = json_decode($apiContent, true);
        $total=0;
        foreach ($contentDecode['results'] as $row) {
            if (isset($row['ShippingInfo'])) {
                foreach ($row['ShippingInfo'] as $r) {
                    if ($r['destination_country_name'] == "United Kingdom") {
                        echo "<pre>";
                        print_r($row);
                        $total++;
                    }
                }
            }
        }
        echo $total;
?>

I used includes=ShippingInfo(destination_country_name) parameter to get the shipping details of the listing. It get the in which country listing will be delivered. Hope it will work for you.

Manoj Kumar
  • 477
  • 2
  • 8
  • 24