# Trustpilot Review Theme Miner (`isotonic/trustpilot-review-theme-miner`) Actor

Extracts public Trustpilot reviews and derives complaint and praise themes.

- **URL**: https://apify.com/isotonic/trustpilot-review-theme-miner.md
- **Developed by:** [Brian Keefe](https://apify.com/isotonic) (community)
- **Categories:** E-commerce, Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## Trustpilot Review Theme Miner

Production-oriented Apify Actor that reads public Trustpilot company review pages, extracts available review fields, and derives complaint themes, praise themes, sentiment, urgency, competitor mentions, product mentions, rating distributions, date distributions, and representative quotes.

### Public-data posture

- Trustpilot-first only.
- Uses public company review pages only.
- Does not require login.
- Does not use private APIs, anti-bot bypasses, or hidden endpoints.
- Gracefully reports public-access failures such as `403`, `429`, and network errors in output source evidence.

### Input

The actor accepts either `companyProfileUrls`, `domains`, or both. Runtime validation enforces that at least one entry is provided.

```json
{
  "companyProfileUrls": [
    "https://www.trustpilot.com/review/example.com"
  ],
  "domains": [
    "example.org"
  ],
  "maxReviews": 25,
  "ratings": [1, 2, 4, 5],
  "dateFrom": "2024-01-01",
  "dateTo": "2024-12-31",
  "includeRawReviews": true,
  "maxQuotesPerTheme": 2
}
````

#### Input fields

- `companyProfileUrls`: array of Trustpilot company review profile URLs.
- `domains`: array of bare domains, converted to `https://www.trustpilot.com/review/<domain>`.
- `maxReviews`: maximum reviews to include per company, capped at `500`.
- `ratings`: allowed star ratings from `1` to `5`.
- `dateFrom`: inclusive ISO date lower bound.
- `dateTo`: inclusive ISO date upper bound.
- `includeRawReviews`: when `true`, includes the extracted raw review records in the final dataset item.
- `maxQuotesPerTheme`: number of quotes kept per derived theme.

### Output

Each dataset item contains:

- `input`: normalized target domain and Trustpilot profile URL.
- `company`: detected company name and canonical profile URL.
- `source`: public-data evidence, page fetch statuses, retries, and stop reason.
- `summary`: review counts and applied filters.
- `analysis.sentiment`: positive, neutral, negative counts and average rating.
- `analysis.complaintThemes`: negative-rating themes with evidence and representative quotes.
- `analysis.praiseThemes`: positive-rating themes with evidence and representative quotes.
- `analysis.urgencySignals`: urgent complaint evidence.
- `analysis.competitorMentions`: mentions extracted from phrases like `vs`, `versus`, or `compared to`.
- `analysis.productMentions`: recurring product or experience terms.
- `analysis.ratingDistribution`: counts for ratings `1` through `5`.
- `analysis.dateDistribution`: monthly review counts in `YYYY-MM` form.
- `analysis.representativeQuotes`: overall positive and negative quote samples.
- `reviews`: included only when `includeRawReviews` is `true`.

See `examples/sample-input.json` and `examples/sample-output.json`.

### Extraction notes

- The parser prioritizes public Trustpilot review-card HTML and JSON-LD review nodes when present.
- Extracted review fields include title, body, rating, date, reviewer metadata when available, and the source URL.
- Pagination is attempted via `?page=<n>` URLs while reviews remain and public pages continue to return content.

### Limitations

- Trustpilot can rate-limit or block public access. The actor surfaces those events in `source.pageFetches` and stops cleanly.
- Public page structures can change. The parser is intentionally narrow and relies on public review cards and public JSON-LD.
- Theme derivation is heuristic. It is deterministic and maintainable, but not a substitute for a bespoke NLP model.
- Competitor and product mention extraction is pattern-based and may miss implicit references.

### Local usage

Install dependencies:

```bash
npm install
```

Run the deterministic smoke test:

```bash
npm test
```

Run locally with Apify input storage or environment-provided input:

```bash
npm start
```

### Publish

With the Apify CLI authenticated:

```bash
apify push
```

# Actor input Schema

## `companyProfileUrls` (type: `array`):

Full Trustpilot company review profile URLs such as https://www.trustpilot.com/review/example.com.

## `domains` (type: `array`):

Company domains to resolve to Trustpilot review pages.

## `maxReviews` (type: `integer`):

Maximum number of public Trustpilot reviews to collect and analyze per company profile.

## `ratings` (type: `array`):

Only include these star ratings.

## `dateFrom` (type: `string`):

Inclusive ISO date filter, for example 2024-01-01.

## `dateTo` (type: `string`):

Inclusive ISO date filter, for example 2024-12-31.

## `includeRawReviews` (type: `boolean`):

When enabled, include the extracted review rows in addition to the derived theme analysis.

## `maxQuotesPerTheme` (type: `integer`):

Maximum number of evidence quotes to include for each detected complaint or praise theme.

## Actor input object example

```json
{
  "companyProfileUrls": [
    "https://www.trustpilot.com/review/example.com"
  ],
  "domains": [
    "example.com"
  ],
  "maxReviews": 50,
  "ratings": [
    "1",
    "2",
    "3",
    "4",
    "5"
  ],
  "includeRawReviews": false,
  "maxQuotesPerTheme": 3
}
```

# 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 = {
    "companyProfileUrls": [
        "https://www.trustpilot.com/review/example.com"
    ],
    "domains": [
        "example.com"
    ],
    "ratings": [
        "1",
        "2",
        "3",
        "4",
        "5"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("isotonic/trustpilot-review-theme-miner").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 = {
    "companyProfileUrls": ["https://www.trustpilot.com/review/example.com"],
    "domains": ["example.com"],
    "ratings": [
        "1",
        "2",
        "3",
        "4",
        "5",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("isotonic/trustpilot-review-theme-miner").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 '{
  "companyProfileUrls": [
    "https://www.trustpilot.com/review/example.com"
  ],
  "domains": [
    "example.com"
  ],
  "ratings": [
    "1",
    "2",
    "3",
    "4",
    "5"
  ]
}' |
apify call isotonic/trustpilot-review-theme-miner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=isotonic/trustpilot-review-theme-miner",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Trustpilot Review Theme Miner",
        "description": "Extracts public Trustpilot reviews and derives complaint and praise themes.",
        "version": "0.1",
        "x-build-id": "ykL2gSA4wXa0QAZ2r"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/isotonic~trustpilot-review-theme-miner/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-isotonic-trustpilot-review-theme-miner",
                "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/isotonic~trustpilot-review-theme-miner/runs": {
            "post": {
                "operationId": "runs-sync-isotonic-trustpilot-review-theme-miner",
                "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/isotonic~trustpilot-review-theme-miner/run-sync": {
            "post": {
                "operationId": "run-sync-isotonic-trustpilot-review-theme-miner",
                "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": {
                    "companyProfileUrls": {
                        "title": "Trustpilot company profile URLs",
                        "type": "array",
                        "description": "Full Trustpilot company review profile URLs such as https://www.trustpilot.com/review/example.com.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "domains": {
                        "title": "Company domains",
                        "type": "array",
                        "description": "Company domains to resolve to Trustpilot review pages.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxReviews": {
                        "title": "Maximum reviews per company",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of public Trustpilot reviews to collect and analyze per company profile.",
                        "default": 50
                    },
                    "ratings": {
                        "title": "Ratings filter",
                        "type": "array",
                        "description": "Only include these star ratings.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "1",
                                "2",
                                "3",
                                "4",
                                "5"
                            ]
                        }
                    },
                    "dateFrom": {
                        "title": "Date from",
                        "type": "string",
                        "description": "Inclusive ISO date filter, for example 2024-01-01."
                    },
                    "dateTo": {
                        "title": "Date to",
                        "type": "string",
                        "description": "Inclusive ISO date filter, for example 2024-12-31."
                    },
                    "includeRawReviews": {
                        "title": "Include raw reviews in output",
                        "type": "boolean",
                        "description": "When enabled, include the extracted review rows in addition to the derived theme analysis.",
                        "default": false
                    },
                    "maxQuotesPerTheme": {
                        "title": "Maximum representative quotes per theme",
                        "minimum": 1,
                        "maximum": 10,
                        "type": "integer",
                        "description": "Maximum number of evidence quotes to include for each detected complaint or praise theme.",
                        "default": 3
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
