# YouTube Charts Scraper: trending videos, top songs by country (`tallyrake/youtube-trending`) Actor

YouTube trending videos as flat CSV/JSON rows: rank, title, channel, views, URL, region, category. One row per video, stable id. Trending chart only. Not search, comments, or autocomplete.

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

## Pricing

from $2.00 / 1,000 result rows

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Charts by country: trending videos, top videos, top songs, top artists

YouTube Charts as flat CSV/JSON rows. Pick one or more countries and one or more charts (trending videos, top music videos, top songs, top artists) and get each entry with its rank, title, artist, channel, views, URL, and a stable `id`. $0.25 per 1,000 rows.

The source is one POST to `https://charts.youtube.com/youtubei/v1/browse` per chart (the public YouTube Charts page, client `WEB_MUSIC_ANALYTICS` 2.0). It is not the YouTube Data API. It is not `https://www.youtube.com/feed/trending`. YouTube removed that Trending page on 2025-07-21; a logged-out fetch of it is the Home shell, and this actor does not read it.

### What you get

One row per chart entry. `id` is the first 16 hex characters of sha1(`region|chart|period|entityId`). A chart with no period (trending videos) uses an empty period segment. The same entry in another region, chart, or period is a different row.

| Field | Example |
|---|---|
| `id` | `81283813ed4fdc19` |
| `chart` | `top-videos` |
| `region` | `US` |
| `period` | `weekly`. `null` on trending videos, which has no period |
| `rank` | `1` (chart position, not renumbered after `maxRows`) |
| `rankChange` | `0` when the previous rank is present. Positive means it moved up (`previous − current`). `null` when the payload has no previous rank |
| `videoId` | `fcnDmrtj6Sk` on video charts. On top songs, the representative official video |
| `songId` | `null` here. A track id such as `G:jhyzqACqEWY` on top songs |
| `artistId` | `null` here. A chart id such as `/m/05mt_q` on top artists |
| `title` | `Dai Dai` |
| `channelName` | `shakiraVEVO`. `null` on songs and artists |
| `channelUrl` | `https://www.youtube.com/channel/UCGnjeahCJW1AF34HBmQTJ-Q` |
| `artistName` | `Shakira, Burna Boy` |
| `url` | `https://www.youtube.com/watch?v=fcnDmrtj6Sk`. On top artists this is the channel URL |
| `viewCount` | `2889869`. `null` on trending videos, which does not send a count |
| `viewCountText` | `2,889,869` (the count with thousands separators; the payload sends a number, not a label). `null` when there is no count |
| `periodStart` | `null`. The browse payload has no period start |
| `periodEnd` | `2026-10-08` when the list has an end date. `null` on trending videos |
| `fetchedAt` | ISO timestamp |

The example row is rank 1 of the US weekly top music videos chart saved during this build (2026-10-15). That response had 100 videos. Rank 1 was unchanged (`rankChange` 0). The same week, US top songs rank 1 was "Choosin' Texas" (5,611,670 views, up from 2) and US top artists rank 1 was Drake (40,488,924 views). US trending videos was 30 rows and had no view count, no rank change, and no period.

### Example input

```json
{
  "regions": ["US", "GB"],
  "charts": ["trending-videos", "top-videos"],
  "period": "weekly",
  "maxRows": 100,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

`regions` defaults to `["US"]`. `UK` is stored as `GB`. `charts` defaults to trending videos and top videos. `period` defaults to `weekly`. `maxRows` defaults to 100 and cannot exceed 200. Proxy defaults to Apify Proxy with no proxy group (datacenter). Language on the request is fixed to English.

Top songs and top artists are published weekly only. Asking for `daily` still fetches those two as weekly, and the row's `period` says `weekly`. Trending videos ignores `period`.

### Where this sits on the shelf

Not published. The $0.25 per 1,000 rows figure is the placeholder price; the maintainer sets pay-per-result on the Store. Nothing in this build charges a custom event. One default dataset row is one result.

This is YouTube Charts, not the Trending page YouTube removed. Store listings that scrape `/feed/trending` are a different product, and this pass did not re-count them.

### Recipes

**US top music videos, this week.** `regions` = `US`, `charts` = `top-videos`, `period` = `weekly`. One charts request. 100 rows, with views and a period end date.

**Trending videos right now.** `charts` = `trending-videos`. About 30 rows. `period`, `viewCount`, `rankChange`, and `periodEnd` are null. That is the live chart, not a weekly archive.

**Songs and artists.** `charts` = `top-songs` and `top-artists`. Weekly only. A song row's `url` is the representative official video; `songId` is the chart's track id. An artist row's `url` is the YouTube channel; `artistId` is the chart's artist id.

**Same charts, several countries.** `regions` = `US`, `GB`, `DE`. One request per region per chart. Rows carry `region`, so the dataset merges.

**Shorter file.** `maxRows` = 10 keeps the first 10 chart positions. Rank stays the chart rank.

### Cost limit

If a run reaches the "Maximum total charge per run" you set, it stops in process rather than being aborted by the platform: the run ends with status SUCCEEDED, and the run status message says how many rows were written and how many were found but not written and not billed. Re-running the same input writes and bills the same prefix again, so raise the cap before re-running if you want the rest.

No soaked run has been measured, so this README does not state a success rate or a platform-usage cost.

### Bigger jobs

Pulling charts for many countries, or need this as a one-off file instead of a run? We build custom exports — any keywords, countries and date ranges, delivered as flat CSV or JSON within 24 hours: https://tallyrake.com/datasets/

### Limits

This is YouTube Charts only. It is not search, not comments, not autocomplete, and not the removed Trending feed at `https://www.youtube.com/feed/trending`. It does not return channel uploads, video descriptions, or Data API `mostPopular`.

Checked live on 2026-10-15, US, no proxy:

| Chart | Period | Rows | Views | Period end |
|---|---|---|---|---|
| Trending videos | none (live) | 30 | no | no |
| Top music videos | weekly | 100 | yes | 2026-10-08 |
| Top songs | weekly | 100 | yes | 2026-10-08 |
| Top artists | weekly | 100 | yes | 2026-10-08 |

Daily top music videos is a period the charts page publishes. It was not fetched during this build. Top songs and top artists have no daily chart. The payload's period end is the only date; there is no period start to store. `viewCountText` is the chart count with thousands separators, not the public watch-page counter and not a label YouTube sent.

`regions` are 2-letter country codes. The worldwide chart is not an input. An unsupported country can come back empty or failed. No country other than the US was fetched during this build. The EU consent cookie is sent on the charts request; an EU region was not fetched.

# Actor input Schema

## `regions` (type: `array`):

ISO country codes, one per line (US, GB, DE, IN, BR, JP). One request per region per chart. UK is read as GB. Not the worldwide chart.

## `charts` (type: `array`):

Which YouTube Charts to fetch. Trending videos is the live music chart (about 30 rows, no view count, no period). Top videos is top music videos (weekly or daily). Top songs and top artists are weekly only; a daily run still stores weekly for those two.

## `period` (type: `string`):

Weekly or daily, where that chart publishes one. Top songs and top artists are weekly only. Trending videos has no period. Default weekly.

## `maxRows` (type: `integer`):

How many entries to keep per chart, in chart order. Rank stays the chart rank. Weekly charts are 100 rows; trending videos is about 30.

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

Apify Proxy, datacenter by default (leave proxy groups empty). The run rotates its session on HTTP 429 or 5xx. Residential is optional.

## Actor input object example

```json
{
  "regions": [
    "US"
  ],
  "charts": [
    "trending-videos",
    "top-videos"
  ],
  "period": "weekly",
  "maxRows": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `charts` (type: `string`):

One row per chart entry (chart, region, period, rank, title, artist, channel, views, URL).

## `csv` (type: `string`):

All rows as CSV.

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

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tallyrake/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/5UbftA1vFegaihGaU/builds/gyMTRrVQo4ahtvMOL/openapi.json
