Shopify

Analyze sales, products, inventory, and customers with the Shopify Admin GraphQL API.

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

Prerequisites

The following example requires the openai library and a Shopify Admin API access token with appropriate scopes.

uv pip install agno openai

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
  • OPENAI_API_KEY: Your OpenAI API key

For a new app, create it in the Shopify Dev Dashboard and obtain a shop access token through the applicable access-token flow. Client credentials apply to eligible apps owned by the same organization as the store; use the supported OAuth/token-exchange flow for other app types. Pass the resulting access token, not the app client secret. Shopify stopped creating legacy Admin custom apps on January 1, 2026; existing legacy tokens remain a separate supported case.

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 analyzes the fetched subset of sales data. The adapter does not paginate all orders, so its results can omit sales from larger stores. This older cookbook excerpt uses gpt-4o; the current main cookbook uses OpenAIChat(id="gpt-5.6-luna"). Use that model setting when following main.

cookbook/91_tools/shopify_tools.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.shopify import ShopifyTools

sales_agent = Agent(
    name="Sales Analyst",
    model=OpenAIChat(id="gpt-4o"),
    tools=[ShopifyTools()],
    instructions=[
        "You are a sales analyst for an e-commerce store using Shopify.",
        "Help the user understand their sales performance, product trends, and customer behavior.",
        "When analyzing data:",
        "1. Start by getting the relevant data using the available tools",
        "2. Summarize key insights in a clear, actionable format",
        "3. Highlight notable patterns or concerns",
        "4. Suggest next steps when appropriate",
        "Always present numbers clearly and use comparisons to add context.",
        "If you need to get information about the store, like currency, call the `get_shop_info` tool.",
    ],
    add_datetime_to_context=True,
    markdown=True,
)

sales_agent.print_response(
    "What are my top 5 selling products in the last 30 days? "
    "Show me quantity sold and revenue for each.",
)

Toolkit Params

ParameterTypeDefaultDescription
shop_nameOptional[str]NoneYour Shopify store name (e.g., "my-store" from my-store.myshopify.com). Or set via SHOPIFY_SHOP_NAME environment variable.
access_tokenOptional[str]NoneShopify 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 the fetched product/variant subset
get_low_stock_productsCurrently unavailable: the adapter sends an invalid GraphQL query; see limitations below
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

Analytics limits

The aggregate methods read bounded snapshots, including at most 250 orders per query and 100 line items per order. Product and variant queries have their own limits, and the adapter does not paginate them. Top products, sales totals, repeat-customer counts, and trends therefore describe only the returned subset. Use a paginated provider workflow when you need complete store reporting.

The current get_low_stock_products query contains doubled GraphQL braces and fails before producing inventory results. Keep it out of the agent's tools until that upstream query is repaired, for example ShopifyTools(exclude_tools=["get_low_stock_products"]). Enabling it does not provide a working low-stock report.

Developer Resources