YouTube Trending
Structured YouTube data: send country_code. Cursor-paginated, 1 credit per successful call.
Overview
Section titled “Overview”Call GET /api/v2/youtube-trending/ with country_code. The results are in data.videos; send data.next_cursor back as cursor to get the next page. 2 optional parameters refine the call (see Parameters).
Request
Section titled “Request”curl -G "https://api.scrapier.io/api/v2/youtube-trending/" \ -H "X-API-Key: YOUR_API_KEY" \ --data-urlencode "country_code=US" \ --max-time 210const params = new URLSearchParams({ country_code: "US" });
const res = await fetch(`https://api.scrapier.io/api/v2/youtube-trending/?${params}`, { headers: { "X-API-Key": "YOUR_API_KEY" }, signal: AbortSignal.timeout(210_000),});const body = await res.json();if (!res.ok) throw new Error(body.error ?? body.detail ?? `HTTP ${res.status}`);
console.log(body.data.videos);import requests
resp = requests.get( "https://api.scrapier.io/api/v2/youtube-trending/", headers={"X-API-Key": "YOUR_API_KEY"}, params={"country_code": "US"}, timeout=210,)body = resp.json()if not resp.ok: raise RuntimeError(body.get("error") or body.get("detail"))
print(body["data"]["videos"])curl -X POST "https://api.scrapier.io/api/v2/youtube-trending/" \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"country_code":"US"}' \ --max-time 210Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X-API-Key header | string | yes | — | Your API key from the dashboard. |
country_code | string | yes | e.g. US | Two-letter ISO country code (e.g., US, BD, IN, GB). Required on first call; ignored when cursor is supplied. |
cursor | string | no | — | Pagination cursor returned in the previous response's next_cursor. Pass it back unchanged to fetch the next page. When next_cursor is null, you have reached the last page. |
content_type | string | no | music | Trending list: music (trending music videos, 30; regions without that chart fall back to daily top music videos) | movies (trending trailers, 30) | top_music_videos (100) | gaming | sports | news | live | learning | fashion. Invalid value -> 400. Locked into the cursor. |
Advanced
| Name | Type | Default | Description |
|---|---|---|---|
use_proxy | boolean | true | Route the request through Scrapier's residential proxy pool. Default: true. Leave as is unless support tells you otherwise. |
raw_data | boolean | false | When true, the response carries the full raw upstream payload(s) the scraper received (GraphQL / JSON API bodies, HTML, embedded JSON-LD -- exactly as the platform returned them) under raw_responses, in place of the formatted items. When false (default) you get the formatted output. Pagination (cursor / next_cursor) works the same in both modes. |
Response
Section titled “Response”{ "success": true, "data": { "country_code": "US", "content_type": "music", "page": 1, "page_size": 25, "videos": [ { "type": "video", "id": "V-uIp-WuD60", "video_id": "V-uIp-WuD60", "title": "Patient Zero", "status": "OK", "url": "https://www.youtube.com/watch?v=V-uIp-WuD60", "description": "Provided to YouTube by Universal Music Group\n\nPatient Zero · Taylor Swift\n\nThe Life of a Showgirl: The Encore\n\n℗ 2026 Taylor Swift\n\nReleased on: 2026-09-25\n\nCom", "duration": 226, "views": "6722880", "view_count": 6722880, "likes": "95077", "like_count": 95077, "comments": null, "channel": { "id": "UCPC0L1d253x-KuMNwa05TpA", "name": "Taylor Swift - Topic", "handle": null, "url": "https://www.youtube.com/channel/UCPC0L1d253x-KuMNwa05TpA", "subscriber_count": null, "thumbnails": [], "badges": [] }, "channel_id": "UCPC0L1d253x-KuMNwa05TpA", "channel_name": "Taylor Swift - Topic", "keywords": [ "Taylor Swift", "テイラースウィフト", "テイラー・スウィフト" ], "is_ratings_allowed": true, "is_live": false, "is_live_content": false, "is_family_safe": true, "category": "Music", "is_private": false, "is_exclusive": false, "thumbnails": [ { "url": "https://i.ytimg.com/vi/V-uIp-WuD60/maxresdefault.jpg", "width": 1920, "height": 1080 } ], "embed_url": "https://www.youtube.com/embed/V-uIp-WuD60", "is_embeddable": true, "is_unlisted": false, "publish_date": "2026-09-24T21:02:10-07:00", "published_at": "2026-09-24T21:02:10-07:00", "relative_date": null, "upload_date": "2026-09-24T21:02:10-07:00", "trending_position": 1, "previous_position": null, "periods_on_chart": null, "chart_view_count": null, "artists": [ "Taylor Swift" ], "release_date": "2026-09-24", "country_code": "US", "content_type": "music", "source": "youtube_charts", "chart_type": "TRENDING_VIDEOS", "enriched": true, "scraped_at": "2026-10-03T04:28:40.122Z" } ], "next_cursor": "eyJjdCI6Im11c2ljIiwiaSI6IlVTIiwicCI6Miwic24iOlsiMGExYjJjIl19" }}Bad input. The exact message varies by endpoint.
{ "success": false, "error": "…"}Balance below the endpoint’s price.
{ "error": "Insufficient credits. Buy more to scrape more.", "balance": 1, "required": 2}Invalid or unknown API key.
{ "detail": "Authentication service unavailable or invalid API key."}Throttled — wait for Retry-After.
{ "detail": "Request was throttled. Expected available in N seconds."}Sample from the live catalog; arrays trimmed to 3 items. Results are in data.videos.
Response fields
Section titled “Response fields”| Field | Type | Example | Description |
|---|---|---|---|
country_code | string | US | — |
content_type | string | music | — |
page | integer | 1 | — |
page_size | integer | 25 | — |
videos | array | [1 item] | The results. |
next_cursor | string | eyJjdCI6Im11c2ljIiwiaSI6IlVTIiwicCI6Miwic24iO… | Pass back as cursor for the next page. null on the last page. |
videos[].type | string | video | — |
videos[].id | string | V-uIp-WuD60 | — |
videos[].video_id | string | V-uIp-WuD60 | — |
videos[].title | string | Patient Zero | — |
videos[].status | string | OK | — |
videos[].url | string | https://www.youtube.com/watch?v=V-uIp-WuD60 | — |
videos[].description | string | Provided to YouTube by Universal Music Group … | — |
videos[].duration | integer | 226 | — |
videos[].views | string | 6722880 | — |
videos[].view_count | integer | 6722880 | — |
videos[].likes | string | 95077 | — |
videos[].like_count | integer | 95077 | — |
videos[].comments | null | null | — |
videos[].channel | object | {…} | — |
videos[].channel_id | string | UCPC0L1d253x-KuMNwa05TpA | — |
videos[].channel_name | string | Taylor Swift - Topic | — |
videos[].keywords | array | [5 items] | — |
videos[].is_ratings_allowed | boolean | true | — |
videos[].is_live | boolean | false | — |
videos[].is_live_content | boolean | false | — |
videos[].is_family_safe | boolean | true | — |
videos[].category | string | Music | — |
videos[].is_private | boolean | false | — |
videos[].is_exclusive | boolean | false | — |
videos[].thumbnails | array | [1 item] | — |
videos[].embed_url | string | https://www.youtube.com/embed/V-uIp-WuD60 | — |
videos[].is_embeddable | boolean | true | — |
videos[].is_unlisted | boolean | false | — |
videos[].publish_date | string | 2026-09-24T21:02:10-07:00 | — |
videos[].published_at | string | 2026-09-24T21:02:10-07:00 | — |
videos[].relative_date | null | null | — |
videos[].upload_date | string | 2026-09-24T21:02:10-07:00 | — |
videos[].trending_position | integer | 1 | — |
videos[].previous_position | null | null | — |
videos[].periods_on_chart | null | null | — |
videos[].chart_view_count | null | null | — |
videos[].artists | array | [1 item] | — |
videos[].release_date | string | 2026-09-24 | — |
videos[].country_code | string | US | — |
videos[].content_type | string | music | — |
videos[].source | string | youtube_charts | — |
videos[].chart_type | string | TRENDING_VIDEOS | — |
videos[].enriched | boolean | true | — |
videos[].scraped_at | string | 2026-10-03T04:28:40.122Z | — |
Pagination
Section titled “Pagination”Pass data.next_cursor back as cursor until it is null. Required inputs are ignored once a cursor is sent. Each page is one billed call. More in Pagination.
const url = "https://api.scrapier.io/api/v2/youtube-trending/";let params = { country_code: "US" };const items = [];
for (let page = 0; page < 10; page++) { // each page is one billed call const res = await fetch(`${url}?${new URLSearchParams(params)}`, { headers: { "X-API-Key": "YOUR_API_KEY" }, signal: AbortSignal.timeout(210_000), }); const body = await res.json(); if (!res.ok) throw new Error(body.error ?? body.detail ?? `HTTP ${res.status}`); const data = body.data; items.push(...(data.videos ?? [])); if (!data.next_cursor) break; // null = last page params = { cursor: data.next_cursor };}import requests
URL = "https://api.scrapier.io/api/v2/youtube-trending/"HEADERS = {"X-API-Key": "YOUR_API_KEY"}params = {"country_code": "US"}items = []
for _ in range(10): # each page is one billed call resp = requests.get(URL, headers=HEADERS, params=params, timeout=210) resp.raise_for_status() data = resp.json()["data"] items.extend(data.get("videos") or []) if not data.get("next_cursor"): # None = last page break params = {"cursor": data["next_cursor"]}Errors
Section titled “Errors”Failed calls are free. Branch on the HTTP status and read the message from error (or detail). Full details in Errors.
| Status | Meaning | Retry? | Charged? |
|---|---|---|---|
400 | Bad or missing input. | No — fix the params | No |
401 / 403 | Missing, invalid or revoked API key. | No — fix the key | No |
402 | Out of credits (body has balance). | No — top up | No |
404 | Unknown endpoint slug. | No — check the slug | No |
429 / 503 | Busy or throttled. | Yes — after Retry-After | No |
5xx | Target site or upstream failure, or timeout. | Yes — with backoff | No |
- Nothing special: send the inputs, read the result.
Related
Section titled “Related”- YouTube Channel Info — Structured YouTube data: send
urls. Single lookup, 1 credit per successful call. - YouTube Channel Live/Streams — Structured YouTube data: send
channels. Cursor-paginated, 1 credit per successful call. - YouTube Channel Video Scraper — Structured YouTube data: send
youtube_channels. Cursor-paginated, 1 credit per successful call. - YouTube Comment Replies — Structured YouTube data: send
continuation_tokens. Cursor-paginated, 1 credit per successful call.