How can I get information about multiple sessionIds in one Insights GraphQL query? How can I get information about multiple sessionIds in one Insights GraphQL query?

How can I get information about multiple sessionIds in one Insights GraphQL query?

Vonage API Support

Objective

Querying multiple sessions at once using the Insights GraphQL query.

Applies To

  • Insights
  • Session IDs

Procedure

To simplify querying information for several Sessions at once, you can use a sessions request to specify multiple sessionIds (plural) in a single request. For this:

  • Use sessionIds (plural) when requesting information about a Session instead of querying on a single sessionId (singular).
  • The sessionIds parameter expects a string array of sessionIds or you can just pass in a single sessionId as a string.

Create a new sessions request that looks like this:

sessions(
  sessionIds: [String]!
  first: Int
  endCursor: String
): Sessions!

It receives three parameters:

  • sessionIds (required): An array of sessionIds. Note that If you want the data from only one session you can just pass one sessionId as a String or an Array with one element.
  • first (optional): First N records of the results.
  • endCursor (optional): The cursor at which to continue pagination.

The response will be a Sessions object that implements the interface ResourceCollection, which includes these three fields:

  • totalCount: Int!
  • pageInfo: PageInfo!
  • resources: [Session]!

An example of how you might query for three sessionIds in the same request.

{
project(projectId: 12345678) {
   sessionData {
     sessions(
        sessions(sessionIds: ["your_session_id_1", "your_session_id_2", "your_session_id_3"]) {
         totalCount
         pageInfo {
           endCursor
         }
         resources {
           mediaMode
           meetings {
             resources {
               meetingId
               createdAt
               destroyedAt
             }
           }
         }
       }
   }
 }
}

The response for the requested session information will look like this:

{
  "data": {
    "project": {
      "sessionData": {
        "sessions": {
        "totalCount": 3,
         "pageInfo": {
           "endCursor": null
          },
          "resources": [
            {
              "mediaMode": "routed",
              "sessionId": "your_session_id_1",
              "meetings": {
                "resources": [
                  {
                    "meetingId": "3b06de2e-1ea3-4700-b5b9-d38953305344",
                    "createdAt": "2018-10-07T00:00:00.931Z",
                    "destroyedAt": "2018-10-07T00:01:16.886Z"
                  }
                ]
              }
            }'
            {
              "mediaMode": "routed",
              "sessionId": "your_session_id_2",
              "meetings": {
                "resources": [
                  {
                    "meetingId": "1b68e430-b10d-4ccc-8e94-83abdf7b91ec",
                    "createdAt": "2018-10-07T00:00:21.748Z",
                    "destroyedAt": "2018-10-07T00:01:37.785Z"
                  }
                ]
              }
            },
            {
              "mediaMode": "routed",
              "sessionId": "your_session_id_3",
              "meetings": {
                "resources": [
                {
  "meetingId":"b8e7f88a-ac17-4d03-840f-0f9d0719bf1a",
              "createdAt":"2018-10-07T00:01:29.640Z",
              "destroyedAt": "2018-10-07T00:02:45.572Z"
                  }
                ]
              }
            }
          ]
        }
      }
    }
  }
}

Note that if you pass many sessionIds, your results may be paginated. In this case, you can make new requests using the endCursor value.

Additional Information

For more information, see our developer documentation on the Insights GraphQL query below:

Vonage Video API Opentok Environment 

Vonage Video API Unified Environment

How to recognize if I'm using Vonage Video API Unified Environment or Vonage Video API OpenTok environment?