使用 Python Shopify 模块访问 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT'

Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module

我正在寻找一种在调用 Shopify API 时查看请求的 header 信息的方法 API。

API 文档说:

You can check how many calls you've already made using the Shopify header that was sent in response to your API call: HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT (lists how many calls you've made for that particular shop)

在 Shopify 支持页面上,我发现了一个线程问同样的问题,Shopify 的回复是:

If (you are using) the python adapter then you probably need to use the get_headers method. I'm not sure, I don't use this library.

探索时,我尝试过如下调用:

shopify.ShopifyResource.get_headers().get('HTTP_X_SHOPIFY_API_CALL_LIMIT')
>>None

能够通过以下方式访问它:

resp_header = shopify.ShopifyResource.connection.response.headers["X-Shopify-Shop-Api-Call-Limit"]

但是,我还在另一个线程上看到还有一个 API 关键全局限制,应该可以通过以下方式访问:'x-shopify-api-call-limit'