Create WHEP Session - API
This API lets you create a WHEP session to receive (egress) WebRTC media streams from a VideoSDK meeting. This endpoint is used to pull media from a VideoSDK room to external players or applications.
HTTP method and endpoint
POST
|
https://api.videosdk.live/v2/whepHeaders Parameters
REQUIRED
values : YOUR_TOKEN_WITHOUT_ANY_PREFIX
This will be a JWT token generate using VideoSDK ApiKey and Secret.
Note that the token will not include any prefix such as "Basic " or "Bearer ". Just pass a token as value.
You can generate a new token by refering this Guide: Generate Auth token
REQUIRED
values : application/json
This is usefull for json body parameters, so that VideoSDK servers can understand that the incoming body parameter will be a JSON string.
Query Parameters
REQUIRED
The VideoSDK room ID from which to receive the stream.
REQUIRED
The participant ID identifying the receiver.
Body Parameters
REQUIRED
An SDP (Session Description Protocol) offer is a text-based description of the media capabilities that your WebRTC client wants to send or receive. It contains information about:
- Media types (audio, video)
- Codecs supported (e.g., Opus for audio, VP8/VP9/H264 for video)
- Network information (IP addresses, ports)
- ICE candidates for establishing the connection
- Security parameters (DTLS fingerprints, ICE credentials)
Example SDP Offer:
v=0
o=- 1495799811084970 1495799811084970 IN IP4 0.0.0.0
s=-
t=0 0
a=msid-semantic: iot
a=group:BUNDLE audio
m=audio 9 UDP/TLS/RTP/SAVP 111
a=rtpmap:111 opus/48000/2
a=ssrc:6 cname:webrtc-opus
a=sendrecv
a=mid:audio
c=IN IP4 0.0.0.0
a=rtcp-mux
a=fingerprint:sha-256 72:7E:06:D6:D0:9C:2E:30:75:22:AD:01:75:D6:5B:2B:D7:FB:00:A2:CD:60:20:49:5B:B0:62:63:A6:5F:A7:B4
a=setup:passive
a=ice-ufrag:a3oo
a=ice-pwd:a3ooPQLUll7W9HOfLpF1GlLT
a=candidate:0 1 UDP 2129213695 10.144.33.135 59704 typ host
a=candidate:2 1 UDP 1693006079 115.246.27.117 59704 typ srflx raddr 0.0.0.0 rport 0Response Header
Response header containing the session URL for managing this WHEP session (e.g.,
/v2/whep/sessions/{sessionId}). Response header indicating
application/sdp content type. Response Parameters
The SDP answer in the response body. This contains the server's media capabilities and must be processed by your WebRTC client to establish the connection.
POST
|
https://api.videosdk.live/v2/whep
NodeJS
import fetch from 'node-fetch';
const options = {
method: "POST",
headers: {
"Authorization": "$YOUR_TOKEN",
"Content-Type": "application/sdp",
},
body: sdpOffer, // SDP offer or ICE candidate fragments
};
const url= `https://api.videosdk.live/v2/whep?roomId=zfww-680a-dzen&participantId=whep-viewer`;
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
RESPONSE
"v=0\no=mediasoup-client 10000 1 IN IP4 0.0.0.0\ns=-\nt=0 0\na=ice-lite\na=fingerprint:sha-256 47:19:3D:F5:C5:61:0F:64:6C:1F:FD:97:93:17:11:1E:32:9A:AE:06:63:AC:4B:6C:35:75:5C:38:E1:19:8C:6B\na=msid-semantic: WMS *\na=group:BUNDLE audio\nm=audio 9 UDP/TLS/RTP/SAVP 111\nc=IN IP4 127.0.0.1\na=rtpmap:111 opus/48000/2\na=setup:active\na=mid:audio\na=recvonly\na=ice-ufrag:ik9np3y7w1swoftcrla82wbkd6x9xc2t\na=ice-pwd:86z9f189yrimq9zq9bkekapufsjnfq07\na=candidate:udpcandidate 1 udp 1076302079 34.100.132.184 42771 typ host\na=end-of-candidates\na=ice-options:renomination\na=rtcp-mux\na=rtcp-rsize"
Got a Question? Ask us on discord