Code Examples & Integration

    Integrate StreamVault into your application with the REST API, embed codes, and direct HLS playback.

    JavaScript

    Node.js & browser SDK

    Coming soon

    React

    React component library

    Coming soon

    Python

    Python SDK

    Coming soon

    Official client packages are in the works. In the meantime, the REST API works from any language with an HTTP client — the examples below cover JavaScript and Python without any dependency beyond what ships with your runtime.

    JavaScript

    Works in Node.js 18+ and every modern browser using the built-in fetch. Keep your API key server-side — never ship it in browser code.

    javascript
    const BASE = 'https://api.streamvault.one/v1';
    const headers = {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json',
    };
    
    // List videos
    const { videos } = await fetch(`${BASE}/videos`, { headers }).then(r => r.json());
    
    // Get a single video
    const video = await fetch(`${BASE}/videos/VIDEO_ID`, { headers }).then(r => r.json());
    console.log(video.title, video.iframeLink);
    
    // Upload via URL
    const uploaded = await fetch(`${BASE}/videos`, {
      method: 'POST',
      headers,
      body: JSON.stringify({
        url: 'https://example.com/video.mp4',
        title: 'My Video',
      }),
    }).then(r => r.json());
    
    // Update a video
    await fetch(`${BASE}/videos/VIDEO_ID`, {
      method: 'PATCH',
      headers,
      body: JSON.stringify({ title: 'Updated Title' }),
    });
    
    // Poll encoding status after upload
    const status = await fetch(`${BASE}/videos/VIDEO_ID/status`, { headers }).then(r => r.json());
    
    // Delete a video
    await fetch(`${BASE}/videos/VIDEO_ID`, { method: 'DELETE', headers });

    Python

    Using the requests library (pip install requests):

    python
    import requests
    
    BASE = "https://api.streamvault.one/v1"
    HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
    
    # List videos
    videos = requests.get(f"{BASE}/videos", headers=HEADERS).json()
    for video in videos["videos"]:
        print(video["title"], video["status"])
    
    # Upload via URL
    video = requests.post(
        f"{BASE}/videos",
        headers=HEADERS,
        json={"url": "https://example.com/video.mp4", "title": "My Video"},
    ).json()
    
    # Poll encoding status
    status = requests.get(f"{BASE}/videos/{video['id']}/status", headers=HEADERS).json()
    print(status)
    
    # Delete a video
    requests.delete(f"{BASE}/videos/{video['id']}", headers=HEADERS)

    Embed Codes

    Every video's embed code is also available in the dashboard under the video's Embed Code option — including your verified custom domain when one is connected.

    Standard iframe Embed

    html
    <iframe
      src="https://streamvault.one/embed/VIDEO_ID"
      width="640"
      height="360"
      frameborder="0"
      allow="encrypted-media; fullscreen; picture-in-picture"
      allowfullscreen>
    </iframe>

    Responsive Embed

    html
    <div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
      <iframe
        src="https://streamvault.one/embed/VIDEO_ID"
        style="position:absolute;top:0;left:0;width:100%;height:100%;"
        frameborder="0"
        allow="encrypted-media; fullscreen; picture-in-picture"
        allowfullscreen>
      </iframe>
    </div>

    HLS Direct Playback

    For native apps or a fully custom player, load the HLS manifest directly. Safari plays HLS natively; other browsers can use hls.js:

    javascript
    // Using hls.js for direct HLS playback
    import Hls from 'hls.js';
    
    const video = document.getElementById('video');
    const hls = new Hls();
    
    hls.loadSource('https://api.streamvault.one/v1/play/VIDEO_ID/master.m3u8');
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED, () => {
      video.play();
    });

    A mobile-friendly manifest URL is also available per video in the dashboard (/v1/apps/hls/{key}.m3u8). Note: domain allowlists and access rules configured for the video apply to manifest requests as well.

    Embedding in your LMS

    The responsive iframe above works in every major course platform. Platform notes:

    Allowed Domains is optional. Leave it empty and your videos play on any site. To limit playback to your own site, add its domain under Settings → Allowed Domains — plain domain names such as yourschool.com, without https:// — and add every address your students use. Once the list has an entry, a site that is not on it shows "Video unavailable — This video cannot be played on this domain".

    WordPress

    Add a Custom HTML block and paste the responsive embed. With LearnDash/LifterLMS, paste into the lesson content field. Optional: add your site's domain (for example yoursite.com) to Allowed Domains to limit playback to it.

    Teachable

    In the lesson editor choose Add HTML and paste the embed. Optional: to limit playback to your school, add both yourschool.teachable.com and your custom domain to Allowed Domains.

    Thinkific

    Use a Text lesson → source/HTML view → paste the embed. Optional: add both yourschool.thinkific.com and your custom domain to Allowed Domains.

    Kajabi

    Add a Custom Code block in the lesson and paste the embed. Optional: add both yoursite.mykajabi.com and your custom domain to Allowed Domains.

    Moodle

    In the HTML editor toggle source mode (< >) and paste the embed. Optional: add your Moodle site's domain to Allowed Domains.

    Tip: the account list (Settings → Allowed Domains) covers every video in your account at once. A single video can also have its own list in its Video Settings, and the player allows a site that is on either list. Domain lists set on a project through the API are stored, but the player does not apply them — use the account list or a video's own list.