Login

Webhooks in live stream

  • Webhooks are a mechanism for communication between two web applications in real-time.
  • Webhooks act as a tool used by FastPix to notify your application of events occurring asynchronously, outside o the API request cycle. For example, these events could involve livestream creation, update, or changes in the livestream API status.
  • FastPix sends a POST request to the provided address when these asynchronous events occur, allowing you the freedom to handle the response in a manner that fits your application's requirements. Once a webhook is configured for a specific environment, notifications will be sent for all events within that environment.

Requirements for Webhooks Implementation:

  • Develop a webhooks endpoint: Create a designated endpoint on your server to receive incoming webhook requests from Fastpix. This endpoint, usually a URL, will serve as the destination for data sent via the POST method when specific trigger events related to livestreaming occur within your application.
  • Define the trigger event for live streaming: Identify the precise live streaming events or actions within your application that should trigger the FastPix webhook. These events could include, for instance, the start of a live stream, viewer interactions, or the completion of a live stream session.
  • Monitoring and maintenance for webhooks: Regularly monitor the FastPix webhook endpoint to identify and address any errors or failures that may arise during live streaming events. Conduct routine maintenance tasks and updates and to ensure the ongoing functionality reliability of the FastPix webhook system tailored for live streaming applications.

{
  "type": "video.live_stream.created",
  "request_id": null,
  "object": {
    "type": "live",
    "id": "a2ae2143-62a1-4eee-b888-4f1406148481"
  },
  "id": "8fa0e3ea-3d5c-4712-8428-803b532bbc33",
  "environment": {
    "name": "Development",
    "id": "7c07598b-c27b-42e6-8b31-a334da54c387"
  },
  "data": {
    "test": false,
    "streamId": "a2ae2143-62a1-4eee-b888-4f1406148481",
    "status": "idle",
    "audioOnly": true,
    "streamKey": "FP_TRgf4CswLZ9UcHH3yTxQ",
    "maxResolution": "1080p",
    "createdAt": "2024-04-02T11:17:52.460858Z",
    "reconnectWindow": 60,
    "latencyMode": "standard",
    "maxDuration": 43200,
    "playbackId": [
      {
        "id": "55d5b68e-508a-4adf-a01a-9420005ee796",
        "accessPolicy": "public"
      }
    ]
  },
  "createdAt": "2024-04-02T11:17:52.722812836Z",
  "attempts": [],
  "accessor_source": null,
  "accessor": null
}

When a POST request is made to create a livestream, this webhook event is triggered.


{
  "type": "video.live_stream.created",
  "request_id": null,
  "object": {
    "type": "live",
    "id": "3dda81f7-c3c8-4090-b19c-ddc8bc885a8d"
  },
  "id": "26c7a1a4-d049-4046-b54b-7967354949f0",
  "environment": {
    "name": "Development",
    "id": "43a59a2d-6d5f-41c2-ba36-f4e5a8b15829"
  },
  "data": {
    "test": false,
    "streamId": "3dda81f7-c3c8-4090-b19c-ddc8bc885a8d",
    "status": "idle",
    "audioOnly": false,
    "streamKey": "FP_pbeAbQF5LUxPAdUseA0u",
    "maxResolution": "1080p",
    "createdAt": "2024-04-02T12:15:24.001028Z",
    "reconnectWindow": 60,
    "latencyMode": "standard",
    "maxDuration": 43200,
    "playbackId": [
      {
        "id": "c2677bb8-8db8-4786-ab8a-55bfb14e9994",
        "accessPolicy": "public"
      }
    ]
  },
  "createdAt": "2024-04-02T12:15:24.416436Z",
  "attempts": null,
  "accessor_source": null,
  "accessor": null
}

When a POST request is made to create a Simulcast of a livestream, this webhook event is triggered.


Implement webhooks

Get a webhook proxy unique URL from wehooks.site and create a webhook API for particular environment-Id.
Next, start creating live streams and execute live stream tasks. Subsequently, a specific event is received at a designated URL.


Live stream events

  1. video.live_stream.created: A new live stream has been created. Broadcasters possessing a stream key can commence transmitting their encoder feed to this particular live stream.
  2. video.live_stream.connected: The live stream is in a "connected" status for video live streaming, confirming that an encoder has established a successful connection to it.
  3. video.live_stream.recording: The live stream's video recording is now in progress.
  4. video.live_stream.active: The live stream is currently marked as "active," signifying that it is presently "live" and actively broadcasting.
  5. video.live_stream.disconnected: When the stream is stopped, causing the encoder to become disconnected.
  6. video.live_stream.idle: The live stream enters an "idle" state as there is no ongoing streaming activity.
  7. video.asset.created: The live stream enters an "cretaed" state as there is no ongoing streaming activity.
  8. video.live_stream.updated: The live stream has been either updated, or the stream key for this livestream has been reset.
  9. video.live_stream.enabled: The live stream that was previously disabled has now been enabled.
  10. video.live_stream.disabled: The live stream has been disabled, and if desired, it can be re-enabled. However, please note that test streams cannot be re-enabled.
  11. video.live_stream.deleted: The live stream has been deleted.

Simulcast events

Utilizing simulcast target events is crucial for developing a user interface that provides users with real-time information on the status of their set third-party endpoints. This becomes especially beneficial when designing a UI to present the current state of each simulcast target and to monitor any updates in their status as they happen.

  1. video.live_stream.simulcast.created: A new simulcast has been created for a live stream.
  2. video.live_stream.simulcast.starting: When the parent live stream triggers a "connected" event, the simulcast targets shift to the "starting" state.
  3. video.live_stream.simulcast.broadcasting: When FastPix has established a successful connection with third-party platforms and commenced the process of pushing content to those external services.
  4. video.live_stream.simulcast.deleted: When the simulcast of a live stream has been deleted.