Ad

Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' With Python Shopify Module

- 1 answer

I am looking for a way to view the header information of my requests when calling the Shopify API.

The API documentation says:

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)

On a Shopify support page I found a thread asking this same question, and Shopify's response was:

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.

When exploring I have tried calls like the following:

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

Answer

Was able to access it via:

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

However, I also saw on another thread that there is also an API Key Global limit that should be accessible somewhere through: 'x-shopify-api-call-limit'

Ad
source: stackoverflow.com
Ad