# List

To list all sessions you need to execute a **GET** request against the **/sessions** endpoint.&#x20;

Since potentially there could be thousands of sessions, pagination is supported with **limit**, **order** and **after** arguments. Read about [pagination](https://docs.digitalsamba.com/reference/rest-api/pagination) to learn the details of it. By default maximum 100 sessions will be returned in the response.

{% hint style="info" %}
To filter sessions from a concrete date interval use the **date\_start** and **date\_end** query parameters: api/v1/sessions?**date\_start**=2024-04-03&**date\_end**=2024-04-18
{% endhint %}

{% hint style="info" %}
To list all sessions for a concrete room execute a **GET** request against the **/sessions** endpoint and add the **room\_id** param. \
\
api/v1/sessions?**room\_id**=87a5d383-9e79-44ea-b382-686e430f4ecc

You can also use:\
api/v1/rooms/87a5d383-9e79-44ea-b382-686e430f4ecc/sessions
{% endhint %}

{% hint style="info" %}
If you want to retrieve the details of one concrete session, execute a **GET** request against the **api/v1/sessions/:id** endpoint
{% endhint %}

{% hint style="info" %}
If you want to filter live sessions only (haven't ended yet), then use the **live** parameter:\
api/v1/sessions?**live**=true\
\
If you want to filter ended sessions only: \
api/v1/sessions?**live**=false
{% endhint %}

#### Request (listing all sessions)

{% tabs %}
{% tab title="cURL" %}

```bash
curl --request GET \
  --url https://api.digitalsamba.com/api/v1/sessions \
  --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY
```

{% endtab %}

{% tab title="Java" %}

```java
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Base64;
import java.util.Map;

String TEAM_ID = "YOUR_TEAM_ID";
String DEVELOPER_KEY = "YOUR_DEVELOPER_KEY";
String authorizationHeader = "Bearer " + Base64.getEncoder().encodeToString((TEAM_ID + ":" + DEVELOPER_KEY).getBytes());

HttpRequest request = HttpRequest.newBuilder()
  .GET()
  .uri(new URI("https://api.digitalsamba.com/api/v1/sessions"))
  .header("Authorization", authorizationHeader)
  .build();

HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

System.out.println("Status code: " + response.statusCode());
System.out.println("Body: " + response.body());
```

{% endtab %}
{% endtabs %}

#### Response (200 OK)

```json
{
    "total_count": 8096,
    "data": [
          {
            "id": "edb7a1cb-0627-44ed-9ae4-62a344d6e8a9",
            "start_time": "2024-03-27 08:15:36",
            "room_id": "95d36f70-a35e-4547-a9da-4f8c013c2874",
            "room_external_id": null,
            "description": null,
            "friendly_url": "MyWebinar",
            "room_is_deleted": false,
            "participants_max": 200,
            "participants_live": 150,
            "participants_total": 300,
            "live": true --If the session is still running, then end_time will be null
         },
         {
            "id": "f875d3dd-1cf8-421e-930a-927cce0bf9dd",
            "start_time": "2024-03-27 08:15:36",
            "end_time": "2024-03-27 08:27:38",
            "room_id": "87a5d383-9e79-44ea-b382-686e430f4ecc",
            "room_external_id": null,
            "description": null,
            "friendly_url": "DailyEnglishLessons",
            "room_is_deleted": false,
            "participants_max": 3,
            "participants_live": 0,
            "participants_total": 3,
            "live": false
        },
        ...............98 more sessions...............
    ]
} 
```

{% hint style="info" %}
The **total\_count** is the total amount of sessions that happened. It is **NOT** the amount of sessions in the current page returned in the **data** array. In the above example you have 8096 sessions in total, but in the data array there will be maximum 100 sessions (the default limit argument value).
{% endhint %}

#### Request (get a concrete session)

{% tabs %}
{% tab title="cURL" %}

```bash
curl --request GET \
  --url https://api.digitalsamba.com/api/v1/sessions/cf6706ee-5971-464d-8cb9-da3a0df74cf1 \
  --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY
```

{% endtab %}

{% tab title="Java" %}

```java
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Base64;
import java.util.Map;

String TEAM_ID = "YOUR_TEAM_ID";
String DEVELOPER_KEY = "YOUR_DEVELOPER_KEY";
String authorizationHeader = "Bearer " + Base64.getEncoder().encodeToString((TEAM_ID + ":" + DEVELOPER_KEY).getBytes());
//Put your session id here - this value is just an example
String sessionId = "cf6706ee-5971-464d-8cb9-da3a0df74cf1";

HttpRequest request = HttpRequest.newBuilder()
  .GET()
  .uri(new URI("https://api.digitalsamba.com/api/v1/sessions/" + roomId))
  .header("Authorization", authorizationHeader)
  .build();

HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

System.out.println("Status code: " + response.statusCode());
System.out.println("Body: " + response.body());
```

{% endtab %}
{% endtabs %}

#### Response (200 OK)

```json
{
    "id": "cf6706ee-5971-464d-8cb9-da3a0df74cf1",
    "room_id": "87a5d383-9e79-44ea-b382-686e430f4ecc",
    "room_friendly_url": "Scrum",
    "room_privacy": "public",
    "room_max_participants": 100,
    "room_is_deleted": false,
    "session_id": "c7bcb25f-caf7-4700-8344-46b484bb6b3d",
    "session_duration": 15,
    "session_live": false,
    "session_start_time": "2024-03-22T09:18:49Z",
    "session_end_time": "2024-03-22T09:34:34Z",
    "participation_minutes": 16,
    "desktop_participation_minutes": 16,
    "mobile_participation_minutes": 0,
    "tablet_participation_minutes": 0,
    "smarttv_participation_minutes": 0,
    "broadcasted_minutes": 16,
    "subscribed_minutes": 0,
    "screen_broadcasted_minutes": 0,
    "screen_subscribed_minutes": 0,
    "live_participants": 0,
    "active_participants": 1,
    "desktop_participants": 1,
    "mobile_participants": 0,
    "tablet_participants": 0,
    "smarttv_participants": 0,
    "max_concurrent_participants": 1,
    "e2ee_minutes": 16,
    "recorded_minutes": 0,
    "stored_recorded_minutes": 0,
    "whiteboard_minutes": 0,
    "breakout_minutes": 0,
    "presentation_minutes": 0,
    "active_roles": 1,
    "public_chat_posts": 0,
    "questions": 0,
    "answers": 0
}
```
