tags:

views:

246

answers:

3

Hello,

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.

A: 

I think you can find some inspiration by taking a look at this:

http://bitbucket.org/jespern/django-piston/wiki/Home

Although it is directly opposite what you want to do (Piston is for building APIs, and what you want is to use an API) it can give you some clues on common topics.

I could mention, of course, reading obvious sources like the Shopify developers forum:

http://forums.shopify.com/categories/9

But I guess you already had it in mind :)

Cheers,

H.

nabucosound
A: 

inspiration? see http://www.satchmoproject.com/

panchicore
A: 

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.

Jim McGaw