Ad

Shopify Python API Request ISO 8601 Fomat

- 1 answer

The Shopify API reference says:

updated_at_min
Show products last updated after date (format: 2014-04-25T16:15:47-04:00)

If I have a datetime object when making an API call, do I need to convert the datetime to a string of ISO 8601 format prior to making the request?

i.e. do I need to do this?

min_date = timezone.now()
shopify.Product.count(created_at_min = str(min_data.isoformat()))

My request would look like this then:

https://[store-url].myshopify.com/admin/products/count.json?updated_at_min=2017-01-29T14%3A43%3A27-05%3A00

Versus this (if I pass the unformatted datetime object in):

https://[store-url].myshopify.com/admin/products/count.json?updated_at_min=2016-12-10+14%3A43%3A27-05%3A00

(If so, why doesn't the Shopify Python API handle this conversion automatically, seems kind of silly?)

Ad

Answer

(From a response to my issue on the Shopify Python repo): The Shopify API actually does accept several date formats, but it's always safest to use the format that is documented in the API documentation (ISO 8601), as this is guaranteed to continue working in the future.

The current Shopify Python module does not currently handle date formatting, because the bulk of the functionality of the library is for wrapping HTTP requests using pyactiveresource - it is largely a port of https://github.com/shopify/shopify_api and hasn't been extended to do this.

Ad
source: stackoverflow.com
Ad