获得所有上市图片来自Etsy的一个商店 [英] Getting all listing images from an Etsy shop

查看:132
本文介绍了获得所有上市图片来自Etsy的一个商店的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

局势

我已经工装各地的Etsy的沙盒API中试图找出谁想要显示的默认图像和标题给他们所有的上市Etsy的客户端的解决方案。点击后,他们希望直接它们关闭网站,并到该埃斯蒂房源的页面。

现在,搞清楚如何让自己的所有目录的名称和网址很容易,并且可以在一个公共API调用来完成:


  

http://openapi.etsy.com/v2/shops/:shop_id/listings/active?method=GET&api_key=:api_key


这调用不会只返回列表的名称和上市的网址,也对特定项目的其它信息,众说纷纭。我想我应该限制我的电话刚开我需要的字段,但了一个例子,我离题...

什么最让我惊讶的是,在什么样的信息巨大的数组中不包括的东西我希望找到在那里:上市或至少主图像相关的图像。然而,有一个单独的API调用,我可以得到图像为单个上市,但这需要得到listing_id,使一个单独的API调用每一个项目。现在这变成了我所期望的是一个(或地狱,甚至二)调用的API Etsy的,到1加然而,许多项目,你回来。当然,如果你有100个项目你在店里卖,这是在短短的几秒钟101 API调用!叫我疯了,但我觉得我们有了一个更好的办法做到这一点比我已经找到。

问题

什么是做一个Etsy的API调用返回的所有房源全部图像(甚至主图像)在一家商店的最简单的方法?


解决方案

我最终使用以下code,包括我需要到一个API调用的一切:

<$p$p><$c$c>http://openapi.etsy.com/v2/shops/:shop_id/listings/active?method=GET&api_key=:api_key&fields=title,url&limit=100&includes=MainImage

这样,我定义我的领域,所以我没有不必要的信息,但我也设置结果的限制,使用 =包含MainImage 作为查询字符串。 这是对Etsy的开发者社区的一员的建议。

THE SITUATION

I've been tooling around in the Etsy sandbox API trying to figure out a solution for a client who wants to show the default image and title to all their Etsy listings. Upon clicking, they want it to direct them off the website and onto that Esty listing's page.

Now, figuring out how to get the name and url of all their listings was easy and can be done in one public API call:

http://openapi.etsy.com/v2/shops/:shop_id/listings/active?method=GET&api_key=:api_key

This call will not only return the name of the listing and the url of listing, but also a multitude of other information on that particular item. I suppose I should limit my call to just getting the fields I need, but for sake of example, I digress...

What surprises me most is that what is not included in that gigantic array of information is something I'd expect to find in there: the images associated with the listing or at least the main image. There is however a separate API call I can make to get the images for a single listing, but that would require getting the listing_id and making a separate API call for each item. This now turns what I would expect to be one (or hell, even two) calls to the Etsy API, into 1 plus however many items you return. Granted if you have 100 items you're selling in a shop, that's 101 API calls in just a few seconds! Call me crazy, but I feel there's got to be a better way to do this than what I've found.

THE QUESTION

What is the easiest way to make an Etsy API call to return all the images (or even the main image) for all the listings in a shop?

解决方案

I ended up using the following code to include everything I needed into one API call:

http://openapi.etsy.com/v2/shops/:shop_id/listings/active?method=GET&api_key=:api_key&fields=title,url&limit=100&includes=MainImage

This way I defined my fields so I don't have unnecessary information, but I also set a limit on the results and used includes=MainImage as a query string. This was to the suggestion of a member of the Etsy developer community.

这篇关于获得所有上市图片来自Etsy的一个商店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆