# IMDb Marketing Analyzer (`scraper_guru/imdb-analyzer`) Actor

Scrape IMDb ratings across multiple countries and identify the best markets for your movie.

- **URL**: https://apify.com/scraper\_guru/imdb-analyzer.md
- **Developed by:** [LIAICHI MUSTAPHA](https://apify.com/scraper_guru) (community)
- **Categories:** Developer tools, E-commerce, Lead generation
- **Stats:** 2 total users, 1 monthly users, 96.6% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.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 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

## 🎬 IMDb Marketing Analyzer

**Scrape IMDb ratings across multiple countries and identify the best markets for your movie.**

***

### 🚀 Features

- **Multi-Country Scraping**: Automatically fetches demographic rating data from IMDb for a custom list of countries (e.g., US, UK, India, Germany, France).
- **Marketing Intelligence**: Calculates an **"Opportunity Score"** for each country to help you find untapped markets where audiences are highly engaged.
- **Visual Analytics**: Generates professional charts (`rating_chart.png`, `votes_chart.png`) visualizing the data.
- **Direct IP Support**: Optimized to run efficiently on Apify's infrastructure.

***

### 📥 Input Parameters

| Field | Type | Description | Default |
|---|---|---|---|
| `imdb_id` | String | The unique ID of the movie on IMDb (e.g., `tt0111161` for *The Shawshank Redemption*). | `tt0111161` |
| `countries` | Array | List of countries to scrape data for. Names must match IMDb's country filters exactly. | `["United States", "United Kingdom", "India", "Germany", "France"]` |

***

### 📤 Output

The actor stores results in the default dataset and Key-Value store.

#### 1. Dataset (JSON)

The main result object contains:

- **Scraped Data**: Raw rating metrics (Mean, Total Votes) for each country.
- **Analysis**: Global averages and computed scores.
- **Insights**: A sorted list of "Country Insights" from highest to lowest opportunity.

**Example JSON:**

```json
{
  "imdb_id": "tt0111161",
  "marketing_analysis": {
    "global_average_rating": 9.32,
    "top_opportunity": "United States",
    "country_insights": [
      {
        "country": "United States",
        "rating": 9.3,
        "votes": 667000,
        "opportunity_score": 54.16,
        "status": "Neutral"
      },
      {
        "country": "India",
        "rating": 9.5,
        "votes": 156000,
        "opportunity_score": 49.33,
        "status": "High Affinity"
      }
    ]
  }
}
```

#### 2. Key-Value Store (Images)

- **`rating_chart.png`**: Bar chart comparing average ratings across countries.
- **`votes_chart.png`**: Bar chart comparing the volume of votes (popularity) across countries.

***

### 📊 How It Works

1. **Navigates** to the IMDb Ratings page for the specific ID.
2. **Iterates** through the requested countries, applying filters to extract specific data point.
3. **Computes** metrics:
   - **Affinity Score**: `Country Rating - Global Average`. Positive values indicate the country likes the movie *more* than the global average.
   - **Opportunity Score**: A weighted metric combining both *Rating* and *Log(Votes)* to find markets that are both **highly positive** and **significant in size**.
4. **Generates** plots using `matplotlib` and saves them to the Key-Value store.

***

### 🛠 Usage Tips

- **Validation**: Ensure the `imdb_id` is valid and the movie has been released (unreleased movies may not have rating breakdowns).
- **Country Names**: Use standard English names as they appear on IMDb (e.g., use "United Kingdom", not "UK").

# Actor input Schema

## `imdb_id` (type: `string`):

The IMDb ID of the movie to analyze (e.g., tt0111161).

## `countries` (type: `array`):

List of countries to scrape and analyze.

## Actor input object example

```json
{
  "imdb_id": "tt0111161",
  "countries": [
    "United States",
    "United Kingdom",
    "India",
    "Germany",
    "France",
    "Japan",
    "Brazil",
    "Turkey",
    "Canada",
    "Australia"
  ]
}
```

# 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 = {
    "imdb_id": "tt0111161"
};

// Run the Actor and wait for it to finish
const run = await client.actor("scraper_guru/imdb-analyzer").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 = { "imdb_id": "tt0111161" }

# Run the Actor and wait for it to finish
run = client.actor("scraper_guru/imdb-analyzer").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 '{
  "imdb_id": "tt0111161"
}' |
apify call scraper_guru/imdb-analyzer --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/h53f47gcdtzfWHJVe/builds/XZ0X84nkVGzMhmohF/openapi.json
