# Shopify Competitor Repricer (`akhiltrivedix/shopify-competitor-repricer`) Actor

Automatically scrape competitor prices, semantically map identical items using AI, and dynamically reprice your Shopify catalog via secure Admin API integration.

- **URL**: https://apify.com/akhiltrivedix/shopify-competitor-repricer.md
- **Developed by:** [Akhil Trivedi](https://apify.com/akhiltrivedix) (community)
- **Categories:** E-commerce, AI, Automation
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Shopify Competitor Repricer (Closed-Loop AI Agent)

A closed-loop dynamic competitor price matching and repricing agent for Shopify. It crawls competitor Shopify stores using their public feeds, matches equivalent items, computes safety margins, and mutates prices in the user's Shopify Admin panel.

***

### 🚀 Why use the Shopify Competitor Repricer?

Managing prices across hundreds of products manually is a bottleneck. Standard scrapers only export competitor data to a spreadsheet, leaving you to do the heavy lifting of product matching, math, and manual catalog updates.

This Actor closes the loop:

1. **Automates Competitor Scraping**: Hitting the public product feeds of competitor stores with 100% reliability (no proxy overhead).
2. **AI Semantic Matching**: Maps catalog items (even with mismatched names/SKUs) using GPT-4o-mini.
3. **Price Rules Engine**: Calculates price cuts under your custom undercut percentage and safety margins.
4. **Direct Write-Back**: Updates variants directly in your Shopify Admin dashboard via secure API mutations.

***

### ✨ Features

- 🔄 **Closed-Loop Automation**: Changes prices directly in your active Shopify store catalog.
- ⚡ **Zero-Auth Crawler**: Fetches competitor data in milliseconds via native `/products.json` feeds.
- 🧠 **LLM Catalog Matching**: Uses `gpt-4o-mini` to resolve title differences (e.g. mapping competitor's *"Nike AF1 - Red"* to your *"Air Force 1 Crimson"*).
- 🛡️ **Safety Margin Guardrails**: Configurable percentage undercut rules and absolute price discounts limits.
- 🔍 **Dry Run Mode**: Test price adjustments in simulation mode to verify calculations before going live.
- 📊 **Clean Output Dashboard**: Generates structured table visualizations directly inside the Apify Console.

***

### 📖 How to Get Started (Shopify API Token Setup)

To allow the Actor to write updated prices back to your Shopify store, you must generate a secure Admin API Access Token:

1. Log in to your **Shopify Admin Panel**.
2. Navigate to **Settings > Apps and sales channels > Develop apps**.
3. Click **Create an app**, name it (e.g. `Apify Repricer`), and select your developer account.
4. Under **Configuration**, click **Configure Admin API integration**.
5. Enable the following scopes:
   - `write_products` (Required to update variant prices)
   - `read_products` (Required to fetch your catalog listings)
6. Click **Save** and then click **Install App** in the top right.
7. Copy the **Admin API access token** (starts with `shpat_`).

***

### 📥 Input Parameters

Configure the following inputs in the Apify Console when running the Actor:

| Field Name | Type | Required | Default | Description |
| :--- | :--- | :--- | :--- | :--- |
| **Competitor Store URL** | `string` | **Yes** | `https://allbirds.com` | The base domain of the competitor's Shopify store. |
| **Your Shopify Store Domain** | `string` | **Yes** | `demo-store.myshopify.com` | Your internal store domain (e.g. `your-store.myshopify.com`). |
| **Shopify Admin Access Token** | `string` | **Yes** | `shpat_demo_mock_token` | The secure access token (`shpat_...`) generated in your Shopify admin. |
| **OpenAI API Key (BYOK)** | `string` | No | `MOCK_KEY_FOR_TESTING` | Your OpenAI API Key for semantic matching. |
| **Undercut Percentage** | `number` | No | `2.0` | The percentage to price under the competitor (e.g. `2.0` for 2% cheaper). |
| **Maximum Discount Limit** | `number` | No | `15.0` | The max discount percentage allowed off your original price to protect margins. |
| **Dry Run Mode** | `boolean` | No | `true` | If enabled, calculates and logs adjustments without modifying your active store. |

***

### 📤 Output / Dataset Structure

Each run saves the pricing adjustments report to the default dataset. A sample output record looks like this:

```json
{
  "variantId": 90011,
  "title": "Adidas Gazelle - Classic White",
  "sku": "ADI-GAZ-WH",
  "oldPrice": 90.00,
  "competitorPrice": 75.00,
  "newPrice": 76.50,
  "status": "UPDATED"
}
```

#### Output Field Descriptions

- `variantId` (Integer): The unique variant identifier in your Shopify store.
- `title` (String): The matched variant description.
- `sku` (String): Your product SKU.
- `oldPrice` (Number): The variant's starting price before the run.
- `competitorPrice` (Number): The competitor's price extracted.
- `newPrice` (Number): The newly computed price (either undercut or safety capped).
- `status` (String): Can be `UPDATED` (price updated), `DRY_RUN` (calculations completed but not synced), `NO_CHANGE` (price already matches rule), or `NO_MATCH` (could not find variant in competitor catalog).

# Actor input Schema

## `competitorUrl` (type: `string`):

The base domain of the competitor's Shopify store (e.g., https://competitor-sneakers.com).

## `shopifyStoreDomain` (type: `string`):

Your internal Shopify domain (e.g. your-store.myshopify.com).

## `shopifyAdminAccessToken` (type: `string`):

Shopify Admin API token (starts with shpat\_). Required to write back prices.

## `openaiApiKey` (type: `string`):

Your OpenAI API Key. Used to run semantic variant mapping between catalogs.

## `undercutPercentage` (type: `number`):

The percentage to price under the competitor's price (e.g. 2.0 to be 2% cheaper). Use 0.0 to match price.

## `maxDiscountPercentage` (type: `number`):

The maximum discount percentage allowed off your original price to prevent margin loss.

## `dryRun` (type: `boolean`):

If enabled, the actor will calculate prices and save the report, but will NOT update Shopify.

## Actor input object example

```json
{
  "competitorUrl": "https://allbirds.com",
  "shopifyStoreDomain": "demo-store.myshopify.com",
  "shopifyAdminAccessToken": "shpat_demo_mock_token",
  "openaiApiKey": "MOCK_KEY_FOR_TESTING",
  "undercutPercentage": 2,
  "maxDiscountPercentage": 15,
  "dryRun": true
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "competitorUrl": "https://allbirds.com",
    "shopifyStoreDomain": "demo-store.myshopify.com",
    "shopifyAdminAccessToken": "shpat_demo_mock_token",
    "openaiApiKey": "MOCK_KEY_FOR_TESTING"
};

// Run the Actor and wait for it to finish
const run = await client.actor("akhiltrivedix/shopify-competitor-repricer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "competitorUrl": "https://allbirds.com",
    "shopifyStoreDomain": "demo-store.myshopify.com",
    "shopifyAdminAccessToken": "shpat_demo_mock_token",
    "openaiApiKey": "MOCK_KEY_FOR_TESTING",
}

# Run the Actor and wait for it to finish
run = client.actor("akhiltrivedix/shopify-competitor-repricer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "competitorUrl": "https://allbirds.com",
  "shopifyStoreDomain": "demo-store.myshopify.com",
  "shopifyAdminAccessToken": "shpat_demo_mock_token",
  "openaiApiKey": "MOCK_KEY_FOR_TESTING"
}' |
apify call akhiltrivedix/shopify-competitor-repricer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,akhiltrivedix/shopify-competitor-repricer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/g6dKfGgzsvwa31Z3v/builds/cTbY1SDJ4k7z7Zy2Z/openapi.json
