YouTube Trending API

Merrni videot "më të popullarizuara" për çdo vend ose kategori në kohë reale.

Çfarë mund të bëni?
Merrni rrjedhën ditore të trendeve

Tërhiqni listën zyrtare "Më të Popullarizuarat" direkt nga YouTube.

Filtroni sipas çdo vendi

Specifikoni çdo kod vendi ISO-3166 (US, GB, IN...).

Opsione kategorish dhe kufiri

Ngushtoni në Muzikë (10), Lojëra (20) e më shumë, maks 50 rezultate.

Provo drejtpërdrejt
99.9 % Koha aktive
80.9ms Përgjigje
20 req/s
0.01 Kredite / kërkesë

Trending List


POST https://api.yeb.to/v1/youtube/trending
ParametriLlojiI detyrueshëmPërshkrimi
api_key string po Your API key
country string opsional ISO-3166 code (default US)
category int opsional YouTube category ID (e.g. 10 = Music)
limit int opsional 1-50 results (default 20)

Shembull

curl -X POST https://api.yeb.to/v1/youtube/trending \
  -H "Content-Type: application/json" \
  -d '{
  "api_key":  "YOUR_KEY",
  "country":  "GB",
  "category": "10",
  "limit":    25
}'

Shembull përgjigje

{
  "data": {
    "country":     "GB",
    "category":    "10",
    "cnt_results": 1,
    "videos": [
      {
        "id":           "abc123XYZ",
        "title":        "Top UK Hit 2025",
        "description":  "Official video…",
        "channelId":    "UCmusic",
        "channelTitle": "HitsNow",
        "publishedAt":  "2025-07-06T17:01:02Z",
        "categoryId":   "10",
        "durationISO":  "PT3M12S",
        "viewCount":    4500000,
        "likeCount":    128000,
        "commentCount": 9800,
        "thumb":        "https://i.ytimg.com/vi/abc123XYZ/hqdefault.jpg"
      }
    ]
  }
}
{"error":"Invalid country code. Use ISO 3166-1 alpha-2 format.","code":400}

Kodet e përgjigjes

KodiPërshkrimi
200 SuccessKërkesa u përpunua me sukses.
400 Bad RequestVërtetimi i hyrjes dështoi.
401 UnauthorizedÇelësi API mungon / është i gabuar.
403 ForbiddenÇelësi joaktiv ose i palejuar.
429 Rate LimitShumë kërkesa.
500 Server ErrorDështim i papritur.

Trending List

youtube/trending 0.0100 credits

Parameters

API Key
body · string · required
Country
body · string
Category
body · string
Limit
body · string

Code Samples


                
                
                
            

Response

Status:
Headers

                
Body

                

YouTube Trending API — Practical Guide

A hands-on guide to building “what’s hot now” experiences with YouTube Trending: when to use it, the few parameters that matter, how to read the payload, and how to turn results into cards, playlists, and editorial blocks.

#What YouTube Trending solves

youtube/trending gives a live snapshot of the most popular videos per country, optionally focused on a specific YouTube category (e.g., 10 = Music). Use it for landing pages, auto-curated playlists, “Top Today” widgets, and weekly editorial picks.

#Endpoint & when to use it

  • Best for: Country dashboards, “New & Hot” rows, music-only charts (category=10).
  • Output: Compact list of videos with id, title, channelId/channelTitle, publishedAt, categoryId, durationISO, counts, and a ready-to-use thumb.
  • Tip: Cache per country for 5–10 minutes to reduce feed jitter and API costs.

#Quick start

# GB Music — Top 25
curl -X POST "https://api.yeb.to/v1/youtube/trending" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <YOUR_API_KEY>" \
  -d '{
    "country":  "GB",
    "category": "10",
    "limit":    25
  }'
# US default — Mixed categories, 12 items
curl -X POST "https://api.yeb.to/v1/youtube/trending" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <YOUR_API_KEY>" \
  -d '{ "limit": 12 }'

#Parameters that actually matter

ParamTypeRequiredPractical guidance
api_key string Yes Your API credential. Keep it server-side or use a signed token at the edge.
country string No ISO-3166-1 alpha-2 (e.g., US, GB, DE). Defaults to US. Match your site’s locale.
category int No YouTube category ID. Use 10 for Music. See the YouTube ID reference.
limit int No 1–50 (default 20). Trim to your UI grid (e.g., 8, 12, 24).

#Reading & acting on responses

{
  "data": {
    "country": "GB",
    "category": "10",
    "cnt_results": 1,
    "videos": [
      {
        "id":           "abc123XYZ",
        "title":        "Top UK Hit 2025",
        "description":  "Official video…",
        "channelId":    "UCmusic",
        "channelTitle": "HitsNow",
        "publishedAt":  "2025-07-06T17:01:02Z",
        "categoryId":   "10",
        "durationISO":  "PT3M12S",
        "viewCount":    4500000,
        "likeCount":    128000,
        "commentCount": 9800,
        "thumb":        "https://i.ytimg.com/vi/abc123XYZ/hqdefault.jpg"
      }
    ]
  }
}
  • id — YouTube Video ID. Build links: https://www.youtube.com/watch?v={id}.
  • channelId — Channel ID for badges or deep links: https://www.youtube.com/channel/{channelId}.
  • thumb — Ready “high” thumbnail. Derive sizes via i.ytimg.com/vi/{id}/….
  • durationISO — ISO-8601 (PT#M#S). Convert to mm:ss labels for cards.
  • publishedAt — UTC timestamp. Show “NEW” if < 72h old.
  • viewCount — Snapshot for social proof; trending is volatile, don’t over-sort by it alone.
PHP helper — ISO-8601 duration → mm:ss
$int = new DateInterval('PT3M12S'); $sec = $int->h*3600 + $int->i*60 + $int->s; $label = sprintf('%02d:%02d', floor($sec/60), $sec%60);

#Practical recipes

  • Music-only grid: Call with {"country":"DE","category":10,"limit":12}. Render thumb, title, channel, mm:ss, and a small views chip.
  • Weekly editorial: Cache by country for 7 days, but refresh every hour to catch breakouts; pin manually selected IDs on top.
  • Playlist builder: De-dupe by channelId to avoid stacking multiple uploads from the same channel.
  • Edge caching: Key on country + category; TTL 300–600s keeps UIs stable without feeling stale.

#YouTube IDs you’ll work with

FieldWhat it isHow to use
id (Video ID) 11-char video identifier Watch URL: https://www.youtube.com/watch?v={id} · Thumbs: https://i.ytimg.com/vi/{id}/hqdefault.jpg
channelId Channel identifier Channel URL: https://www.youtube.com/channel/{channelId}
categoryId Numeric category See common IDs below; 10 = Music

#Common YouTube Category IDs

IDCategory
1Film & Animation
2Autos & Vehicles
10Music
17Sports
20Gaming
22People & Blogs
23Comedy
24Entertainment
25News & Politics
26Howto & Style
27Education
28Science & Technology
29Nonprofits & Activism

Availability of categories can vary by region; 10 is universally safe for music use-cases.

#Errors & troubleshooting

  • 400 "Invalid country code. Use ISO 3166-1 alpha-2 format." — Two uppercase letters (e.g., US, GB).
  • 400 "Invalid category. Must be a numeric YouTube category ID." — Provide an integer like 10.
  • 502 "YouTube API error: …" — Upstream hiccup. Retry with exponential backoff (1s → 2s → 4s) and respect quotas.

#API Changelog (youtube/trending)

2026-03-07
Field guidance added. Practical notes for id, channelId, durationISO, and thumb; added YouTube ID reference section.
2026-03-07
Category docs. Clarified category=10 for Music and listed common Category IDs for quick selection.
2026-02-21
Unified wrapper. Standardized the top-level payload to {"data":{...}} and added cnt_results.
2026-02-14
Error surface. Consistent 400 validation (country, category) and 502 for upstream YouTube failures.

Pyetje të bëra shpesh

YouTube vetë e rifreskon listën afërsisht çdo 15 minuta; API-ja shfaq çdo gjë që është aktive në momentin e kërkesës.

Ato janë numerike: 10 = Muzikë, 17 = Sport, 20 = Lojëra, 24 = Argëtim, etj. Shihni dokumentacionin e YouTube Data API për tabelën e plotë.

Po. Çdo kërkesë, edhe ato që rezultojnë në gabime, konsumon kredite. Kreditet tuaja janë të lidhura me numrin e kërkesave, pavarësisht suksesit ose dështimit. Nëse gabimi shkaktohet qartë nga një problem i platformës në anën tonë, do të rivendosim kreditet e prekura (pa rimbursime në para të gatshme).

Na kontaktoni në [email protected]. I marrim komentet seriozisht—nëse raporti juaj i defektit ose kërkesa për veçori është e arsyeshme, mund ta rregullojmë ose përmirësojmë API-në shpejt dhe t'ju japim 50 kredite falas si faleminderit.

Varet nga API-ja dhe ndonjëherë edhe nga endpoint-i. Disa endpoint-e përdorin të dhëna nga burime të jashtme, të cilat mund të kenë kufij më të rreptë. Gjithashtu zbatojmë kufij për të parandaluar abuzimin dhe për të mbajtur platformën tonë të qëndrueshme. Kontrolloni dokumentacionin për kufirin specifik të çdo endpoint-i.

Operojmë me një sistem kreditesh. Kreditet janë njësi të parapaguara, jo të rimbursueshme që i shpenzoni në thirrje API dhe mjete. Kreditet konsumohen sipas FIFO (më të vjetrat së pari) dhe janë të vlefshme për 12 muaj nga data e blerjes. Paneli tregon çdo datë blerjeje dhe skadimin e saj.

Po. Të gjitha kreditet e blera (përfshirë balancat fraksionale) janë të vlefshme për 12 muaj nga blerja. Kreditet e papërdorura skadojnë automatikisht dhe fshihen përgjithmonë në fund të periudhës së vlefshmërisë. Kreditet e skaduara nuk mund të rivendosen ose konvertohen në para të gatshme ose vlerë tjetër. Rregulli kalimtar: kreditet e blera para 22 shtatorit 2025 trajtohen si të blera më 22 shtator 2025 dhe skadojnë më 22 shtator 2026 (përveç nëse një skadim më i hershëm u deklarua gjatë blerjes).

Po—brenda periudhës së tyre të vlefshmërisë. Kreditet e papërdorura mbeten të disponueshme dhe barten nga muaji në muaj derisa të skadojnë 12 muaj pas blerjes.

Kreditet janë jo të rimbursueshme. Blini vetëm atë që ju duhet—gjithmonë mund të rimbushni më vonë. Nëse një gabim i platformës shkakton një debitim të dështuar, mund të rivendosim kreditet e prekura pas hetimit. Asnjë rimbursim në para të gatshme.

Çmimet janë caktuar në kredite, jo në dollarë. Çdo endpoint ka koston e vet—shikoni stemën "Kredite / kërkesë" më lart. Gjithmonë do të dini saktësisht sa po shpenzoni.
← Kthehu te API-të