mirror of
https://gitlab.com/vyla-entertainment/documentation.git
synced 2026-11-09 20:17:20 -05:00
194 lines
11 KiB
HTML
194 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="en" class="dark">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>SDK quickstart — Vyla</title>
|
|
<meta name="description" content="Install Vyla SDK, resolve a source, and build a safe server-side integration." />
|
|
<meta name="keywords"
|
|
content="Vyla SDK, SDK quickstart, Node.js SDK, server-side integration, stream resolution, API integration" />
|
|
<link rel="canonical" href="https://vyla.cc/sdk-quickstart.html" />
|
|
|
|
<!-- Open Graph / Facebook -->
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:url" content="https://vyla.cc/sdk-quickstart.html" />
|
|
<meta property="og:title" content="SDK quickstart — Vyla" />
|
|
<meta property="og:description"
|
|
content="Install Vyla SDK, resolve a source, and build a safe server-side integration." />
|
|
<meta property="og:image" content="https://vyla.cc/assets/images/thumbnail.png" />
|
|
<meta property="og:site_name" content="Vyla" />
|
|
|
|
<!-- Twitter -->
|
|
<meta property="twitter:card" content="summary_large_image" />
|
|
<meta property="twitter:url" content="https://vyla.cc/sdk-quickstart.html" />
|
|
<meta property="twitter:title" content="SDK quickstart — Vyla" />
|
|
<meta property="twitter:description"
|
|
content="Install Vyla SDK, resolve a source, and build a safe server-side integration." />
|
|
<meta property="twitter:image" content="https://vyla.cc/assets/images/thumbnail.png" />
|
|
<meta property="twitter:site" content="@vylaentertainment" />
|
|
|
|
<!-- Additional SEO -->
|
|
<meta name="robots" content="index, follow" />
|
|
<meta name="author" content="Vyla" />
|
|
|
|
<link rel="icon" href="/favicon.ico" />
|
|
<link rel="stylesheet" href="/assets/base.css" />
|
|
<link rel="stylesheet" href="/assets/highlight.css" />
|
|
<link rel="stylesheet" href="/assets/mintlify-overrides.css" />
|
|
|
|
<!-- JSON-LD Structured Data -->
|
|
<script type="application/ld+json">
|
|
{
|
|
"@context": "https://schema.org",
|
|
"@type": "SoftwareApplication",
|
|
"name": "SDK quickstart",
|
|
"description": "Install Vyla SDK, resolve a source, and build a safe server-side integration.",
|
|
"url": "https://vyla.cc/sdk-quickstart.html",
|
|
"applicationCategory": "MultimediaApplication",
|
|
"operatingSystem": "Windows, macOS, Linux, Android, Android TV",
|
|
"offers": {
|
|
"@type": "Offer",
|
|
"price": "0",
|
|
"priceCurrency": "USD"
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="banner">
|
|
<span>Vyla is self-hosted. Run Vyla Home, embed the SDK, or deploy Stream API on infrastructure you control. Rights
|
|
holders can request source removal — <a href="/misc/dmca">DMCA policy</a>.</span>
|
|
<button id="banner-close" onclick="dismissBanner()" aria-label="Dismiss">✕</button>
|
|
</div>
|
|
|
|
<header id="navbar">
|
|
<div class="nav-top">
|
|
<a class="brand" href="/"><img src="/assets/images/logo.png" alt="Vyla" id="brand-logo" loading="lazy"
|
|
fetchpriority="low"></a>
|
|
<button id="search-trigger" type="button" onclick="openSearch()" aria-label="Search"></button>
|
|
<div class="links">
|
|
<button id="theme-toggle" type="button" onclick="toggleThemeMenu(event)" aria-label="Theme"></button>
|
|
</div>
|
|
</div>
|
|
<nav class="tabs">
|
|
<a class="tab-link" href="/">Vyla</a>
|
|
<a class="tab-link" href="/sdk">SDK</a>
|
|
<a class="tab-link active" href="/stream-api/overview">Stream API</a>
|
|
<a class="tab-link" href="/guides/integrations">Resources</a>
|
|
<a class="tab-link" href="/misc/credit">Misc</a>
|
|
</nav>
|
|
</header>
|
|
<div id="layout">
|
|
<nav id="sidebar">
|
|
<div class="group">
|
|
<p class="group-title">Vyla SDK</p>
|
|
<ul>
|
|
<li><a class="" href="/sdk">Sdk</a></li>
|
|
<li><a class="active" href="/sdk-quickstart">Sdk Quickstart</a></li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
<div id="content-col">
|
|
<main class="prose">
|
|
<h1>SDK quickstart</h1>
|
|
<p class="page-description">Install Vyla SDK, resolve a source, and build a safe server-side integration.</p>
|
|
<h2 id="before-you-start">Before you start</h2>
|
|
<p>Vyla SDK is for <strong>server-side Node.js</strong>. It contains provider integrations and makes outbound
|
|
requests from the process where you install it. Do not import it into a browser bundle or expose provider
|
|
results, credentials, or internal source keys directly to untrusted clients.</p>
|
|
<p>You need Node.js 18 or later and, for sources that resolve title metadata, a TMDB API key.</p>
|
|
<h2 id="install-and-initialize">Install and initialize</h2>
|
|
<div class="code-group">
|
|
<div class="code-group-tabs"><button class="code-group-tab active" data-tab-index="0" type="button"
|
|
onclick="cgSwitch(this)">npm</button><button class="code-group-tab" data-tab-index="1" type="button"
|
|
onclick="cgSwitch(this)">pnpm</button><button class="code-group-tab" data-tab-index="2" type="button"
|
|
onclick="cgSwitch(this)">yarn</button></div>
|
|
<div class="code-group-panels">
|
|
<div class="code-group-panel active">
|
|
<pre><code class="hljs language-bash">npm <span class="hljs-built_in">install</span> <span class="hljs-string">@vyla-entertainment/sdk</span></code></pre>
|
|
</div>
|
|
<div class="code-group-panel">
|
|
<pre><code class="hljs language-bash">pnpm <span class="hljs-built_in">install</span> <span class="hljs-string">@vyla-entertainment/sdk</span></code></pre>
|
|
</div>
|
|
<div class="code-group-panel">
|
|
<pre><code class="hljs language-bash">yarn <span class="hljs-built_in">add</span> <span class="hljs-string">@vyla-entertainment/sdk</span></code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<pre><code class="hljs language-js"><span class="hljs-keyword">import</span> <span class="hljs-title class_">VylaSDK</span> <span class="hljs-keyword">from</span> <span class="hljs-string">"@vyla-entertainment/sdk"</span>;
|
|
|
|
<span class="hljs-keyword">const</span> vyla = <span class="hljs-keyword">new</span> <span class="hljs-title class_">VylaSDK</span>({
|
|
<span class="hljs-attr">tmdbApiKey</span>: process.<span class="hljs-property">env</span>.<span class="hljs-property">TMDB_API_KEY</span>,
|
|
<span class="hljs-attr">penguManifest</span>: process.<span class="hljs-property">env</span>.<span class="hljs-property">PENGU_MANIFEST</span>
|
|
});
|
|
</code></pre>
|
|
<div class="callout callout-warning">
|
|
<div class="callout-content">
|
|
<p>Keep <code>TMDB_API_KEY</code> and any deployment configuration in server-side environment variables.
|
|
Never commit them or send them to a client.</p>
|
|
</div>
|
|
</div>
|
|
<h2 id="resolve-a-movie">Resolve a movie</h2>
|
|
<p>First inspect active providers. Provider availability changes over time, so select a key from the running
|
|
configuration instead of hard-coding a placeholder.</p>
|
|
<pre><code class="hljs language-js"><span class="hljs-keyword">const</span> providers = vyla.<span class="hljs-title function_">getSources</span>(<span class="hljs-literal">true</span>);
|
|
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">table</span>(providers.<span class="hljs-title function_">map</span>(<span class="hljs-function">(<span class="hljs-params">{ key, label }</span>) =></span> ({ key, label })));
|
|
|
|
<span class="hljs-keyword">const</span> provider = providers[<span class="hljs-number">0</span>];
|
|
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> vyla.<span class="hljs-title function_">getStream</span>(provider.<span class="hljs-property">key</span>, <span class="hljs-number">155</span>);
|
|
<span class="hljs-keyword">const</span> candidates = result.<span class="hljs-property">allUrls</span> ?? [result];
|
|
|
|
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(candidates.<span class="hljs-title function_">map</span>(<span class="hljs-function">(<span class="hljs-params">{ url, type, quality }</span>) =></span> ({ url, type, quality })));
|
|
</code></pre>
|
|
<p><code>155</code> is a TMDB movie ID. For an episode, include season and episode:</p>
|
|
<pre><code class="hljs language-js"><span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> vyla.<span class="hljs-title function_">getStream</span>(provider.<span class="hljs-property">key</span>, <span class="hljs-number">1396</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>);
|
|
</code></pre>
|
|
<h2 id="make-it-resilient">Make it resilient</h2>
|
|
<p>Provider results are inherently variable: a source can fail, time out, return more than one candidate, or be
|
|
temporarily disabled. In production:</p>
|
|
<ol>
|
|
<li>Probe sources or maintain a recent availability signal before choosing one.</li>
|
|
<li>Give every provider call a request deadline in your application.</li>
|
|
<li>Treat <code>allUrls</code> as fallback candidates, not a guarantee that every URL will play.</li>
|
|
<li>Return only the fields your client needs and validate requests at your own API boundary.</li>
|
|
<li>Cache and rate-limit at your boundary to avoid repeatedly triggering upstream work.</li>
|
|
</ol>
|
|
<pre><code class="hljs language-js"><span class="hljs-keyword">const</span> health = <span class="hljs-keyword">await</span> vyla.<span class="hljs-title function_">probeAllSources</span>();
|
|
<span class="hljs-keyword">const</span> usableKey = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">entries</span>(health).<span class="hljs-title function_">find</span>(<span class="hljs-function">(<span class="hljs-params">[, result]</span>) =></span> result.<span class="hljs-property">ok</span>)?.[<span class="hljs-number">0</span>];
|
|
|
|
<span class="hljs-keyword">if</span> (!usableKey) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">"No providers are currently available"</span>);
|
|
|
|
<span class="hljs-keyword">const</span> stream = <span class="hljs-keyword">await</span> vyla.<span class="hljs-title function_">getStream</span>(usableKey, <span class="hljs-number">155</span>);
|
|
</code></pre>
|
|
<h2 id="next-steps">Next steps</h2>
|
|
<ul>
|
|
<li>Read the complete <a href="/sdk">SDK reference</a> for methods and return shapes.</li>
|
|
<li>Learn provider flags, timeout behavior, and source keys in <a href="/concepts/providers">Providers</a>.
|
|
</li>
|
|
<li>Choose <a href="/stream-api/overview">Stream API</a> only when an SSE HTTP interface better fits your
|
|
client architecture.</li>
|
|
</ul>
|
|
</main>
|
|
<aside id="toc">
|
|
<p class="toc-title">On this page</p>
|
|
<ul>
|
|
<li><a href="#before-you-start">Before you start</a></li>
|
|
<li><a href="#install-and-initialize">Install and initialize</a></li>
|
|
<li><a href="#resolve-a-movie">Resolve a movie</a></li>
|
|
<li><a href="#make-it-resilient">Make it resilient</a></li>
|
|
<li><a href="#next-steps">Next steps</a></li>
|
|
</ul>
|
|
</aside>
|
|
</div>
|
|
</div>
|
|
<footer id="site-footer">
|
|
<a href="https://discord.gg/5eqRhKeywG" target="_blank" rel="noopener">Discord</a>
|
|
<a href="https://gitlab.com/vyla-entertainment/" target="_blank" rel="noopener">GitLab</a>
|
|
</footer>
|
|
<script src="/assets/app.js"></script>
|
|
</body>
|
|
|
|
</html> |