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

val filters = mutableMapOf(
    "members" to mutableMapOf("\$in" to listOf("tommaso")),
    "starts_at" to mutableMapOf("\$lt" to threeHoursFromNow),
    //"ended_at" to false,
)
val sort = listOf(SortField.Asc("starts_at"))
val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true)

Calls that are ongoing / currently have participants

client.queryCalls(mapOf("ongoing" to true)).let { result ->
    result
        .onSuccess { calls: QueriedCalls -> Log.d(TAG, "Query success: $calls") }
        .onError { error: Error -> Log.e(TAG, "Query failure: ${error.message}") }
}

Calls filters on a custom property

val filters = mutableMapOf(
    "custom.color" to "red",
)
val sort = listOf(SortField.Asc("starts_at"))
val result = client.queryCalls(filters=filters, sort=sort, limit=10, watch=true)

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.

// Request first page (prev and next are not set)
val resultPage1 = client.queryCalls(filters=emptyMap(), limit=10)
...
val resultPage1 = queryResult as Result.Success

// Request second page with prev and next parameters from previous response
val resultPage2 = client.queryCalls(
    filters = emptyMap(),
    limit = 10,
    prev = resultPage1.value.prev,
    next = resultPage1.value.next
)

Fields for Query Calls

You can filter on the following fields

OptionDescription
typeThe call type. Typically default, livestream etc
idThe id for this call
cidThe cid for this call. IE default:123
created_by_user_idThe user id who created the call
created_atWhen the call was created
updated_atWhen the call was updated
starts_atWhen the call starts at
ended_atWhen the call ended
backstageIf the call is in backstage mode or not
membersCheck if you are a member of this call
customYou can query custom data using the “custom.myfield” syntax

Sorting is supported on the fields below:

  • starts_at
  • created_at
  • updated_at
  • ended_at
  • type
  • id
  • cid

If you specify watch the SDK will automatically keep the data about these calls updated. This allows you to show a live preview of who’s in the call.

© Getstream.io, Inc. All Rights Reserved.