Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Pull request Compare This branch is 223 commits behind Shopify:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Shopify API

The ShopifyAPI library allows Python developers to programmatically access the admin section of stores.

The API is accessed using pyactiveresource in order to provide an interface similar to the ruby Shopify API gem. The data itself is sent as XML over HTTP to communicate with Shopify, which provides a web service that follows the REST principles as much as possible.



All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by other shop owners:

  • Shop owners can create applications for themselves through their own admin (under the Apps > Manage Apps).
  • Shopify Partners create applications through their admin:

For more information and detailed documentation about the API visit


To easily install or upgrade to the latest release, use pip

pip install --upgrade ShopifyAPI

or easy_install

easy_install -U ShopifyAPI

Getting Started

ShopifyAPI uses pyactiveresource to communicate with the REST web service. pyactiveresource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:

  1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET.

  2. You will need to supply two parameters to the Session class before you instantiate it:

    shopify.Session.setup(api_key=API_KEY, secret=SHARED_SECRET)
  3. For application to access a shop via the API, they first need a "access token" specific to the shop, which is obtained from Shopify after the owner has granted the application access to the shop. This can be done by redirecting the shop owner to a permission URL, obtained as follows:

    shop_url = ""
    scope = ["write_products", "read_orders"]
    permission_url = shopify.Session.create_permission_url(shop_url, scope)

    Note: Legacy Auth is assumed if the scope parameter is omitted or None

  4. After visiting this URL, the shop redirects the owner to a custom URL of your application where a code param gets sent to along with other parameters to ensure it was sent by Shopify. The following code will validate that the request came from Shopify, then obtain the permanent access token (with an HTTP request when using OAuth2) which can be used to make API requests for this shop.

    session = shopify.Session(shop_url, params)
  5. Activate the session to use the access token for following API requests for the shop it was authorized for.

  6. Start making authorized API requests for that shop. Data is returned as ActiveResource instances:

    # Get a list of products
    products = shopify.Product.find()
    # Get a specific product
    product = shopify.Product.find(632910)
    # Create a new product
    new_product = shopify.Product()
    new_product.title = "Burton Custom Freestlye 151"
    new_product.product_type = "Snowboard"
    new_product.vendor = "Burton"
    # Update a product
    product.handle = "burton-snowboard"

Saved Session

  1. Follow steps 1-4 from the "Getting Started" section to obtain a session, then save the session's token along with the shop_url.

    shop_url = session.url
    saved_token = session.token
  2. Create and activate a new session using the saved shop_url and token.

    session = shopify.Session(shop_url)
    session.token = saved_token


This package also includes the script to make it easy to open up an interactive console to use the API with a shop.

  1. Go to to generate a private application and obtain your API key and password to use with your shop.

  2. Use the script to save the credentials for the shop to quickly login. The script uses PyYAML to save and load connection configurations in the same format as the ruby shopify_api. add yourshopname

    Follow the prompts for the shop domain, API key and password.

  3. Start the console for the connection. console
  4. Enter the following for the full list of the commands. help

Using Development Version

Use the bin/ script when running from the source tree. It will add the lib directory to start of sys.path, so the installed version won't be used.

bin/ console

The development version can be built using

python sdist

then the package can be installed using pip

pip install --upgrade dist/ShopifyAPI-*.tar.gz

or easy_install

easy_install -U dist/ShopifyAPI-*.tar.gz


Currently there is no support for:

  • python 3
  • asynchronous requests
  • persistent connections
  • json format for API requests

Questions or Problems?


Copyright (c) 2012 "Shopify inc.". See LICENSE for details.

Something went wrong with that request. Please try again.