View Counts

Client implementations write to the increment route so your stream can report the audience size. Each viewer's client should hit the route once per second or their reservation will expire and the total count will decrement.

Each route requires that requests authenticate with a Reactive JWT Token. Refer our authentication documenation for how get and use a Reactive JWT Token.

Increment view count

This increments the view count for your stream for 1 second. Your client needs to post to this route once per second while it's connected to the stream.

Request:

POST https://view-counts.reactive.live/api/v1/view-counts/:stream_id

Parameters:

Name Type Required Description
stream_id string Yes The id of the stream you'd like to register as a viewer for

Example command:

curl -X POST \
    -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpcCI6IjEwNC4xNjIuOTcuMjgiLCJhdWQiOiI2OTM1MzU3YS04ZDcxLTQ1ZjItOWEwZi1kZGFlZDcwNWI0M2EiLCJzdWIiOiJBQjM1NDU3YS04ZDcxLTQ1ZjItQkUyRi1kZGFlZDcwNWI0M2EiLCJpc3MiOiJSZWFjdGl2ZSIsImlhdCI6MTYzNDkzNTQ5NCwiZXhwIjoxNjM0OTM2MDk0LCJqdGkiOiIwNzRlNDA0MS02MDg0LTQyOTItOTk2MC1jMTBlNWE1YzAwMjgifQ.o-pkrvzbTSVlzGixknSQvX1cwH1UIpx3R_fzmMpn3R8" \
    https://view-counts.reactive.live/api/v1/view-counts/6935357a-8d71-45f2-9a0f-ddaed705b43a

Response:

HTTP 204 NO CONTENT
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

Get view count

Returns the current view count of the stream.

Request:

GET https://view-counts.reactive.live/api/v1/view-counts/:stream_id

Parameters:

Name Type Required Description
stream_id string Yes The id of the stream you're querying

Example command:

curl -H "Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpcCI6IjEwNC4xNjIuOTcuMjgiLCJhdWQiOiI2OTM1MzU3YS04ZDcxLTQ1ZjItOWEwZi1kZGFlZDcwNWI0M2EiLCJzdWIiOiJBQjM1NDU3YS04ZDcxLTQ1ZjItQkUyRi1kZGFlZDcwNWI0M2EiLCJpc3MiOiJSZWFjdGl2ZSIsImlhdCI6MTYzNDkzNTQ5NCwiZXhwIjoxNjM0OTM2MDk0LCJqdGkiOiIwNzRlNDA0MS02MDg0LTQyOTItOTk2MC1jMTBlNWE1YzAwMjgifQ.o-pkrvzbTSVlzGixknSQvX1cwH1UIpx3R_fzmMpn3R8" \
    https://view-counts.reactive.live/api/v1/view-counts/6935357a-8d71-45f2-9a0f-ddaed705b43a

Response:

{
    "value": 1000010,
    "formatted": "1M"
}