Skip to main content

Streaming API

Endpoints for live streaming via Mux, video generation, and streaming webhook processing.

List live streams

GET /api/basefm/live
Returns all currently active Mux live streams. No authentication required.

Response

{
  "djs": [
    {
      "id": "aB1cD2eF3g",
      "name": "DJ Rave",
      "wallet": "0x1234...abcd",
      "playbackId": "xYz789",
      "streamKey": "sk-ab12-cd34-ef56",
      "status": "active",
      "startedAt": 1710806400,
      "hlsUrl": "https://stream.mux.com/xYz789.m3u8",
      "embedUrl": "https://stream.mux.com/xYz789.html"
    }
  ],
  "count": 1
}
FieldTypeDescription
djs[].idstringMux live stream ID
djs[].namestringDJ display name (defaults to Anonymous DJ)
djs[].walletstring | nullDJ wallet address from stream metadata
djs[].playbackIdstring | nullMux playback ID
djs[].streamKeystringRTMP stream key
djs[].statusstringStream status (active)
djs[].startedAtnumberUnix timestamp when the stream was created
djs[].hlsUrlstring | nullHLS playlist URL for playback
djs[].embedUrlstring | nullEmbeddable player URL

Errors

CodeDescription
500Mux is not configured or an internal error occurred

Create live stream

POST /api/basefm/streams
Creates a new Mux live stream. Access is gated by RAVE token balance — the caller’s wallet must hold at least 1,250,000 RAVE tokens on the Base network.

Request body

FieldTypeRequiredDescription
walletstringYesWallet address of the DJ. Used for RAVE token balance verification.
namestringNoDJ display name (default: Anonymous DJ)

Response (200)

{
  "success": true,
  "stream": {
    "id": "aB1cD2eF3g",
    "name": "DJ Rave",
    "wallet": "0x1234...abcd",
    "streamKey": "sk-ab12-cd34-ef56",
    "rtmpUrl": "rtmp://global-live.mux.com:5222/app",
    "fullRtmpUrl": "rtmp://global-live.mux.com:5222/app/sk-ab12-cd34-ef56",
    "playbackId": "xYz789",
    "status": "created"
  },
  "obsSettings": {
    "server": "rtmp://global-live.mux.com:5222/app",
    "streamKey": "sk-ab12-cd34-ef56",
    "recommended": {
      "audioBitrate": "256-320 kbps",
      "encoder": "AAC",
      "sampleRate": "44.1 kHz",
      "channels": "Stereo"
    }
  }
}
FieldTypeDescription
stream.idstringMux live stream ID
stream.streamKeystringRTMP stream key
stream.rtmpUrlstringRTMP ingest server URL
stream.fullRtmpUrlstringFull RTMP URL including stream key (for OBS)
stream.playbackIdstring | nullMux playback ID for viewers
obsSettings.recommendedobjectRecommended OBS audio encoding settings

Errors

CodeDescription
400Wallet address required
403Insufficient RAVE tokens. The wallet must hold at least 1,250,000 RAVE.
500Mux is not configured or stream creation failed

Generate video

POST /api/generate-video
Generates a video and uploads it to blob storage. Requires session authentication. This endpoint has a 5-minute timeout.

Request body

FieldTypeRequiredDescription
typestringYesVideo type. One of: demo, marketing, screenshot, tutorial.
agentNamestringFor demoAgent name for the demo video
agentDescriptionstringFor demoAgent description for the demo video
productNamestringFor marketingProduct name for the marketing video
featuresanyFor marketingProduct features for the marketing video
imageUrlstringFor screenshotImage URL to animate
descriptionstringFor screenshotDescription for the animation
topicstringFor tutorialTutorial topic
stepsanyFor tutorialTutorial steps

Response

{
  "url": "https://blob-storage-url/videos/1710806400000.mp4"
}

Errors

CodeDescription
400Invalid video type
401Unauthorized — session required
500Video generation or upload failed

Mux webhooks

POST /api/webhooks/mux
Receives and processes Mux webhook events. This endpoint verifies the request signature using HMAC-SHA256 and rejects unsigned, expired, or tampered requests.
This endpoint is intended to be called by Mux only. You must configure the MUX_SIGNING_SECRET (or MUX_WEBHOOK_SECRET) environment variable for signature verification. When the signing secret is not configured, all requests are rejected.

Headers

HeaderRequiredDescription
mux-signatureYesMux webhook signature in the format t=<timestamp>,v1=<signature>

Signature verification

The endpoint performs the following checks:
  1. Rejects requests missing the mux-signature header (401)
  2. Rejects requests with a timestamp older than 5 minutes to prevent replay attacks (403)
  3. Computes HMAC-SHA256 over <timestamp>.<body> using the signing secret
  4. Performs a timing-safe comparison of the computed signature against the provided signature (403 on mismatch)

Handled event types

EventBehavior
video.asset.readyArchives HD assets (1080p or higher) longer than 15 minutes. Shorter or lower-resolution assets are queued for deletion.
video.live_stream.activeLogs that a live stream has become active
video.live_stream.idleLogs that a live stream has stopped

Response

{
  "received": true
}

Errors

CodeDescription
401Missing mux-signature header
403Invalid signature or expired timestamp
500Webhook processing failed