Puede recuperar las estadísticas del canal de YouTube a través de la API de búsqueda de Scavio configurando la plataforma en youtube. Esto evita el sistema de cuotas de YouTube Data API v3 y devuelve recuentos de suscriptores, recuentos de visualizaciones y videos recientes en una sola solicitud.
Requisitos previos
- Python 3.9+
- Clave API de Scavio
Guia paso a paso
Paso 1: Buscar un canal de YouTube
Busque el nombre del canal con plataforma: youtube para obtener estadísticas a nivel de canal.
import requests
API_KEY = "your-scavio-api-key"
def get_channel_stats(channel_name: str) -> dict:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={
"query": channel_name,
"platform": "youtube",
"num_results": 5
},
headers={"x-api-key": API_KEY},
timeout=20
)
r.raise_for_status()
return r.json()
data = get_channel_stats("Fireship")
results = data.get("organic_results", [])
for r in results:
print(r.get("title"), r.get("channel"), r.get("views"))Paso 2: Buscar videos recientes de un canal
Agregue el nombre del canal más un tema para obtener listados de videos relevantes con recuentos de vistas.
def get_channel_videos(channel_name: str, topic: str = "") -> list:
query = f"{channel_name} {topic}".strip()
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": query, "platform": "youtube", "num_results": 20},
headers={"x-api-key": API_KEY},
timeout=20
)
r.raise_for_status()
results = r.json().get("organic_results", [])
return [
{
"title": v.get("title"),
"url": v.get("link"),
"views": v.get("views"),
"duration": v.get("duration"),
"published": v.get("published_date"),
"channel": v.get("channel")
}
for v in results
if channel_name.lower() in (v.get("channel") or "").lower()
]Paso 3: Cree un panel de terminal simple
Muestra estadísticas de múltiples canales en una tabla formateada.
CHANNELS = ["Fireship", "Theo - t3.gg", "ThePrimeagen", "Web Dev Simplified"]
print(f"{'Channel':<25} {'Recent Videos Found':>20}")
print("-" * 50)
for channel in CHANNELS:
videos = get_channel_videos(channel)
total_views = sum(
int(v["views"].replace(",", "").replace(" views", ""))
for v in videos
if v.get("views") and v["views"].replace(",", "").replace(" views", "").isdigit()
)
print(f"{channel:<25} {len(videos):>10} videos found")Ejemplo en Python
import requests
import re
from datetime import date
API_KEY = "your-scavio-api-key"
def parse_views(views_str: str) -> int:
if not views_str:
return 0
cleaned = re.sub(r"[^0-9KMB.]", "", views_str.upper())
if "B" in cleaned:
return int(float(cleaned.replace("B", "")) * 1_000_000_000)
if "M" in cleaned:
return int(float(cleaned.replace("M", "")) * 1_000_000)
if "K" in cleaned:
return int(float(cleaned.replace("K", "")) * 1_000)
return int(cleaned) if cleaned.isdigit() else 0
def get_channel_videos(channel_name: str, n: int = 20) -> list:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": channel_name, "platform": "youtube", "num_results": n},
headers={"x-api-key": API_KEY},
timeout=20
)
r.raise_for_status()
results = r.json().get("organic_results", [])
return [
{"title": v.get("title"), "url": v.get("link"),
"views": parse_views(v.get("views","")),
"views_raw": v.get("views"), "duration": v.get("duration"),
"published": v.get("published_date"), "channel": v.get("channel")}
for v in results
]
def channel_dashboard(channels: list) -> None:
print(f"YouTube Dashboard — {date.today()}")
print("=" * 70)
for ch in channels:
videos = get_channel_videos(ch)
if not videos:
print(f"{ch}: no data")
continue
total_views = sum(v["views"] for v in videos)
top = sorted(videos, key=lambda v: v["views"], reverse=True)[:1]
print(f"\n{ch}")
print(f" Videos found: {len(videos)} | Total tracked views: {total_views:,}")
if top:
print(f" Top video: {top[0]['title'][:60]} ({top[0]['views_raw']})")
if __name__ == "__main__":
channel_dashboard(["Fireship", "Theo - t3.gg", "ThePrimeagen"])Ejemplo en JavaScript
const API_KEY = 'your-scavio-api-key';
async function getChannelVideos(channelName, n = 20) {
const res = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': API_KEY },
body: JSON.stringify({ query: channelName, platform: 'youtube', num_results: n })
});
const data = await res.json();
return data.organic_results ?? [];
}
const channels = ['Fireship', 'Theo - t3.gg'];
for (const ch of channels) {
const videos = await getChannelVideos(ch);
console.log(`\n${ch}: ${videos.length} videos found`);
for (const v of videos.slice(0, 3)) {
console.log(` ${v.title?.slice(0, 60)} | ${v.views}`);
}
}Salida esperada
YouTube Dashboard - 2026-05-22
======================================================================
Fireship
Videos found: 18 | Total tracked views: 24,892,441
Top video: Every JavaScript Framework Explained in 30 Seconds (4.2M views)
Theo - t3.gg
Videos found: 15 | Total tracked views: 12,441,209
Top video: I was wrong about React Server Components (2.1M views)