# List

To list the existing polls for a room you need to execute a **GET** request against the **/rooms/:roomId/polls** endpoint.&#x20;

Since potentially there could be a lot of polls, pagination is supported with **limit**, **order** and **after** arguments. Read about [pagination](/reference/rest-api/pagination.md) to learn the details of it. By default maximum 100 polls will be returned in the response.

{% hint style="info" %}
If you want to retrieve the details of one concrete poll execute a **GET** request against  the **/rooms/:roomId/polls/:id** endpoint
{% endhint %}

#### Request (listing all polls)

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request GET \
  --url https://api.digitalsamba.com/api/v1/rooms/c39d7c40-7ff7-4faa-b06f-698a639a9523/polls \
  --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY
```

{% endcode %}
{% 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 room id or friendly_url (name) here - this value is just an example
String roomId = "c39d7c40-7ff7-4faa-b06f-698a639a9523";

HttpRequest request = HttpRequest.newBuilder()
  .GET()
  .uri(new URI("https://api.digitalsamba.com/api/v1/rooms/" + roomId + "/polls"))
  .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": 200,
  "data": [
    {
      "id": "c15102d9-ed47-468c-8e5a-86be0c97c296",
      "question": "How many languages have you learned?",
      "anonymous": true,
      "multiple": true,
      "status": "created",
      "created_at": "2024-06-27T12:33:21Z"
    },
    {
      "id": "e221af19-6458-438d-820e-afc7c6077112",
      "question": "How old are you?",
      "anonymous": true,
      "multiple": false,
      "status": "ended",
      "created_at": "2024-06-21T14:25:41Z"
    }
    ...............98 more rooms...............
  ]
} 
```

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

#### Request (get a concrete poll)

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request GET \
  --url https://api.digitalsamba.com/api/v1/rooms/c39d7c40-7ff7-4faa-b06f-698a639a9523/polls/c15102d9-ed47-468c-8e5a-86be0c97c296 \
  --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY
```

{% endcode %}
{% 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 room id here - this value is just an example
String roomId = "c39d7c40-7ff7-4faa-b06f-698a639a9523";

//Put your poll id here - this value is just an example
String pollId = "c15102d9-ed47-468c-8e5a-86be0c97c296";

HttpRequest request = HttpRequest.newBuilder()
  .GET()
  .uri(new URI("https://dev-api.monza.digitalsamba.com/api/v1/rooms/" + roomId + "/polls/" + pollId))
  .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": "c15102d9-ed47-468c-8e5a-86be0c97c296",
  "question": "How many languages have you learned?",
  "anonymous": true,
  "multiple": true,
  "status": "created",
  "options": [
    {
      "id": "ee0300ba-be73-4e8a-954a-3a0c2218913e",
      "text": "One"
    },
    {
      "id": "34914c0c-2bb6-4e58-9d0c-e393c4b61f5f",
      "text": "Two"
    },
    {
      "id": "93d07105-704d-4ced-a924-b266260012ce",
      "text": "Three"
    },
    {
      "id": "bf4029ac-461d-4488-ae5e-c6ba03be8ee5",
      "text": "More than three"
    }
  ],
  "created_at": "2024-06-27T12:33:21Z"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalsamba.com/reference/rest-api/polls/list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
