Live SDKs JavaScript v1
Live SDKs JavaScript
Live SDKs
JavaScript
Version 1

List live events

Copy link

A user can get a list of ongoing live events using the LiveEventListQuery object. The user can filter their search by host type, created date, participant count, duration, live event ID, and more by using the LiveEventListQueryParams object. If the user knows the ID of the live event, the user can use the ID to directly find the live event. Retrieving a live event from the list of ongoing live events also gives access to the chat for the live event. If the chat isn't automatically made available and displayed in the participant view, call fetchOpenChannel() to manually retrieve the chat.

/*
export interface LiveEventListQueryParams {
    types?: LiveEventType[];
    liveEventState?: LiveEventState;
    createdAtRange?: [number | undefined, number | undefined];
    participantCountRange?: [number | undefined, number | undefined];
    durationRange?: [number | undefined, number | undefined];
    liveEventIds?: string[];
    createdByUserIds?: string[];
    limit?: number;
}
*/

const params = {
    createdByUserIds: [USER_ID],
    limit: 10
};

const query = SendbirdLive.createLiveEventListQuery(params)
try {
    if(query.hasNext) {
        const events = await query.next()
        console.log(events)
    }
} catch (e) {
    // Handle error
}

Note: Keep your original event query in order to paginate and get additional events using query.next().

To get a specific live event, use getLiveEvent() with the event's ID.

try {
  const liveEvent = await SendbirdLive.getLiveEvent(liveEventId);
} catch (e) {
  // Handle error.
}

LiveEventListQueryParams

Copy link
Property nameTypeDescription

types

LiveEventType[]

Filters query results to include live events with the specified live event type.

state

LiveEventState

Filters query results to include live events with the specified live event state.

createdAtRange

Range

Filters query results to include live events that were created within the specified range in Unix milliseconds.

participantCountRange

Range

Filters query results to include live events where the number of current participants is within the specified range.

durationRange

Range

Filters query results to include live events whose duration is within the specified range.

liveEventIds

String

Filters query results to include live events with the specified live event IDs.

createdByUserIds

String

Filters query results to include live events that were created by the specified user IDs.

limit

int

Sets the number of rooms to be retrieved at once.