Overview
SwipeCDN stores short vertical videos and delivers them fast. Videos are converted in the uploader's browser into a quality ladder (240p, 360p, 540p, 720p — never above the source) of fMP4/HLS segments with a 1-second first segment, a poster and a tiny inline placeholder, then uploaded straight to storage. Nothing has to run on your servers.
| Credential | Looks like | Where it lives |
|---|---|---|
| Public key | pk_live_… | Web pages (the upload button). Only works from your allowed origins. |
| Secret key | sk_live_… | Your server only. REST API. Shown once. |
| Playback signing key | kid_… + secret | Your server only. Signs viewer tokens for protected videos. |
| Upload token | gvu_… | Short-lived (15 min by default), created for the button or by your server. |
Quickstart: the upload button
- Allow your admin site. Dashboard → API keys → Allowed origins → add the exact origin, e.g.
https://admin.example.com. - Paste the script and the element into the page where your team adds items:
<script src="https://swipecdn.com/v1/button.js" data-key="pk_live_YOUR_PUBLIC_KEY" async></script>
<swipecdn-upload ref="recipe-42" title="Crispy chicken bowl"></swipecdn-upload>- Save the link when the video is ready:
document.addEventListener("swipecdn:ready", (e) => {
const v = e.detail; // { id, ref, title, protected, playback_url, hls, mp4, poster, duration, width, height }
document.querySelector("#video_id").value = v.id;
document.querySelector("#video_url").value = v.playback_url;
});
document.addEventListener("swipecdn:error", (e) => console.warn(e.detail.message));Attributes
| Attribute | Meaning |
|---|---|
ref | Your own ID for the item (up to 120 characters). Returned in callbacks and webhooks. |
title | The video title. Defaults to the file name. |
protected | Pre-tick «Protected video». protected-choice="hidden" hides the checkbox and keeps your choice. |
token-url | Strict mode: a URL on your server that returns {"token":"gvu_…"} created with your secret key. Required when «Only accept upload tokens from my server» is on. |
label | Button text. Default «Upload video». |
multiple | Allow choosing several files. |
Prefer a callback? Put data-callback="onVideoReady" on the script tag and define window.onVideoReady = (video) => ….
script-src https://swipecdn.com, worker-src blob: and connect-src https://cdn.swipecdn.com (plus your storage address if you use your own R2 bucket).Browsers: recent Chrome, Edge, Firefox and Safari with WebCodecs. The button says so if the browser cannot convert video.
Playback links
Every ready video has one public JSON document that tells any player what to load:
GET https://cdn.swipecdn.com/swipecdn/cdn/api/v1/videos/{id}/playback{
"id": "Xq3…", "title": "Crispy chicken bowl", "duration": 14.6, "width": 1080, "height": 1920,
"hls": "…/master.m3u8", // any HLS player (AVPlayer, ExoPlayer, hls.js, Safari)
"mp4": "…/fallback.mp4", // progressive fallback (not for protected videos)
"poster": "…/poster.webp", // the first frame
"lqip": "data:image/webp;base64,…",// tiny blurred placeholder, paint it at once
"encrypted": false,
"renditions": [{ "id": "r1", "width": 240, "height": 426, "bandwidth": 271000, "segs": [1, 2, 2, …] }, …],
"prefetch": { "r1": ["…/index.m3u8", "…/init.mp4", "…/s1.m4s", "…/s2.m4s"] }
}Display it however you like: your own player with hls, a plain <video> with mp4, our feed player, or the hosted watch page https://swipecdn.com/w/{id} (also embeddable: https://swipecdn.com/e/{id} in an <iframe>).
REST API
Base URL https://swipecdn.com/api/v1. Send your secret key as a bearer token, from your server only. JSON in, JSON out.
curl https://swipecdn.com/api/v1/videos \
-H "Authorization: Bearer sk_live_…"| Method | Path | What it does |
|---|---|---|
GET | /videos?limit=50&offset=0&status=ready | List videos, newest first. |
GET | /videos/{id} | One video with its links. |
PATCH | /videos/{id} | Change title, ref or hidden (hidden videos stay playable but leave the public feed). |
DELETE | /videos/{id} | Delete the video and its files. Frees its minutes. |
POST | /upload-tokens | Create an upload token for a browser: { origin?, protected?, ttl_seconds?, max_videos? }. |
POST | /viewer-tokens | Mint a viewer token for a protected video: { video, ttl_seconds?, origin? }. |
GET | /usage | Stored minutes, plan minutes, videos. |
GET | /feed?key=pk_live_… | Public: playback JSON of your visible, unprotected videos (CORS open). For the feed player. |
Create an upload token on your server
Use this for strict mode, or to upload from your own page with the uploader library.
curl -X POST https://swipecdn.com/api/v1/upload-tokens \
-H "Authorization: Bearer sk_live_…" -H "Content-Type: application/json" \
-d '{"origin":"https://admin.example.com","protected":false,"ttl_seconds":900}'
# → { "ok": true, "token": "gvu_…", "expires_at": "…", "upload_api": "https://cdn.swipecdn.com/swipecdn/cdn/api/v1" }protected is optional: true or false forces the choice for every upload made with that token; leave it out to let the person uploading decide with the checkbox.
// on your page, without the button:
import { upload } from "https://cdn.swipecdn.com/swipecdn/cdn/static/ingest/uploader.js";
const { token, upload_api } = await (await fetch("/my-server/swipecdn-token")).json();
const r = await upload(file, { api: upload_api, apiKey: token, encrypt: false, ref: "recipe-42",
onState: (s) => console.log(s.step, s.p) });
console.log(r.id, r.playback);Webhooks
Add HTTPS endpoints in Dashboard → Webhooks. Events:
| Event | When |
|---|---|
video.ready | The video finished uploading and can play. |
video.deleted | A ready video was deleted. |
video.rejected | An upload would have gone over your plan's minutes and was discarded. |
ping | «Send test» in the dashboard. |
POST /your/webhook
webhook-id: msg_2Lr…
webhook-timestamp: 1795612345
webhook-signature: v1,K5o…=
{ "type": "video.ready", "timestamp": "2026-11-25T12:00:00Z",
"data": { "id": "Xq3…", "ref": "recipe-42", "title": "…", "protected": false, "duration": 14.6,
"playback_url": "https://cdn.swipecdn.com/swipecdn/cdn/api/v1/videos/Xq3…/playback", "hls": "…", "mp4": "…", "poster": "…" } }Signatures follow the Standard Webhooks scheme. Verify before trusting the body, and reject timestamps older than 5 minutes:
import crypto from "node:crypto";
// secret = "whsec_…" from the dashboard
function verify(secret, headers, rawBody) {
const id = headers["webhook-id"], ts = headers["webhook-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const want = crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64");
return headers["webhook-signature"].split(" ").some((s) => s === "v1," + want);
}Answer with any 2xx within 10 seconds. Failed deliveries are retried after 30 seconds, 5 minutes and 30 minutes. Use webhook-id to ignore duplicates.
Protected video
Tick Protected video when uploading (dashboard, button, or "protected": true on an upload token). The video is then encrypted with AES-128, and it plays only with a viewer token that your backend issues. Your system decides who may watch and adds any watermark; SwipeCDN provides the encryption, the token check and expiring, origin-bound links.
Be clear about what this is. AES-128 with signed, expiring tokens stops link sharing and casual downloading. It is not DRM, and no web player can fully stop screen recording.
1. Create a playback signing key
Dashboard → API keys → Playback signing keys → Create. Keep the kid and the secret on your server.
2. Mint a viewer token on your server
A standard JWT, HS256, with the claims sub (video ID) and exp (at most 24 h ahead); optional origin binds it to one website. Put the kid in the header.
// Node.js — no library needed
import crypto from "node:crypto";
const KID = "kid_…", SECRET = process.env.SWIPECDN_SIGNING_SECRET; // base64url, from the dashboard
const b64u = (o) => Buffer.from(JSON.stringify(o)).toString("base64url");
export function viewerToken(videoId, { ttl = 3600, origin } = {}) {
const head = b64u({ alg: "HS256", typ: "JWT", kid: KID });
const body = b64u({ sub: videoId, exp: Math.floor(Date.now() / 1000) + ttl, ...(origin ? { origin } : {}) });
const sig = crypto.createHmac("sha256", Buffer.from(SECRET, "base64url")).update(head + "." + body).digest("base64url");
return head + "." + body + "." + sig;
}<?php // PHP
function viewer_token($videoId, $ttl = 3600, $origin = null) {
$kid = 'kid_…'; $secret = base64_decode(strtr(getenv('SWIPECDN_SIGNING_SECRET'), '-_', '+/'));
$b64u = fn($s) => rtrim(strtr(base64_encode($s), '+/', '-_'), '=');
$head = $b64u(json_encode(['alg' => 'HS256', 'typ' => 'JWT', 'kid' => $kid]));
$claims = ['sub' => $videoId, 'exp' => time() + $ttl]; if ($origin) $claims['origin'] = $origin;
$body = $b64u(json_encode($claims));
return "$head.$body." . $b64u(hash_hmac('sha256', "$head.$body", $secret, true));
}No signing code? Ask the API instead, with your secret key:
curl -X POST https://swipecdn.com/api/v1/viewer-tokens -H "Authorization: Bearer sk_live_…" \
-H "Content-Type: application/json" -d '{"video":"Xq3…","ttl_seconds":3600,"origin":"https://app.example.com"}'3. Play
GET https://cdn.swipecdn.com/swipecdn/cdn/api/v1/videos/{id}/playback?token=VIEWER_TOKEN
// the answer is the usual playback JSON; its "hls" link and the key link are valid for at most 15 minutes,
// and only from the token's origin (or your allowed origins). Without a valid token: 401.The web feed player and the Flutter package play protected videos as soon as you give them this JSON. Mobile apps send no web origin; the token alone applies there.
Web feed player
A TikTok-style vertical feed: a pool of three players, priority prefetch of the next videos, start at the lowest quality then climb. About 7 KB gzipped, no framework.
<link rel="stylesheet" href="https://cdn.swipecdn.com/swipecdn/cdn/static/sdk/gv-feed.css">
<script src="https://cdn.swipecdn.com/swipecdn/cdn/static/sdk/gv-feed.js"></script>
<div id="feed" style="position:fixed;inset:0"></div>
<script>
fetch("https://swipecdn.com/api/v1/feed?key=pk_live_YOUR_PUBLIC_KEY")
.then((r) => r.json())
.then(({ items }) => {
const feed = GVFeed.mount(document.getElementById("feed"), {
items, // playback JSON objects, in order
api: "https://cdn.swipecdn.com/swipecdn/cdn/api/v1", // where playback quality reports go
hlsSrc: "https://cdn.swipecdn.com/swipecdn/cdn/static/vendor/hls.light-1.7.3.min.js",
hud: false,
onActive: (i) => console.log("now playing", items[i].id),
});
// feed.next(), feed.go(i), feed.setMuted(false)
});
</script>Flutter
The swipecdn_feed package: a vertical PageView feed with a 3-controller pool, disk prefetch of the next two videos through a local proxy, and the same start-low rule. Download the package, unpack it next to your app and add it as a path dependency.
# pubspec.yaml
dependencies:
swipecdn_feed:
path: ../swipecdn_feed # the unpacked folder (it brings video_player and flutter_cache_manager)import 'package:swipecdn_feed/swipecdn_feed.dart';
// items = the playback JSON of each video, e.g. from https://swipecdn.com/api/v1/feed?key=… or your own API
final feed = GvVideoFeed(
items: jsonItems.map((j) => GvPlayback.fromJson(j)).toList(),
initialIndex: 0,
muted: false,
metricsApi: 'https://cdn.swipecdn.com/swipecdn/cdn/api/v1',
metricsLabel: 'my-app',
onPageChanged: (i) => debugPrint('now playing $i'),
overlayBuilder: (context, item, index, active) => Align(
alignment: Alignment.bottomLeft,
child: Padding(padding: const EdgeInsets.all(16), child: Text(item.title)),
),
);Platform setup, once: iOS Info.plist → NSAppTransportSecurity › NSAllowsLocalNetworking = YES; Android network_security_config allowing cleartext for 127.0.0.1 only (the prefetch proxy runs on the device).
Limits & errors
Errors are JSON: { "ok": false, "error": "quota_exceeded", "message": "…" }.
| Status | error | Meaning |
|---|---|---|
| 401 | auth | Missing or wrong key or token. |
| 401 | token_expired, token_signature | Protected video: the viewer token is not valid. |
| 402 | quota_exceeded | Not enough stored minutes left on the plan. |
| 403 | origin | The request came from a website that is not allowed. |
| 403 | uploads_paused | The trial or plan has ended. |
| 429 | rate | Too many requests; wait and retry. |
REST API: 120 requests per minute per key. Upload tokens: up to 20 videos each, 15 minutes by default (1 minute to 1 hour).