# Livestreams ## Create an independent livestream `client.RealtimeKit.Livestreams.NewIndependentLivestream(ctx, appID, params) (*LivestreamNewIndependentLivestreamResponse, error)` **post** `/accounts/{account_id}/realtime/kit/{app_id}/livestreams` Creates a livestream for the given App ID and returns ingest server, stream key, and playback URL. You can pass custom input to the ingest server and stream key, and freely distribute the content using the playback URL on any player that supports HLS/LHLS. ### Parameters - `appID string` The app identifier tag. - `params LivestreamNewIndependentLivestreamParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `Name param.Field[string]` Body param: Name of the livestream ### Returns - `type LivestreamNewIndependentLivestreamResponse struct{…}` - `Data LivestreamNewIndependentLivestreamResponseData` - `ID string` The livestream ID. - `Disabled bool` Specifies if the livestream was disabled. - `IngestServer string` The server URL to which the RTMP encoder should send the video and audio data. - `MeetingID string` - `Name string` - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamNewIndependentLivestreamResponseDataStatus` - `const LivestreamNewIndependentLivestreamResponseDataStatusLive LivestreamNewIndependentLivestreamResponseDataStatus = "LIVE"` - `const LivestreamNewIndependentLivestreamResponseDataStatusIdle LivestreamNewIndependentLivestreamResponseDataStatus = "IDLE"` - `const LivestreamNewIndependentLivestreamResponseDataStatusErrored LivestreamNewIndependentLivestreamResponseDataStatus = "ERRORED"` - `const LivestreamNewIndependentLivestreamResponseDataStatusInvoked LivestreamNewIndependentLivestreamResponseDataStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.NewIndependentLivestream( context.TODO(), "app_id", realtime_kit.LivestreamNewIndependentLivestreamParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("prdmmp-xhycsl"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "disabled": false, "id": "78dd0b50-4147-4bb8-88d3-2ccc2e98bff0", "ingest_server": "rtmps://live.cloudflare.com:443/live/", "meeting_id": null, "name": "Livestreaming-Demo", "playback_url": "https://customer-s8oj0c1n5ek8ah1e.cloudflarestream.com/7de6a3fec0f9c05bf1df140950d3a237/manifest/video.m3u8", "status": "INVOKED", "stream_key": "f26566285faca6fbe2e79a73a66rsrrsrrsr3cde23a2bb7dbc6c2c1761b98f4e4" }, "success": true } ``` ## Fetch all livestreams `client.RealtimeKit.Livestreams.GetAllLivestreams(ctx, appID, params) (*LivestreamGetAllLivestreamsResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/livestreams` Returns details of livestreams associated with the given App ID. It includes livestreams created by your App and RealtimeKit meetings that are livestreamed by your App. If you only want details of livestreams created by your App and not RealtimeKit meetings, you can use the `exclude_meetings` query parameter. ### Parameters - `appID string` The app identifier tag. - `params LivestreamGetAllLivestreamsParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `EndTime param.Field[Time]` Query param: Specify the end time range in ISO format to access the live stream. - `ExcludeMeetings param.Field[bool]` Query param: Exclude the RealtimeKit meetings that are livestreamed. - `PageNo param.Field[int64]` Query param: The page number from which you want your page search results to be displayed. - `PerPage param.Field[int64]` Query param: Number of results per page. - `SortOrder param.Field[LivestreamGetAllLivestreamsParamsSortOrder]` Query param: Specifies the sorting order for the results. - `const LivestreamGetAllLivestreamsParamsSortOrderAsc LivestreamGetAllLivestreamsParamsSortOrder = "ASC"` - `const LivestreamGetAllLivestreamsParamsSortOrderDsc LivestreamGetAllLivestreamsParamsSortOrder = "DSC"` - `StartTime param.Field[Time]` Query param: Specify the start time range in ISO format to access the live stream. - `Status param.Field[LivestreamGetAllLivestreamsParamsStatus]` Query param: Specifies the status of the operation. - `const LivestreamGetAllLivestreamsParamsStatusLive LivestreamGetAllLivestreamsParamsStatus = "LIVE"` - `const LivestreamGetAllLivestreamsParamsStatusIdle LivestreamGetAllLivestreamsParamsStatus = "IDLE"` - `const LivestreamGetAllLivestreamsParamsStatusErrored LivestreamGetAllLivestreamsParamsStatus = "ERRORED"` - `const LivestreamGetAllLivestreamsParamsStatusInvoked LivestreamGetAllLivestreamsParamsStatus = "INVOKED"` ### Returns - `type LivestreamGetAllLivestreamsResponse struct{…}` - `Data LivestreamGetAllLivestreamsResponseData` - `ID string` The ID of the livestream. - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `Disabled string` Specifies if the livestream was disabled. - `IngestServer string` The server URL to which the RTMP encoder sends the video and audio data. - `MeetingID string` ID of the meeting. - `Name string` Name of the livestream. - `Paging LivestreamGetAllLivestreamsResponseDataPaging` - `EndOffset int64` - `StartOffset int64` - `TotalCount int64` - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamGetAllLivestreamsResponseDataStatus` - `const LivestreamGetAllLivestreamsResponseDataStatusLive LivestreamGetAllLivestreamsResponseDataStatus = "LIVE"` - `const LivestreamGetAllLivestreamsResponseDataStatusIdle LivestreamGetAllLivestreamsResponseDataStatus = "IDLE"` - `const LivestreamGetAllLivestreamsResponseDataStatusErrored LivestreamGetAllLivestreamsResponseDataStatus = "ERRORED"` - `const LivestreamGetAllLivestreamsResponseDataStatusInvoked LivestreamGetAllLivestreamsResponseDataStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `UpdatedAt Time` Timestamp the object was updated at. The time is returned in ISO format. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetAllLivestreams( context.TODO(), "app_id", realtime_kit.LivestreamGetAllLivestreamsParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "id": "3fd739f4-3c41-456e-bfba-6ebd51e16d2d", "created_at": "2023-07-15T11:48:34.753Z", "disabled": "disabled", "ingest_server": "rtmps://live.cloudflare.com:443/live/", "meeting_id": "meeting_id", "name": "test", "paging": { "end_offset": 1, "start_offset": 1, "total_count": 1 }, "playback_url": "https://customer-s8oj0c1n5ek8ah1e.cloudflarestream.com/7de6a3fec0f9c05bf1df140950d3a237/manifest/video.m3u8", "status": "LIVE", "stream_key": "f26566285faca6fbe2e79a73a66rsrrsrrsr3cde23a2bb7dbc6c2c1761b98f4e4", "updated_at": "2023-07-15T11:48:34.753Z" }, "success": true } ``` ## Stop livestreaming a meeting `client.RealtimeKit.Livestreams.StopLivestreamingAMeeting(ctx, appID, meetingID, body) (*LivestreamStopLivestreamingAMeetingResponse, error)` **post** `/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream/stop` Stops the active livestream of a meeting associated with the given meeting ID. Retreive the meeting ID using the `Create a meeting` API. ### Parameters - `appID string` The app identifier tag. - `meetingID string` - `body LivestreamStopLivestreamingAMeetingParams` - `AccountID param.Field[string]` The account identifier tag. ### Returns - `type LivestreamStopLivestreamingAMeetingResponse struct{…}` - `Data LivestreamStopLivestreamingAMeetingResponseData` - `Message string` - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.StopLivestreamingAMeeting( context.TODO(), "app_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", realtime_kit.LivestreamStopLivestreamingAMeetingParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "message": "Stopped live stream successfully" }, "success": true } ``` ## Start livestreaming a meeting `client.RealtimeKit.Livestreams.StartLivestreamingAMeeting(ctx, appID, meetingID, params) (*LivestreamStartLivestreamingAMeetingResponse, error)` **post** `/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/livestreams` Starts livestream of a meeting associated with the given meeting ID. Retreive the meeting ID using the `Create a meeting` API. ### Parameters - `appID string` The app identifier tag. - `meetingID string` - `params LivestreamStartLivestreamingAMeetingParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `Name param.Field[string]` Body param - `VideoConfig param.Field[LivestreamStartLivestreamingAMeetingParamsVideoConfig]` Body param - `Height int64` Height of the livestreaming video in pixels - `Width int64` Width of the livestreaming video in pixels ### Returns - `type LivestreamStartLivestreamingAMeetingResponse struct{…}` - `Data LivestreamStartLivestreamingAMeetingResponseData` - `ID string` The livestream ID. - `IngestServer string` The server URL to which the RTMP encoder sends the video and audio data. - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamStartLivestreamingAMeetingResponseDataStatus` - `const LivestreamStartLivestreamingAMeetingResponseDataStatusLive LivestreamStartLivestreamingAMeetingResponseDataStatus = "LIVE"` - `const LivestreamStartLivestreamingAMeetingResponseDataStatusIdle LivestreamStartLivestreamingAMeetingResponseDataStatus = "IDLE"` - `const LivestreamStartLivestreamingAMeetingResponseDataStatusErrored LivestreamStartLivestreamingAMeetingResponseDataStatus = "ERRORED"` - `const LivestreamStartLivestreamingAMeetingResponseDataStatusInvoked LivestreamStartLivestreamingAMeetingResponseDataStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.StartLivestreamingAMeeting( context.TODO(), "app_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", realtime_kit.LivestreamStartLivestreamingAMeetingParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("prdmmp-xhycsl"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "id": "7088bba8-f522-49a8-b59b-3cd0e946bbb0", "ingest_server": "rtmps://live.cloudflare.com:443/live/", "playback_url": "https://customer-s8oj0c1n5ek8ah1e.cloudflarestream.com/7de6a3fec0f9c05bf1df140950d3a237/manifest/video.m3u8", "status": "INVOKED", "stream_key": "f26566285faca6fbe2e79a73a66rsrrsrrsr3cde23a2bb7dbc6c2c1761b98f4e4" }, "success": true } ``` ## Fetch complete analytics data for your livestreams `client.RealtimeKit.Livestreams.GetLivestreamAnalyticsComplete(ctx, appID, params) (*LivestreamGetLivestreamAnalyticsCompleteResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/analytics/livestreams/overall` Returns livestream analytics for the specified time range. ### Parameters - `appID string` The app identifier tag. - `params LivestreamGetLivestreamAnalyticsCompleteParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `EndTime param.Field[Time]` Query param: Specify the end time range in ISO format to access the livestream analytics. - `StartTime param.Field[Time]` Query param: Specify the start time range in ISO format to access the livestream analytics. ### Returns - `type LivestreamGetLivestreamAnalyticsCompleteResponse struct{…}` - `Data LivestreamGetLivestreamAnalyticsCompleteResponseData` - `Count int64` Count of total livestreams. - `TotalIngestSeconds int64` Total time duration for which the input was given or the meeting was streamed. - `TotalViewerSeconds int64` Total view time for which the viewers watched the stream. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetLivestreamAnalyticsComplete( context.TODO(), "app_id", realtime_kit.LivestreamGetLivestreamAnalyticsCompleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "count": 0, "total_ingest_seconds": 0, "total_viewer_seconds": 0 }, "success": true } ``` ## Fetch day-wise session and recording analytics data for an App `client.RealtimeKit.Livestreams.GetOrgAnalytics(ctx, appID, params) (*LivestreamGetOrgAnalyticsResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/analytics/daywise` Returns day-wise session and recording analytics data of an App for the specified time range start_date to end_date. If start_date and end_date are not provided, the default time range is set from 30 days ago to the current date. ### Parameters - `appID string` The app identifier tag. - `params LivestreamGetOrgAnalyticsParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `EndDate param.Field[string]` Query param: end date in YYYY-MM-DD format - `StartDate param.Field[string]` Query param: start date in YYYY-MM-DD format ### Returns - `type LivestreamGetOrgAnalyticsResponse struct{…}` - `Data LivestreamGetOrgAnalyticsResponseData` - `RecordingStats LivestreamGetOrgAnalyticsResponseDataRecordingStats` Recording statistics of an App during the range specified - `DayStats []LivestreamGetOrgAnalyticsResponseDataRecordingStatsDayStat` Day wise recording stats - `Day string` - `TotalRecordingMinutes int64` Total recording minutes for a specific day - `TotalRecordings int64` Total number of recordings for a specific day - `RecordingCount int64` Total number of recordings during the range specified - `RecordingMinutesConsumed float64` Total recording minutes during the range specified - `SessionStats LivestreamGetOrgAnalyticsResponseDataSessionStats` Session statistics of an App during the range specified - `DayStats []LivestreamGetOrgAnalyticsResponseDataSessionStatsDayStat` Day wise session stats - `Day string` - `TotalSessionMinutes float64` Total session minutes for a specific day - `TotalSessions int64` Total number of sessions for a specific day - `SessionsCount int64` Total number of sessions during the range specified - `SessionsMinutesConsumed float64` Total session minutes during the range specified - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetOrgAnalytics( context.TODO(), "app_id", realtime_kit.LivestreamGetOrgAnalyticsParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "recording_stats": { "day_stats": [ { "day": "day", "total_recording_minutes": 0, "total_recordings": 0 } ], "recording_count": 0, "recording_minutes_consumed": 0 }, "session_stats": { "day_stats": [ { "day": "day", "total_session_minutes": 0, "total_sessions": 0 } ], "sessions_count": 0, "sessions_minutes_consumed": 0 } }, "success": true } ``` ## Fetch active livestreams for a meeting `client.RealtimeKit.Livestreams.GetMeetingActiveLivestreams(ctx, appID, meetingID, query) (*LivestreamGetMeetingActiveLivestreamsResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-livestream` Returns details of all active livestreams for the given meeting ID. ### Parameters - `appID string` The app identifier tag. - `meetingID string` - `query LivestreamGetMeetingActiveLivestreamsParams` - `AccountID param.Field[string]` The account identifier tag. ### Returns - `type LivestreamGetMeetingActiveLivestreamsResponse struct{…}` - `Data LivestreamGetMeetingActiveLivestreamsResponseData` - `ID string` The livestream ID. - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `Disabled string` Specifies if the livestream was disabled. - `IngestServer string` The server URL to which the RTMP encoder sends the video and audio data. - `MeetingID string` - `Name string` Name of the livestream. - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamGetMeetingActiveLivestreamsResponseDataStatus` - `const LivestreamGetMeetingActiveLivestreamsResponseDataStatusLive LivestreamGetMeetingActiveLivestreamsResponseDataStatus = "LIVE"` - `const LivestreamGetMeetingActiveLivestreamsResponseDataStatusIdle LivestreamGetMeetingActiveLivestreamsResponseDataStatus = "IDLE"` - `const LivestreamGetMeetingActiveLivestreamsResponseDataStatusErrored LivestreamGetMeetingActiveLivestreamsResponseDataStatus = "ERRORED"` - `const LivestreamGetMeetingActiveLivestreamsResponseDataStatusInvoked LivestreamGetMeetingActiveLivestreamsResponseDataStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `UpdatedAt Time` Timestamp the object was updated at. The time is returned in ISO format. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetMeetingActiveLivestreams( context.TODO(), "app_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", realtime_kit.LivestreamGetMeetingActiveLivestreamsParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "disabled": "disabled", "ingest_server": "ingest_server", "meeting_id": "meeting_id", "name": "name", "playback_url": "playback_url", "status": "LIVE", "stream_key": "stream_key", "updated_at": "2019-12-27T18:11:19.117Z" }, "success": true } ``` ## Fetch livestream session details using livestream session ID `client.RealtimeKit.Livestreams.GetLivestreamSessionDetailsForSessionID(ctx, appID, livestreamSessionID, query) (*LivestreamGetLivestreamSessionDetailsForSessionIDResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/livestreams/sessions/{livestream-session-id}` Returns livestream session details for the given livestream session ID. Retrieve the `livestream_session_id`using the `Fetch livestream session details using a session ID` API. ### Parameters - `appID string` The app identifier tag. - `livestreamSessionID string` - `query LivestreamGetLivestreamSessionDetailsForSessionIDParams` - `AccountID param.Field[string]` The account identifier tag. ### Returns - `type LivestreamGetLivestreamSessionDetailsForSessionIDResponse struct{…}` - `Data LivestreamGetLivestreamSessionDetailsForSessionIDResponseData` - `ID string` The livestream ID. - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `ErrMessage string` The server URL to which the RTMP encoder sends the video and audio data. - `IngestSeconds int64` Name of the livestream. - `LivestreamID string` - `StartedTime string` Unique key for accessing each livestream. - `StoppedTime string` The web address that viewers can use to watch the livestream. - `UpdatedAt string` Timestamp the object was updated at. The time is returned in ISO format. - `ViewerSeconds int64` Specifies if the livestream was disabled. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetLivestreamSessionDetailsForSessionID( context.TODO(), "app_id", "livestream-session-id", realtime_kit.LivestreamGetLivestreamSessionDetailsForSessionIDParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "err_message": "err_message", "ingest_seconds": 0, "livestream_id": "livestream_id", "started_time": "started_time", "stopped_time": "stopped_time", "updated_at": "updated_at", "viewer_seconds": 0 }, "success": true } ``` ## Fetch active livestream session details `client.RealtimeKit.Livestreams.GetActiveLivestreamsForLivestreamID(ctx, appID, livestreamID, query) (*LivestreamGetActiveLivestreamsForLivestreamIDResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}/active-livestream-session` Returns details of all active livestreams for the given livestream ID. Retreive the livestream ID using the `Start livestreaming a meeting` API. ### Parameters - `appID string` The app identifier tag. - `livestreamID string` - `query LivestreamGetActiveLivestreamsForLivestreamIDParams` - `AccountID param.Field[string]` The account identifier tag. ### Returns - `type LivestreamGetActiveLivestreamsForLivestreamIDResponse struct{…}` - `Data LivestreamGetActiveLivestreamsForLivestreamIDResponseData` - `Livestream LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestream` - `ID string` - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `Disabled string` Specifies if the livestream was disabled. - `IngestServer string` The server URL to which the RTMP encoder sends the video and audio data. - `MeetingID string` ID of the meeting. - `Name string` Name of the livestream. - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatus` - `const LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatusLive LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatus = "LIVE"` - `const LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatusIdle LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatus = "IDLE"` - `const LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatusErrored LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatus = "ERRORED"` - `const LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatusInvoked LivestreamGetActiveLivestreamsForLivestreamIDResponseDataLivestreamStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `UpdatedAt Time` Timestamp the object was updated at. The time is returned in ISO format. - `Session LivestreamGetActiveLivestreamsForLivestreamIDResponseDataSession` - `ID string` - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `ErrMessage string` - `IngestSeconds string` The time duration for which the input was given or the meeting was streamed. - `InvokedTime Time` Timestamp the object was invoked. The time is returned in ISO format. - `LivestreamID string` - `StartedTime Time` Timestamp the object was started. The time is returned in ISO format. - `StoppedTime Time` Timestamp the object was stopped. The time is returned in ISO format. - `UpdatedAt Time` Timestamp the object was updated at. The time is returned in ISO format. - `ViewerSeconds string` The total view time for which the viewers watched the stream. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetActiveLivestreamsForLivestreamID( context.TODO(), "app_id", "livestream_id", realtime_kit.LivestreamGetActiveLivestreamsForLivestreamIDParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "livestream": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "disabled": "disabled", "ingest_server": "ingest_server", "meeting_id": "meeting_id", "name": "name", "playback_url": "playback_url", "status": "LIVE", "stream_key": "stream_key", "updated_at": "2019-12-27T18:11:19.117Z" }, "session": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "err_message": "err_message", "ingest_seconds": "ingest_seconds", "invoked_time": "2019-12-27T18:11:19.117Z", "livestream_id": "livestream_id", "started_time": "2019-12-27T18:11:19.117Z", "stopped_time": "2019-12-27T18:11:19.117Z", "updated_at": "2019-12-27T18:11:19.117Z", "viewer_seconds": "viewer_seconds" } }, "success": true } ``` ## Fetch livestream details using livestream ID `client.RealtimeKit.Livestreams.GetLivestreamSessionForLivestreamID(ctx, appID, livestreamID, params) (*LivestreamGetLivestreamSessionForLivestreamIDResponse, error)` **get** `/accounts/{account_id}/realtime/kit/{app_id}/livestreams/{livestream_id}` Returns details of a livestream with sessions for the given livestream ID. Retreive the livestream ID using the `Start livestreaming a meeting` API. ### Parameters - `appID string` The app identifier tag. - `livestreamID string` - `params LivestreamGetLivestreamSessionForLivestreamIDParams` - `AccountID param.Field[string]` Path param: The account identifier tag. - `PageNo param.Field[int64]` Query param: The page number from which you want your page search results to be displayed. - `PerPage param.Field[int64]` Query param: Number of results per page. ### Returns - `type LivestreamGetLivestreamSessionForLivestreamIDResponse struct{…}` - `Data LivestreamGetLivestreamSessionForLivestreamIDResponseData` - `Livestream LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestream` - `ID string` ID of the livestream. - `CreatedAt string` Timestamp the object was created at. The time is returned in ISO format. - `Disabled string` Specifies if the livestream was disabled. - `IngestServer string` The server URL to which the RTMP encoder sends the video and audio data. - `MeetingID string` The ID of the meeting. - `Name string` Name of the livestream. - `PlaybackURL string` The web address that viewers can use to watch the livestream. - `Status LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatus` - `const LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatusLive LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatus = "LIVE"` - `const LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatusIdle LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatus = "IDLE"` - `const LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatusErrored LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatus = "ERRORED"` - `const LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatusInvoked LivestreamGetLivestreamSessionForLivestreamIDResponseDataLivestreamStatus = "INVOKED"` - `StreamKey string` Unique key for accessing each livestream. - `UpdatedAt string` Timestamp the object was updated at. The time is returned in ISO format. - `Paging LivestreamGetLivestreamSessionForLivestreamIDResponseDataPaging` - `EndOffset int64` - `StartOffset int64` - `TotalCount int64` - `Session LivestreamGetLivestreamSessionForLivestreamIDResponseDataSession` - `ID string` ID of the session. - `CreatedAt Time` Timestamp the object was created at. The time is returned in ISO format. - `ErrMessage string` - `IngestSeconds float64` The time duration for which the input was given or the meeting was streamed. - `InvokedTime Time` Timestamp the object was invoked. The time is returned in ISO format. - `LivestreamID string` - `StartedTime Time` Timestamp the object was started. The time is returned in ISO format. - `StoppedTime Time` Timestamp the object was stopped. The time is returned in ISO format. - `UpdatedAt Time` Timestamp the object was updated at. The time is returned in ISO format. - `ViewerSeconds float64` The total view time for which the viewers watched the stream. - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/realtime_kit" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.RealtimeKit.Livestreams.GetLivestreamSessionForLivestreamID( context.TODO(), "app_id", "livestream_id", realtime_kit.LivestreamGetLivestreamSessionForLivestreamIDParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` #### Response ```json { "data": { "livestream": { "id": "id", "created_at": "created_at", "disabled": "disabled", "ingest_server": "ingest_server", "meeting_id": "meeting_id", "name": "name", "playback_url": "playback_url", "status": "LIVE", "stream_key": "stream_key", "updated_at": "updated_at" }, "paging": { "end_offset": 1, "start_offset": 1, "total_count": 1 }, "session": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "err_message": "err_message", "ingest_seconds": 0, "invoked_time": "2019-12-27T18:11:19.117Z", "livestream_id": "livestream_id", "started_time": "2019-12-27T18:11:19.117Z", "stopped_time": "2019-12-27T18:11:19.117Z", "updated_at": "2019-12-27T18:11:19.117Z", "viewer_seconds": 0 } }, "success": true } ```