Nearglass

A seat and its viewer token (server admission), or a place in line

Call it from your backend after your own login. Without `seat`, a new seat id is made; while the viewer waits, call again with the `seat` from the last answer every `retry_after_ms`. A seat is kept by the player's heartbeat (`/v1/play/{id}/hb`): 20 s without one (60 s for a hidden tab) and the seat is lost and its relay sessions closed.

POST
/v1/streams/{id}/viewer-tokens

Call it from your backend after your own login. Without seat, a new seat id is made; while the viewer waits, call again with the seat from the last answer every retry_after_ms. A seat is kept by the player's heartbeat (/v1/play/{id}/hb): 20 s without one (60 s for a hidden tab) and the seat is lost and its relay sessions closed.

Authorization

secretKey
headerAuthorizationBearer <token>

sk_...

Path Parameters

id*string

Request Body

application/json
  1. body
seat?SeatId
Match^se_[0-9a-f]{32}$
viewer_ref?string

your id for the viewer, in the relay logs as viewer:

join?boolean

take a seat offered to this viewer (false: answer state offer and wait for a second call)

Defaulttrue
ttl?integer

seconds; default 120. The token bounds the join, not the watching

Range1 <= value <= 3600

Response Body

seated

application/json
  1. response

A token and where to use it; the player and the SDK publisher take it whole.

token?string

the CAT, base64url without padding; CLIENT_SETUP AUTHORIZATION TOKEN type 1

token_id?|

the CWT cti: s-... (viewer), pub-... (SDK publisher asked with token_id), ing-... (gateway), turn: (controller); null for a device publisher token

expires_at?string
Formatdate-time
exp?integer

Unix seconds

relays?array<>
namespace?string
catalog?string
relay_cert_sha256?string

only for a relay with a self-signed certificate

hls?string

the LL-HLS playlist for the player fallback; with the API edge, /v1/play/{id}/hls/index.m3u8 and only for streams with encoder ingest

state?"in"
Value in"in"
seat?SeatId
Match^se_[0-9a-f]{32}$
heartbeat_ms?integer
play_url?string

where the player keeps the seat: POST {play_url}/hb every heartbeat_ms, and {play_url}/leave on close, with the seat alone; present when the API knows its public address

Example Request
curl -X POST 'https://api.nearglass.com/v1/streams/st_8f2c41d09a7be3105c6e2d77/viewer-tokens' \  -H 'Content-Type: application/json' \  -d '{  "viewer_ref": "user-4821"}'
Example Response
{  "token": "string",  "token_id": "string",  "expires_at": "2019-08-24T14:15:22Z",  "exp": 0,  "relays": [    {      "url": "string"    }  ],  "namespace": "string",  "catalog": "string",  "relay_cert_sha256": "string",  "hls": "string",  "state": "in",  "seat": "string",  "heartbeat_ms": 0,  "play_url": "string"}