Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python (Django) Shopify API Client -- For a Beginner

I have a requirement to build a client for Shopify's API, building it in Python & Django.

I've never done it before and so I'm wondering if someone might advise on a good starting point for the kinds of patterns and techniques needed to get a job like this done.

Here's a link to the Shopify API reference

Thanks.

like image 533
Antonius Common Avatar asked Oct 21 '09 06:10

Antonius Common


3 Answers

Your question is somewhat open-ended, but if you're new to Python or API programming, then you should get a feel for how to do network programming in Python, using either the urllib2 or httplib modules that come with more recent versions of Python. Learn how to initiate a request for a page and read the response into a file.

Here is an overview of the httplib module in Python documentation:

http://docs.python.org/library/httplib.html

After you've managed to make page requests using the GET HTTP verb, learn about how to make POST requests and how to add headers, like Content-Type, to your request. When communicating with most APIs, you need to be able to send these.

The next step would be to get familiar with the XML standard and how XML documents are constructed. Then, play around with different XML libraries in Python. There are several, but I've always used xml.dom.minidom module. In order to talk to an API, you'll probably need to know to create XML documents (to include in your requests) and how to parse content out of them. (to make use of the API's responses) The minidom module allows a developer to do both of these. For your reference:

http://docs.python.org/library/xml.dom.minidom.html

Your final solution will likely put both of these together, where you create an XML document, submit it as content to the appropriate Shopify REST API URL, and then have your application deal with the XML response the API sends back to you.

If you're sending any sensitive data, be sure to use HTTPS over port 443, and NOT HTTP over port 80.

like image 108
Jim McGaw Avatar answered Sep 23 '22 19:09

Jim McGaw


I have been working on a project for the last few months using Python and Django integrating with Shopify, built on Google App Engine.

Shopify has a valuable wiki resource, http://wiki.shopify.com/Using_the_shopify_python_api. This is what I used to get a good handle of the Shopify Python API that was mentioned, https://github.com/Shopify/shopify_python_api.

It will really depend on what you are building, but these are good resources to get you started. Also, understanding the Shopify API will help when using the Python API for Shopify.

like image 30
zachhilbert Avatar answered Sep 22 '22 19:09

zachhilbert


Shopify has now released a Python API client: https://github.com/Shopify/shopify_python_api

like image 37
Alex Dean Avatar answered Sep 25 '22 19:09

Alex Dean