从 Etsy 商店获取所有列表图像 [英] Getting all listing images from an Etsy shop

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

问题描述

情况

我一直在 Etsy 沙盒 API 中使用工具,试图为想要显示所有 Etsy 列表的默认图像和标题的客户找出解决方案.点击后,他们希望它引导他们离开网站并进入 Esty 列表页面.

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.

现在,弄清楚如何获取所有列表的名称和 URL 很容易,只需一个公共 API 调用即可完成:

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

此调用不仅会返回列表名称和列表 url,还会返回有关该特定项目的大量其他信息.我想我应该将我的电话限制为仅获取我需要的字段,但为了举例,我离题了...

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...

最让我惊讶的是,没有包含在庞大信息数组中的内容是我希望在其中找到的内容:与列表相关的图像或至少主图像.然而,我可以进行单独的 API 调用来获取单个列表的图像,但这需要获取 listing_id 并为每个项目进行单独的 API 调用.这现在将我期望的对 Etsy API 的一次(或地狱,甚至两次)调用变成了 1 加上您返回的项目数量.如果您在商店中销售 100 件商品,那么只需几秒钟就可以调用 101 次 API!说我疯了,但我觉得必须有比我发现的更好的方法来做到这一点.

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.

问题

调用 Etsy API 以返回商店中所有商品的所有图片(甚至主图片)的最简单方法是什么?

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?

推荐答案

我最终使用以下代码将我需要的所有内容包含到一个 API 调用中:

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

这样我定义了我的字段,所以我没有不必要的信息,但我也对结果设置了限制,并使用 includes=MainImage 作为查询字符串.这是 Etsy 开发者社区成员的建议.

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天全站免登陆