Shopify

Tools to interact with Shopify.

ShopifyTools enable an Agent to analyze sales data, product performance, and customer insights using the Shopify Admin GraphQL API.

Prerequisites

The following example requires a Shopify Admin API access token with appropriate scopes.

Set the following environment variables:

  • SHOPIFY_SHOP_NAME: Your Shopify shop name (e.g., "my-store" from my-store.myshopify.com)
  • SHOPIFY_ACCESS_TOKEN: Your Shopify Admin API access token

You can get your access token from: Shopify Admin > Settings > Apps and sales channels > Develop apps

Required API scopes:

  • read_orders (for order and sales data)
  • read_products (for product information)
  • read_customers (for customer insights)
  • read_analytics (for analytics data)

Example

The following agent will analyze sales data and provide insights.

1from kern.agent import Agent
2from kern.models.openai import OpenAIResponses
3from kern.tools.shopify import ShopifyTools
4
5sales_agent = Agent(
6 name="Sales Analyst",
7 model=OpenAIResponses(id="gpt-5.2"),
8 tools=[ShopifyTools()],
9 instructions=[
10 "You are a sales analyst for an e-commerce store using Shopify.",
11 "Help the user understand their sales performance, product trends, and customer behavior.",
12 ],
13 markdown=True,
14 add_datetime_to_context=True, # This is important to get the current date and time in the context
15)
16
17sales_agent.print_response("What are my top 5 selling products this month?")

Toolkit Params

ParameterTypeDefaultDescription
shop_namestr-Your Shopify store name (e.g., "my-store" from my-store.myshopify.com). Or set via SHOPIFY_SHOP_NAME environment variable.
access_tokenstr-Shopify Admin API access token with required scopes. Or set via SHOPIFY_ACCESS_TOKEN environment variable.
api_versionstr"2025-10"Shopify API version.
timeoutint30Request timeout in seconds.

Toolkit Functions

FunctionDescription
get_shop_infoGet basic information about the Shopify store
get_productsGet products from the store with optional status filter
get_ordersGet orders with optional date range and status filters
get_top_selling_productsGet the top selling products by quantity sold
get_products_bought_togetherFind products that are frequently bought together for bundle recommendations
get_sales_by_date_rangeGet sales summary for a specific date range with daily breakdown
get_order_analyticsGet comprehensive order analytics including revenue, AOV, and fulfillment rates
get_product_sales_breakdownGet detailed sales breakdown for a specific product
get_customer_order_historyGet order history for a specific customer by email
get_inventory_levelsGet current inventory levels for all products
get_low_stock_productsGet products that are running low on stock
get_sales_trendsGet sales trends comparing current period to previous period
get_average_order_valueGet average order value over time grouped by day, week, or month
get_repeat_customersFind customers who have made multiple purchases

Developer Resources