# YouTube Trending Scraper (`vakitek/youtube-trending`) Actor

Get YouTube's official Trending Music and Top Music Videos charts for any country: rank, views, artists, change versus last period. 0.50 USD per 1,000 results, no minimum charge per run.

- **URL**: https://apify.com/vakitek/youtube-trending.md
- **Developed by:** [Brahim Sliti](https://apify.com/vakitek) (community)
- **Categories:** Videos, Social media
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 chart entry 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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Trending Scraper

Give it countries, get back YouTube's own Trending Music and Top Music Videos charts for each one: rank, title, channel, artists, views and how the rank moved since last period. One row per chart entry.

These are YouTube's official music charts, built into YouTube Charts. YouTube removed its general Trending page in 2025, so this is the closest official chart still available: it covers trending and top music videos, not every kind of trending video.

### What people use it for

- **Music industry monitoring.** Track where a new release enters the chart and how fast it climbs, country by country.
- **Market research.** Compare which artists and songs are trending in the US versus France or Japan on the same day.
- **Content calendars.** Spot which music videos are gaining the most this week to time a campaign around them.
- **Competitor tracking.** Watch a label's or channel's videos move up or down the chart over time.

### How to use it

1. Add countries in **Countries**, one per line: ISO codes like `US`, `FR`, `JP` (default `US`).
2. Pick a **Chart**: Trending now (30 entries per country, no view count), or Top music videos this week or today (100 entries, with view count).
3. Optional: turn on **Include video details** to add views, likes, comment count, publish date and description to each entry.
4. Click **Start**. Export as JSON, CSV or Excel, or pull the results through the API.

```json
{
  "countries": ["US", "FR"],
  "chart": "top_videos_weekly"
}
```

### What you get

```json
{
  "rank": 1,
  "previousRank": 18,
  "weeksOnChart": 2,
  "id": "gsZauX8gwxo",
  "title": "expectations (feat. Chappell Roan) (Official Music Video)",
  "url": "https://www.youtube.com/watch?v=gsZauX8gwxo",
  "thumbnailUrl": "https://i.ytimg.com/vi/gsZauX8gwxo/maxresdefault.jpg",
  "channelName": "OliviaRodrigoVEVO",
  "artists": ["Olivia Rodrigo"],
  "viewCount": 3907969,
  "viewCountChangePercent": 289.3,
  "country": "US",
  "chart": "top_videos_weekly"
}
```

- `rank`/`previousRank`/`weeksOnChart` show the entry's current and previous position and how long it has been charting. `previousRank` is `null` for a new entry.
- `viewCount` is `null` on the **Trending now** chart: that chart does not carry a view count, only rank. The two **Top music videos** charts always have one.
- `viewCountChangePercent` is the change in views versus the previous period, as a percentage (so `289.3` means views nearly quadrupled).
- Turn on **Include video details** to also get `likes`, `commentsCount`, `publishedAt` and `description` on each entry, at no extra cost.

### Pricing

**0.50 USD per 1,000 results.** Include video details at no extra cost. There is no minimum charge per run and no monthly fee.

Example: Trending now for 2 countries (60 results) costs 0.03 USD.

### Good to know

- This is a music chart, not a general list of trending videos: YouTube itself removed the general Trending page in 2025. For videos trending for any other reason, there is no official YouTube source left to scrape honestly.
- `global` is only accepted for the Top music videos charts, not for Trending now (YouTube does not publish a global Trending now chart).
- For a channel's own video list and stats, use our [YouTube Channel Scraper](https://apify.com/vakitek/youtube-channel-videos).
- You don't need a proxy, a YouTube account or a YouTube API key.

### Errors

A bad input never crashes the run. It becomes a row with an `error` code, and you are not charged for it.

| `error` | What happened | Retry? |
| --- | --- | --- |
| `INVALID_INPUT` | The country code is not a real country, or not supported for this chart | No |
| `NO_RESULTS` | The chart came back empty for this country | No |
| `PARSE_ERROR` | YouTube changed its page and we could not read it; we fix these fast, open an issue | No |
| `BLOCKED` | YouTube refused us for now, even after trying every proxy tier | Yes |
| `UPSTREAM_ERROR` | Something went wrong on YouTube's side or ours | Yes |
| `UPSTREAM_UNAVAILABLE` | Our API was unreachable | Yes |
| `TIME_BUDGET_EXCEEDED` | The time budget ran out before this country finished | Yes |

### FAQ

**Is this every trending video on YouTube?**
No. YouTube removed its general Trending page in 2025. This actor covers YouTube's own music charts (Trending now, Top music videos), which is the closest official chart still published.

**I already use another YouTube trending actor. Do I have to change my code?**
Probably not. The output field names follow the most used YouTube trending scraper on the Store.

**Can I call it from my code or from an AI agent?**
Yes, like any Apify actor: REST API, the Python and JavaScript clients, or the Apify MCP server. The examples are in the API tab.

**Something broke or a field is missing?**
Open an issue on this page. We read every one and usually answer within a day.

# Changelog

This Actor's version history is a separate document: https://apify.com/vakitek/youtube-trending/changelog.md

# Actor input Schema

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

ISO 3166-1 alpha-2 country codes (e.g. US, FR, JP). Add one line per country.

## `chart` (type: `string`):

Which YouTube Charts music-analytics chart to scrape.

## `maxResults` (type: `integer`):

Maximum number of chart entries to return per country.

## `includeVideoDetails` (type: `boolean`):

Adds views, likes, comment count, publish date and description to each entry via one extra request per video.

## `timeBudgetSecs` (type: `integer`):

Stop and return what is ready after this many seconds, so n8n/Make run-sync calls never time out. 0 = no limit.

## Actor input object example

```json
{
  "countries": [
    "US"
  ],
  "chart": "trending",
  "maxResults": 100,
  "includeVideoDetails": false,
  "timeBudgetSecs": 240
}
```

# Actor output Schema

## `results` (type: `string`):

Chart entries for each requested country, with rank, views and artists. Error items carry an `error` code and the `input` that failed.

# 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 = {
    "countries": [
        "US"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("vakitek/youtube-trending").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 = { "countries": ["US"] }

# Run the Actor and wait for it to finish
run = client.actor("vakitek/youtube-trending").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 '{
  "countries": [
    "US"
  ]
}' |
apify call vakitek/youtube-trending --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vakitek/youtube-trending"
        }
    }
}
```

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/B1gFyi31eLiIrT0vM/builds/MiiVJerPihCGLXUpZ/openapi.json
