# TikTok Shop & E-Commerce Sales Velocity Tracker (`laced_kirtan/tiktok-shop-sales-velocity`) Actor

Reads public TikTok Shop or Shein product pages and ranks products when public sales telemetry is present in the page data.

- **URL**: https://apify.com/laced\_kirtan/tiktok-shop-sales-velocity.md
- **Developed by:** [Shwetanshu Mehta](https://apify.com/laced_kirtan) (community)
- **Categories:** E-commerce, Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 product sales-velocity records

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

## TikTok Shop & E-Commerce Sales Velocity Tracker

This Actor reads public TikTok Shop or Shein category/product pages and ranks products only when the page exposes sales telemetry. It persists a bounded per-category history so cumulative unit counters can produce a real snapshot delta on later runs. It does not infer sales from popularity badges, solve CAPTCHAs, or call private seller APIs.

### Input

```json
{
  "category": "Beauty & Personal Care",
  "minDailySales": 50,
  "sortBy": "SALES_VELOCITY",
  "maxProducts": 500,
  "maxRetries": 2,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

Optional `platform: "shein"` and `startUrls` allow a public Shein category or a region-specific source URL. TikTok categories use the current public `/us/k/<keyword>` storefront route. Public-site markup and anti-bot behavior can change; proxy retries rotate bounded sessions and user agents, challenge pages are detected but never solved or bypassed, and empty product pages are recorded as bounded source warnings in `RUN_SUMMARY`. If every request remains blocked, the run fails clearly instead of succeeding with an unexplained empty dataset.

### Output

Each item contains `productId`, `title`, `productUrl`, `price`, `currency`, `commissionRate`, `totalUnitsSold`, `totalUnitsSoldSource`, `salesLast24h`, `velocitySource`, snapshot timing, `estDailyRevenue`, `affiliateCreatorCount`, top affiliate handles, and a quality score. Exact embedded product counters are preferred over rounded visible labels, and the selected evidence is identified as `embedded_public_page` or `visible_page_text`. Unknown values are `null`, not zero. Revenue is calculated only when price currency is known; the USD alias is populated only for USD.

When a source reports a true 24-hour field, `velocitySource` is `source_reported_24h`. Otherwise, the first run stores a snapshot and immediately returns the strongest cumulative-sales baselines as uncharged records with `salesLast24h: null`; a later run 1–168 hours afterward can report `snapshot_delta`. Counter resets and stale histories remain null and are labeled explicitly.

### Resource controls

- Pages are fetched sequentially with streamed byte limits and timeouts.
- A bounded, update-aware min-heap retains only the requested top-K products.
- Snapshot history uses one bounded key-value record per platform/category scope, capped at 5,000 products.
- Products are emitted after ranking; raw page objects are not retained.
- Page discovery and affiliate-handle lists are capped.

### Monetization

The manifest declares `product-record` at $0.003 per usable velocity record ($3.00 per 1,000). Products without source-reported or valid snapshot-derived velocity are not charged. A $39/month rental offer can be configured separately in the Apify Store listing.

The published schema includes a one-page, ten-product TikTok Shop prefill for the Store health test. First observations with cumulative sales but no defensible 24-hour delta are returned as uncharged baselines; rerun later to derive snapshot velocity.

### Local development

```bash
npm install
npm test
npm run check
apify validate-schema .actor/input_schema.json
apify run --purge
```

# Actor input Schema

## `category` (type: `string`):

Category such as Beauty & Personal Care.

## `minDailySales` (type: `integer`):

Only emit products whose public sales-velocity field meets this threshold. Unknown telemetry is not treated as zero.

## `sortBy` (type: `string`):

Ranking field used by the bounded top-K result set.

## `maxProducts` (type: `integer`):

Bounded top-K result set retained in memory and emitted.

## `platform` (type: `string`):

Public source platform to scan.

## `startUrls` (type: `array`):

Use public category or search pages when the generated category URL is not appropriate for the selected region.

## `maxPages` (type: `integer`):

Hard cap on public category/search pages fetched.

## `maxRetries` (type: `integer`):

Bounded retries using a fresh proxy session and browser user agent after blocked or failed public requests. CAPTCHAs are detected but never solved or bypassed.

## `proxyConfiguration` (type: `object`):

Use Apify Proxy or your own proxy URLs for public storefront requests. Residential proxy access may improve availability but can add platform usage cost.

## `requestTimeoutSecs` (type: `integer`):

Timeout per public category or product page request.

## `maxResponseBytes` (type: `integer`):

Reject oversized pages before JSON/HTML parsing.

## Actor input object example

```json
{
  "category": "Beauty & Personal Care",
  "minDailySales": 50,
  "sortBy": "SALES_VELOCITY",
  "maxProducts": 10,
  "platform": "tiktok-shop",
  "startUrls": [],
  "maxPages": 1,
  "maxRetries": 1,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "requestTimeoutSecs": 60,
  "maxResponseBytes": 6000000
}
```

# Actor output Schema

## `records` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# 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 = {
    "category": "Beauty & Personal Care",
    "minDailySales": 50,
    "sortBy": "SALES_VELOCITY",
    "maxProducts": 10,
    "platform": "tiktok-shop",
    "maxPages": 1,
    "maxRetries": 1,
    "proxyConfiguration": {
        "useApifyProxy": true
    },
    "requestTimeoutSecs": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("laced_kirtan/tiktok-shop-sales-velocity").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 = {
    "category": "Beauty & Personal Care",
    "minDailySales": 50,
    "sortBy": "SALES_VELOCITY",
    "maxProducts": 10,
    "platform": "tiktok-shop",
    "maxPages": 1,
    "maxRetries": 1,
    "proxyConfiguration": { "useApifyProxy": True },
    "requestTimeoutSecs": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("laced_kirtan/tiktok-shop-sales-velocity").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 '{
  "category": "Beauty & Personal Care",
  "minDailySales": 50,
  "sortBy": "SALES_VELOCITY",
  "maxProducts": 10,
  "platform": "tiktok-shop",
  "maxPages": 1,
  "maxRetries": 1,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "requestTimeoutSecs": 60
}' |
apify call laced_kirtan/tiktok-shop-sales-velocity --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,laced_kirtan/tiktok-shop-sales-velocity"
        }
    }
}

```

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/EDfEKMoc8Zxx1aa01/builds/WifM2grE6GW1gNJuR/openapi.json
