Quickstart
Prepare an API key, a video file, a viewer identifier, and the page address that will host the player. PRAXIS_API_BASE defaults to https://api.deepraxis.com. The API key stays on your backend and never reaches the page.
Publish in the Console
First upload the video to a media library, see Media. Then open Console → 内容 (Contents) (/contents), click “新建内容” (New content), fill in “标题” (Title), pick the “素材库” (Library) and the “视频” (Video), and click “创建” (Create); then click “发布” (Publish) on the content page.
export PRAXIS_API_BASE=https://api.deepraxis.comexport PRAXIS_API_KEY=...LESSON=lesson-01.mp4ORIGIN=https://learn.example.com1. Upload the video to Media
Create a library, then upload the video as an asset (multipart/form-data, field name file). Once the asset is ready its status becomes active.
LIBRARY_ID=$(curl -s -X POST "$PRAXIS_API_BASE/media/v1/libraries" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \ -d '{"name":"course videos"}' | jq -r .id)
ASSET_ID=$(curl -s -X POST "$PRAXIS_API_BASE/media/v1/libraries/$LIBRARY_ID/assets" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -F "file=@$LESSON" | jq -r .asset_id)
curl -s "$PRAXIS_API_BASE/media/v1/libraries/$LIBRARY_ID/assets/$ASSET_ID" \ -H "Authorization: Bearer $PRAXIS_API_KEY" | jq '{asset_id,status,material_type}'When status is active, the asset can be used by a content.
A large file (a course video of a few hundred MB or more) goes through chunks: your backend calls POST /file/v1/uploads/signed for part upload addresses, the browser uploads the parts, and the backend then calls POST /media/v1/libraries/{library_id}/assets/import with the file_id to import the asset. See Limits and errors.
2. Create the content
kind is always video. settings.source names the asset; settings.access decides who may play and how long a playback credential lives.
CONTENT_ID=$(curl -s -X POST "$PRAXIS_API_BASE/content/v1/contents" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \ -d "{\"kind\":\"video\",\"title\":\"Lesson 1\",\"settings\":{\"source\":{\"library_id\":\"$LIBRARY_ID\",\"asset_id\":\"$ASSET_ID\"},\"access\":{\"capability_seconds\":600,\"allowed_origins\":[\"$ORIGIN\"]}}}" | jq -r .id)The response has status: draft and readiness: processing: Content has asked Media to transcode the wanted renditions (480, 720 and 1080 by default).
allowed_origins accepts https origins only (http://localhost is the exception); each entry is the origin itself in lowercase, with no path and no trailing slash. The origin on the grant code in step 4 follows the same rule: https (or http://localhost), equal to its own URL origin.
3. Wait for ready, then publish
Publish once readiness is ready; publishing requires the target version to be ready. Transcoding completion has no callback — poll readiness with GET /content/v1/contents/{content_id} (every 10 seconds is enough). Magnitude: a ten-minute video takes about a minute, longer ones proportionally.
curl -s "$PRAXIS_API_BASE/content/v1/contents/$CONTENT_ID" \ -H "Authorization: Bearer $PRAXIS_API_KEY" | jq '{status,readiness,live_version}'
curl -s -X POST "$PRAXIS_API_BASE/content/v1/contents/$CONTENT_ID/publish" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" -d '{}'After publishing, status is published and live_version names the version just published.
4. Issue a grant code for the viewer
A grant code is single-use and minted by your backend with the API key; the browser never holds the API key. resources names what this sign-in may use.
curl -s -X POST "$PRAXIS_API_BASE/customer/v1/grant_codes" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \ -d "{\"customer_id\":\"student-1001\",\"origin\":\"$ORIGIN\",\"resources\":[\"content:$CONTENT_ID:play\"]}" \ | jq '{code,expires_at}'The viewer field is exactly customer_id (your own id for the viewer); customer, external_id, external_user_id and subject are each refused as Unsupported field. The full request body:
{ "customer_id": "student-1001", "origin": "https://learn.example.com", "resources": ["content:cnt_REPLACE_ME:play"]}Hand the returned code (starts with cgc_) to the browser. origin must be its own URL origin (scheme://host[:port], no path and no trailing slash); with origin bound, the code can only be exchanged from that origin.
5. Play it in the page
Load two scripts: praxis-session.js owns the viewer identity, praxis-video.js registers the <praxis-video> element. Call configure once; the element takes its identity from the session.
<script type="module"> import { configure } from "https://cdn.deepraxis.com/v1/praxis-session.js"; import "https://cdn.deepraxis.com/v1/praxis-video.js";
// The grant code is minted by your backend for the signed-in viewer (step 4); never hard-code it. configure({ api: { url: "https://api.deepraxis.com", grantCode: "cgc_REPLACE_ME" } });</script>
<praxis-video content="cnt_REPLACE_ME" style="display:block;width:100%;aspect-ratio:16/9"></praxis-video>Set the element’s content to the id from step 2 (starts with cnt_). configure exchanges the grant code for an access token and renews it before expiry; the element carries that identity when it opens a play.
Verify
praxis.readyfires when the player is ready; itsdetailcarriesrenditions,title,versionandexpire_time.- In the browser network log,
POST /content/v1/playback/sessionsanswers 201 and the returnedmanifest_urlsits undercontent.praxisusercontent.com. - A play without a token answers 403
RESOURCE_NOT_GRANTED; an origin outsideallowed_originsanswers 403ORIGIN_NOT_ALLOWED.
Clean up
Take a content down with POST /content/v1/contents/{content_id}/unpublish. The Media example can be deleted too — see the Media quickstart.