Shopify¶
Overview¶
Shopify is an e-commerce platform for online stores. This Parsons integration with the Shopify REST API supports fetching records of orders.
Note
- Authentication
Shopify supports different types of authentication methods for different types of apps, which are documented here.
Quickstart¶
To instantiate the Shopify class, you can either store your Shopify API subdomain, password, key, and version as environmental variables (SHOPIFY_SUBDOMAIN, SHOPIFY_PASSWORD, SHOPIFY_API_KEY, and SHOPIFY_API_VERSION, respectively) or pass in your subdomain, password, key, and version as arguments:
from parsons import Shopify
# First approach: Use API credentials via environmental variables
shopify = Shopify()
# Second approach: Pass API credentials as arguments
shopify = Shopify(subdomain='mysubdomain', password='1234', api_key='1234', api_version='2020-10')
You can then call various endpoints:
# Fetch orders
orders = shopify.get_orders()
API¶
- class parsons.Shopify(subdomain=None, password=None, api_key=None, api_version=None, access_token=None)[source]¶
Instantiate the Shopify class
- Parameters:
subdomain – str The Shopify subdomain (e.g.
myorgfor myorg.myshopify.com) Not required ifSHOPIFY_SUBDOMAINenv variable set.password – str The Shopify account password. Not required if
SHOPIFY_PASSWORDenv variable set.api_key – str The Shopify account API key. Not required if
SHOPIFY_API_KEYenv variable set.api_version – str The Shopify API version. Not required if
SHOPIFY_API_VERSIONenv variable set.access_token – str The Shopify access token. Not required if
SHOPIFY_ACCESS_TOKENenv variable set. If argument or env variable is set, password and api_key are ignored.
- Returns:
Shopify Class
- get_count(query_date=None, since_id=None, table_name=None)[source]¶
Get the count of rows in a table.
- Parameters:
query_date – str Filter query by a date that rows were created. This filter is ignored if value is None.
since_id – str Filter query by a minimum ID. This filter is ignored if value is None.
table_name – str The name of the Shopify table to query.
- Returns:
int
- get_orders(query_date=None, since_id=None, completed=True)[source]¶
Get Shopify orders.
- Parameters:
query_date – str Filter query by a date that rows were created. Format: yyyy-mm-dd. This filter is ignored if value is None.
since_id – str Filter query by a minimum ID. This filter is ignored if value is None.
completed – bool True if only getting completed orders, False otherwise.
- Returns:
parsons.Table
- get_query_url(query_date=None, since_id=None, table_name=None, count=True)[source]¶
Get the URL of a Shopify API request
- Parameters:
query_date – str Filter query by a date that rows were created. Format: yyyy-mm-dd. This filter is ignored if value is None.
since_id – str Filter query by a minimum ID. This filter is ignored if value is None.
table_name – str The name of the Shopify table to query.
count – bool True if refund should be included in Table, False otherwise.
- Returns:
str
- graphql(query)[source]¶
Make GraphQL request. Reference: https://shopify.dev/api/admin-graphql
- Parameters:
query – str GraphQL query.
- Returns:
dict
- classmethod load_to_table(subdomain=None, password=None, api_key=None, api_version=None, query_date=None, since_id=None, completed=True)[source]¶
Fast classmethod so you can get the data all at once.
tabledata = Shopify.load_to_table( subdomain='myorg', password='abc123', api_key='abc123', api_version='2020-10', query_date='2020-10-20', since_id='8414', completed=True )
This instantiates the class and makes the appropriate query type to Shopify’s orders table based on which arguments are supplied.
- Parameters:
subdomain – str The Shopify subdomain (e.g.
myorgfor myorg.myshopify.com).password – str The Shopify account password.
api_key – str The Shopify account API key.
api_version – str The Shopify API version.
query_date – str Filter query by a date that rows were created. Format: yyyy-mm-dd. This filter is ignored if value is None.
since_id – str Filter query by a minimum ID. This filter is ignored if value is None.
completed – bool True if only getting completed orders, False otherwise. value as value
- Returns:
parsons.Table