Skip to content
Juan Manuel García edited this page Dec 24, 2013 · 1 revision

Main goal

This service is mainly a wrapper for the shopify python client. All the methods are delegated to this library if they are not defined. This is known as Proxy pattern. So you will be able to call all the methods and use all the properties the shopify library defines via this class.

The constructor method initializes the class with the authentication keys for your shopify private app. In order to get those keys you MUST define the following constants in the settings.py file:

SHOPIFY_API_KEY = "Your shopify API key"
SHOPIFY_API_SECRET = "Your shopify API secret"
SHOPIFY_API_PASSWORD = "Your shopify API password"
SHOPIFY_HOST = "Your shopify store main domain (*.myshopify.com)"

To get this keys you have to create a private app on your shopify store. For instance going to https://django-shopify-core-app-test.myshopify.com/admin/apps/private and clicking "generate new private app".

Usage Example

settings.py

SHOPIFY_API_KEY = "f0513742b6f36ce70fe47558dfdde6e1"
SHOPIFY_API_SECRET = "8860c190fda33fe3236cac43bb63c780"
SHOPIFY_API_PASSWORD = "eb8a666732076c0d89372197917f9a92"
SHOPIFY_HOST = "django-shopify-core-app-test.myshopify.com"

my_file.py

from shopify_app.services import ShopifyService

#get all the customers
customers = ShopifyService().Customer.find()

for customer in customers:
    print customer.attributes["first_name"]

Further documentation

There is not much doc for the python client that shopify provides but you can read the basics here, play with the console and inspect the code to get an idea of how it works and how to use it.