Tuesday, 31 January 2017

Extracting data from Shopify Part 1

"Once upon a time I was asked to provide assistance with extracting data from Shopify."

Background


Our customer company XYZ is based in US would like to use Advanced ETL Processor to connect to shopping platforms, such as Shopify, Big Commerce, Amazon and Volusion.

Solution


Although Advanced ETL Processor does no work directly with Shopify it does support python.
This opens wide range of opportunities. 

For example:


Here some python API for Amazon.



And here is Shopify Python API



Regardless what API we choose to use the process is always the same

  1. Connect to the server.
  2. Perform some action
  3. Return some data.

Installing Python.


Download and install python 2.7, 32 bit for 32 bit version or 64 bit for 64 bit version of Advanced ETL Processor.


 Once installed open command prompt and run the following command

python.exe pip install requests

Configuring Shopify

Create ShopiFy account at https://www.shopify.co.uk/. Login and select apps


Click Private apps



Click create private app


Note API Key and Password.

Extracting Data

The script is very simple, literally five lines of code:

import requests
response = requests.get( "https://SHOPNAME.myshopify.com/admin/orders.xml", auth=("KEY","PASSWORD"))
file = open("orders.xml", "w")
file.write(response.text)
file.close()

Data can be extracted as XML or JSON. Just replace file extension XML with JSON. 
Once data is saved on the local drive it can be loaded into the database

Extracting ShopiFy data using Advanced ETL Processor.

  1. Run Advanced ETL Processor
  2. Create new package
  3. Add Script action
  4. Set language used to Python.
  5. Copy and paste scrip from the above




Feedback from the customer

Your ETL tool is a mission critical piece of our business.  We integrate with dozens and dozens of clients. It helps us manipulate the files in/out and get them loaded into our Warehouse Management System.

Once data is extracted we need to load it into the Datawarehouse. We will discuss it in part two

No comments:

Post a Comment