Skip to content

Automate a stream

A stream has an input, destinations and an overlay. Configure it in the dashboard, or over REST with Configure a stream. This guide drives a configured stream for one match. It needs a write key and a match that already has a stream.

The endpoints are under Streams in the REST reference.

  1. Find the stream of the match.

    Terminal
    curl 'https://api.ligr.live/rest/v2/matches/1188213?include=s,o' \
    -H "Authorization: Bearer $LIGR_API_KEY"
    200 OK (excerpt)
    {
    "id": 1188213,
    "streams": [{ "id": 90412, "name": "Main feed", "destinations": [{ "id": 3301, "name": "YouTube", "type": "youtube" }] }],
    "overlays": [{ "id": 2300003, "name": "Broadcast", "key": "…" }]
    }

    streams[].id is the streamSettingsId every stream route takes. overlays[].id is the overlay you can switch to in step 4.

  2. Read the state.

    Terminal
    curl 'https://api.ligr.live/rest/v1/streams/90412/state' \
    -H "Authorization: Bearer $LIGR_API_KEY"
    200 OK
    { "streamSettingsId": 90412, "state": "IDLE", "matchId": 1188213 }

    An idle stream is ready for GoLive.

  3. Go live.

    Terminal
    curl -X POST 'https://api.ligr.live/rest/v1/streams/90412/manage' \
    -H "Authorization: Bearer $LIGR_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{ "command": "GoLive" }'
    200 OK
    { "streamSettingsId": 90412, "state": "CREATING", "matchId": 1188213, "transitioning": true }

    GoLive starts the stream. Without startDestinationsImmediately it publishes nowhere: the picture runs, and an operator starts the destinations from the dashboard when it is right. That is the preview. To publish at once, list the destination ids to start:

    Go live and publish to one destination at once
    { "command": "GoLive", "startDestinationsImmediately": [3301] }

    Poll GET …/state every 5 seconds until state reads ONLIVE. The transition takes tens of seconds. ERROR means the start failed. Open the stream in the dashboard to read the cause.

  4. Switch the overlay.

    Terminal
    curl -X POST 'https://api.ligr.live/rest/v1/streams/90412/overlay/change' \
    -H "Authorization: Bearer $LIGR_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{ "overlayId": 2300003 }'

    Send "overlayId": null to unlink the overlay. …/overlay/show and …/overlay/hide toggle the linked overlay without unlinking it. …/overlay/refresh restarts it.

  5. Stop.

    Terminal
    curl -X POST 'https://api.ligr.live/rest/v1/streams/90412/manage' \
    -H "Authorization: Bearer $LIGR_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{ "command": "StopStream" }'
    200 OK
    { "streamSettingsId": 90412, "state": "TRANSIT_TO_STOPPED", "matchId": 1188213, "transitioning": true }

    Poll GET …/state until state reads IDLE. The stream is then ready for the next GoLive.

GET …/state returns one of these values.

stateMeaning
IDLENo stream is running. GoLive is allowed
CREATINGGoLive was accepted and the infrastructure is starting
ONLIVEThe stream is live. StopStream is allowed
TRANSIT_TO_STOPPEDStopStream was accepted and the infrastructure is stopping
ERRORThe start or the stop failed. Open the stream in the dashboard

The manage answer adds transitioning. It is true for CREATING and TRANSIT_TO_STOPPED. A command sent while the stream is transitioning is refused with 400. The state endpoint does not carry transitioning. Poll on state.

commandEffect
GoLiveStart the stream. Allowed from IDLE. startDestinationsImmediately picks the destinations that publish at once
StopStreamStop the stream. Allowed from ONLIVE

There is no pause. Stop the stream and go live again. There is no separate preview command. GoLive without destinations is the preview.

Poll GET …/state every 5 seconds while a transition is in progress. Stop polling when the stream reaches the state you wait for. See Rate limits.

StatusCause
400The command is not allowed from the current state, or the stream is transitioning
403A read key on …/manage or an overlay route. Use a write key
404The streamSettingsId belongs to another organization, or the match has no stream

See Streams in the REST reference.