Skip to content

Querying Calls

For many video calling, livestream or audio rooms apps you'll want to show:

  • Upcoming calls
  • Calls that are currently live
  • Popular livestreams/audio rooms with a link to the recording

The SDK makes it easy to query calls

Example Queries

Calls that are about to start

// Filter calls that will start in 3 hours and include me
var filters = new List<IFieldFilterRule>
{
    CallFilter.StartsAt.LessThanOrEquals(DateTime.Now.AddHours(3)),
    CallFilter.Members.EqualsTo(_client.LocalUser)
};

// Order them by how soon they start
var result = await _client.QueryCallsAsync(filters, CallSort.OrderByAscending(CallSortField.StartsAt), limit: 25);

Calls filters on a custom property

// Filter calls by custom property. For example you can attach a "tag" property to a call and get calls that contain any of the provided tags
var filters = new List<IFieldFilterRule>
{
    CallFilter.Custom("tag").In("xbox", "ps", "switch"),
};

// Order them by how soon they start
var sort = CallSort.OrderByAscending(CallSortField.StartsAt);

var result = await _client.QueryCallsAsync(filters, sort, limit: 25);

Pagination The query response is paginated and the maximum count of items is defined by the limit parameter. Use the prev and next parameters from the last response as parameters for requesting the next page.

var filters = new List<IFieldFilterRule>
{
    CallFilter.CreatedAt.GreaterThan(DateTime.Now.AddHours(-24))
};

var result = await _client.QueryCallsAsync(filters, CallSort.OrderByDescending(CallSortField.CreatedAt), limit: 25);

// queried calls, depending on how many calls satisfy the filter this can be only a subset or a single "page" of results
var calls = result.Calls;

// In order to get the next "page" of results, use this token as a "next" argument in the QueryCallsAsync method
var next = result.Next;

// In order to get the previous "page" of results, use this token as a "prev" argument in the QueryCallsAsync method
var prev = result.Prev;

Fields for Query Calls

You can filter with CallFilter on the following fields:

Filter field Description
CallFilter.Type The call type. Typically default, livestream etc
CallFilter.Id The id for this call
CallFilter.Cid The cid for this call. IE default:123
CallFilter.CreatedByUserId The user id who created the call
CallFilter.CreatedAt When the call was created
CallFilter.UpdatedAt When the call was updated
CallFilter.StartsAt When the call starts at
CallFilter.EndedAt When the call ended
CallFilter.Backstage If the call is in backstage mode or not
CallFilter.Members Check if you are a member of this call
CallFilter.Custom() Query your own custom data by field name

Sorting is done with CallSort and one of the CallSortField values:

Sort field Description
CallSortField.StartsAt When the call starts at
CallSortField.CreatedAt When the call was created
CallSortField.UpdatedAt When the call was updated
CallSortField.Type The call type
CallSortField.Id The id for this call
CallSortField.Cid The cid for this call

Watching queried calls

Pass watch: true and the SDK will keep the returned calls updated as events arrive. This allows you to show a live preview of who's in the call.

var result = await _client.QueryCallsAsync(filters, sort, limit: 25, watch: true);