# Sensabeauty Price Tracker (`payai/sensabeauty-price-tracker`) Actor

Comp prices

- **URL**: https://apify.com/payai/sensabeauty-price-tracker.md
- **Developed by:** [PayAI](https://apify.com/payai) (community)
- **Categories:** Agents, AI, Automation
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$1.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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## SensaBeauty Price Tracker - APIFY Actor

Automated competitor price tracking for SensaBeauty products.

### Features

- **3 Competitor Sites**: Jomashop, FragranceNet, Maxaroma
- **Smart Filtering**: Automatically scrapes 998 fragrance products (excludes skincare)
- **Intelligent Matching**: Fuzzy search with SKU prioritization
- **Real-time Analytics**: Automatic price statistics calculation
- **Supabase Integration**: Direct database updates with confidence tracking
- **Match Quality Scores**: Confidence scoring (0.00 - 1.00)
- **Statistics Logging**: Scrape run performance metrics and analytics

### Deployment

#### Prerequisites

- APIFY account
- APIFY CLI installed: `npm install -g apify-cli`
- Supabase credentials

#### Deploy to APIFY

```bash
## Install dependencies
npm install

## Test locally
npm test

## Login to APIFY
apify login --token apify_api_1Z5ffM5PqQSRz2LOl5SWbdbsPvbkkg35ssUx

## Deploy
apify push
````

#### Environment Variables

Set these in APIFY Console:

- `SUPABASE_URL` = `https://iuyxjwgklxhxqtqjwvrq.supabase.co`
- `SUPABASE_SERVICE_KEY` = \[your service role key]

### Usage

#### Input Schema

```json
{
  "mode": "full",           // "full", "sample", or "specific"
  "productIds": [],         // Array of product IDs (for "specific" mode)
  "competitors": [          // Which sites to scrape
    "jomashop",
    "fragrancenet",
    "maxaroma"
  ],
  "maxConcurrency": 3,      // Number of parallel pages
  "updateDatabase": true    // Whether to update Supabase
}
```

#### Run via API

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_ACTOR_ID/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"sample"}'
```

#### Run via GitHub Actions

The actor is automatically triggered daily at 2 AM UTC by the GitHub Actions workflow in `.github/workflows/price-sync.yml`.

### Output

#### Data Schema

Each product scrape outputs structured JSON:

```json
{
  "productId": "uuid",              // Product UUID from Supabase
  "productName": "Product Name",    // SensaBeauty product name
  "productSku": "SKU123",          // Product SKU/UPC code
  "competitor": "jomashop.com",    // Competitor domain
  "competitorName": "Jomashop",    // Human-readable name
  "price": 89.99,                  // Current price (USD)
  "originalPrice": 89.99,          // MSRP price
  "currency": "USD",               // Currency code
  "availability": "in_stock",      // Stock status
  "url": "https://...",            // Direct product URL
  "matchedTitle": "...",           // Matched product title
  "matchConfidence": 0.85,         // Match score (0.00-1.00)
  "scrapedAt": "2025-10-24T...",   // ISO 8601 timestamp
  "status": "success"              // success|not_found|error
}
```

#### Storage Destinations

1. **APIFY Dataset**: All scraped price data (always saved)
2. **Supabase Tables** (if `updateDatabase: true`):
   - `competitor_prices`: Individual price records
   - `product_price_analytics`: Calculated statistics
   - `scrape_runs`: Run statistics and performance metrics

#### Run Summary

Available via `Actor.getValue('OUTPUT')`:

```json
{
  "runId": "...",
  "mode": "full",
  "competitors": ["jomashop", "fragrancenet", "maxaroma"],
  "productsAttempted": 100,
  "productsMatched": 85,
  "matchRate": 85.00,
  "databaseUpdated": true,
  "completedAt": "2025-10-24T...",
  "status": "completed"
}
```

### Product Filtering

The actor automatically filters products to **only scrape fragrances**:

- ✅ **998 fragrance products** (category = "all")
- ❌ **Excludes 2 skincare products** (Serums, Cleansers)

This filtering ensures:

- Higher match rates (fragrances are sold on competitor sites)
- Faster run times (no wasted requests on skincare)
- More accurate pricing data

### Performance

- **Products**: 998 fragrances (automatically filtered)
- **Estimated Match Rate**: 40-60% (niche fragrances have lower availability)
- **Duration**: ~20-25 hours for full catalog (998 × 3 competitors)
- **Concurrency**: 3 pages (adjustable, recommended: 3)
- **Rate Limiting**: Auto-adjusts based on CPU and response codes

### Monitoring

Check scrape quality:

```sql
SELECT * FROM scrape_runs ORDER BY completed_at DESC LIMIT 5;
```

View price updates:

```sql
SELECT COUNT(*) FROM competitor_prices
WHERE scraped_at > NOW() - INTERVAL '24 hours';
```

### Support

For issues or questions, contact support or check the integration documentation.

# Actor input Schema

## `useStaticList` (type: `boolean`):

If true, use provided productList JSON instead of fetching from Supabase

## `productList` (type: `string`):

JSON array of products to scrape (only used if useStaticList is true). Paste entire contents of products-from-excel.json file.

## `mode` (type: `string`):

full = all products, sample = first 10, specific = product IDs (ignored if useStaticList is true)

## `productIds` (type: `array`):

List of specific product IDs to track (ignored if useStaticList is true)

## `competitors` (type: `array`):

Which competitor sites to scrape

## `maxConcurrency` (type: `integer`):

Maximum number of pages to scrape in parallel (recommended: 3)

## `updateDatabase` (type: `boolean`):

Whether to update Supabase database with results (recommended: false for testing)

## Actor input object example

```json
{
  "useStaticList": false,
  "productList": "[]",
  "mode": "full",
  "competitors": [
    "jomashop",
    "fragrancenet",
    "maxaroma",
    "fragrancex"
  ],
  "maxConcurrency": 3,
  "updateDatabase": false
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("payai/sensabeauty-price-tracker").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("payai/sensabeauty-price-tracker").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call payai/sensabeauty-price-tracker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=payai/sensabeauty-price-tracker",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Sensabeauty Price Tracker",
        "description": "Comp prices",
        "version": "2.0",
        "x-build-id": "v9nu1ZdBXSt0KP217"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/payai~sensabeauty-price-tracker/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-payai-sensabeauty-price-tracker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/payai~sensabeauty-price-tracker/runs": {
            "post": {
                "operationId": "runs-sync-payai-sensabeauty-price-tracker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/payai~sensabeauty-price-tracker/run-sync": {
            "post": {
                "operationId": "run-sync-payai-sensabeauty-price-tracker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "useStaticList": {
                        "title": "Use Static Product List",
                        "type": "boolean",
                        "description": "If true, use provided productList JSON instead of fetching from Supabase",
                        "default": false
                    },
                    "productList": {
                        "title": "Static Product List (JSON)",
                        "type": "string",
                        "description": "JSON array of products to scrape (only used if useStaticList is true). Paste entire contents of products-from-excel.json file.",
                        "default": "[]"
                    },
                    "mode": {
                        "title": "Scraping mode",
                        "enum": [
                            "full",
                            "sample",
                            "specific"
                        ],
                        "type": "string",
                        "description": "full = all products, sample = first 10, specific = product IDs (ignored if useStaticList is true)",
                        "default": "full"
                    },
                    "productIds": {
                        "title": "Product IDs (for specific mode)",
                        "type": "array",
                        "description": "List of specific product IDs to track (ignored if useStaticList is true)",
                        "items": {
                            "type": "string"
                        }
                    },
                    "competitors": {
                        "title": "Competitors to scrape",
                        "type": "array",
                        "description": "Which competitor sites to scrape",
                        "default": [
                            "jomashop",
                            "fragrancenet",
                            "maxaroma",
                            "fragrancex"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxConcurrency": {
                        "title": "Max concurrent pages",
                        "minimum": 1,
                        "maximum": 10,
                        "type": "integer",
                        "description": "Maximum number of pages to scrape in parallel (recommended: 3)",
                        "default": 3
                    },
                    "updateDatabase": {
                        "title": "Update Supabase",
                        "type": "boolean",
                        "description": "Whether to update Supabase database with results (recommended: false for testing)",
                        "default": false
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
