Overview
The Problem
Section titled “The Problem”Building an application that aggregates live streaming data across YouTube, Twitch, and TwitCasting means dealing with three completely different APIs. Each has its own authentication scheme, rate limiting model, data format, and URL structure.
| YouTube Data API v3 | Twitch Helix API | TwitCasting API v2 | |
|---|---|---|---|
| Auth | API Key (query parameter) | OAuth2 Client Credentials | Basic Auth (base64) |
| Rate Limiting | Quota-based (10,000 units/day) | Token bucket (header-driven) | Token bucket (60 req/60s) |
| Cost Model | Per-endpoint cost (1–100 units) | Flat (1 req = 1 token) | Flat (1 req = 1 token) |
| Live vs. Archive | Same video ID | Different video IDs | Same movie ID |
| Channel ID | UC... prefix, @handle | Login name | User ID |
Common Pain Points
Section titled “Common Pain Points”- YouTube quota — The daily 10,000-unit quota runs out fast. A single
search.listcall costs 100 units. Without local tracking, you’ll get silent 403 errors mid-day. - Twitch OAuth — Tokens expire and must be refreshed before expiry. Missing a refresh means 401 errors in production.
- TwitCasting rate limits — Only 60 requests per minute. Without a proper token bucket, you’ll hit 429 errors under any moderate load.
- Different data models — A “video” on YouTube, a “VOD” on Twitch, and a “movie” on TwitCasting are conceptually the same thing but have completely different JSON shapes and field names.
How unified-live Solves This
Section titled “How unified-live Solves This”import { UnifiedClient } from "@unified-live/core";import { createYouTubePlugin } from "@unified-live/youtube";import { createTwitchPlugin } from "@unified-live/twitch";import { createTwitCastingPlugin } from "@unified-live/twitcasting";
const client = UnifiedClient.create({ plugins: [ createYouTubePlugin({ apiKey: process.env.YOUTUBE_API_KEY! }), createTwitchPlugin({ clientId: process.env.TWITCH_CLIENT_ID!, clientSecret: process.env.TWITCH_CLIENT_SECRET!, }), createTwitCastingPlugin({ clientId: process.env.TWITCASTING_CLIENT_ID!, clientSecret: process.env.TWITCASTING_CLIENT_SECRET!, }), ],});
// One interface — the SDK handles auth, rate limits, and data normalizationconst yt = await client.resolve("https://www.youtube.com/watch?v=abc123");const tw = await client.resolve("https://www.twitch.tv/videos/123456");const tc = await client.resolve("https://twitcasting.tv/user/movie/789");
// All return the same Content typeconsole.log(yt.title); // stringconsole.log(tw.platform); // "twitch"console.log(tc.type); // "broadcast" | "archive"What the SDK Handles for You
Section titled “What the SDK Handles for You”| Concern | How unified-live handles it |
|---|---|
| Authentication | API key injection (YouTube), OAuth2 auto-refresh (Twitch), Basic auth encoding (TwitCasting) |
| Rate Limiting | Local quota tracking with QuotaExhaustedError (YouTube), token bucket with header parsing (Twitch), fixed token bucket (TwitCasting) |
| Retries | Exponential backoff for 429/5xx, token refresh on 401 |
| Data Normalization | All platforms map to unified Content, Channel, Broadcast, Archive types |
| URL Resolution | Auto-detects platform from URL, supports multiple URL formats per platform |
| Observability | OpenTelemetry spans and metrics for every API call (zero overhead when OTel is not configured) |
Feature Matrix
Section titled “Feature Matrix”| Feature | YouTube | Twitch | TwitCasting |
|---|---|---|---|
| Get content by URL | Yes | Yes | Yes |
| Get content by ID | Yes | Yes | Yes |
| List broadcasts | Yes | Yes | Yes |
| List archives (pagination) | Yes | Yes | Yes |
| Get channel info | Yes | Yes | Yes |
| Archive resolution | Yes | Yes | Yes |
| Search | Yes | Yes | Yes |
| Clips | No | Yes | No |
| Batch get contents | Yes | Yes | Yes* |
| Batch get broadcasts | Yes* | Yes | Yes* |
| Batch get channels | Yes | Yes* | Yes* |
| Batch get clips | No | Yes | No |
| Cross-platform broadcasts | Yes | Yes | Yes |
| Cross-platform search | Yes | Yes | Yes |
| OpenTelemetry traces & metrics | Yes | Yes | Yes |
* Supported via automatic per-item fallback (no native batch API)
Official API Documentation
Section titled “Official API Documentation”- YouTube Data API v3 — Google’s video platform API (SDK targets v3)
- Twitch Helix API — Twitch’s current REST API (SDK targets Helix, the current API)
- TwitCasting API v2 — TwitCasting’s REST API (SDK targets v2)
Next Steps
Section titled “Next Steps”- Getting Started — Install and run your first query
- Core Concepts — Content, Channel, and the type system
- Examples — Practical code recipes