# List channels

Retrieve a paginated list of all channels in your account.

```http
GET /v1/channels
```

{% hint style="info" %}
This endpoint requires authentication using a Bearer token.
{% endhint %}

Authorization header:

```http
Authorization: Bearer YOUR_API_KEY
```

## Query Parameters

| Parameter | Type    | Required | Default | Description                                             |
| --------- | ------- | -------- | ------- | ------------------------------------------------------- |
| `page`    | integer | No       | `1`     | Page number for pagination                              |
| `size`    | integer | No       | `50`    | Number of results per page (max: 100)                   |
| `sort`    | string  | No       | `""`    | Sort order (e.g., `created`, `-created` for descending) |

## Response

### Success Response

**Status Code:** `200 OK`

```json
{
  "pager": {
    "page": 1,
    "totalPages": 5,
    "totalResults": 47,
    "sort": ""
  },
  "channels": [
    {
      "id": "abc123xyz",
      "key": "ch_def456",
      "name": "Product Tutorials",
      "description": "Video tutorials for our product lineup",
      "accountId": "acc_789",
      "version": 1,
      "planType": 2,
      "templateKey": "tmpl_modern",
      "status": 1,
      "created": "2024-01-15T10:30:00Z",
      "updated": "2024-01-20T14:45:00Z"
    },
    {
      "id": "xyz789abc",
      "key": "ch_ghi012",
      "name": "Marketing Videos",
      "description": "Promotional content and ads",
      "accountId": "acc_789",
      "version": 1,
      "planType": 2,
      "templateKey": "tmpl_light",
      "status": 1,
      "created": "2024-01-10T08:15:00Z",
      "updated": "2024-01-18T11:30:00Z"
    }
  ]
}
```

### Response Fields

#### Pager Object

| Field          | Type    | Description                              |
| -------------- | ------- | ---------------------------------------- |
| `page`         | integer | Current page number                      |
| `totalPages`   | integer | Total number of pages available          |
| `totalResults` | integer | Total number of channels in your account |
| `sort`         | string  | Applied sort order                       |

#### Channel Object

| Field         | Type     | Description                            |
| ------------- | -------- | -------------------------------------- |
| `id`          | string   | Internal channel identifier            |
| `key`         | string   | Public channel key (use for embedding) |
| `name`        | string   | Channel display name                   |
| `description` | string   | Channel description                    |
| `accountId`   | string   | Owner account identifier               |
| `version`     | integer  | Channel version number                 |
| `planType`    | integer  | Associated plan type                   |
| `templateKey` | string   | Applied template key                   |
| `status`      | integer  | Channel status (1 = Published)         |
| `created`     | datetime | Creation timestamp (ISO 8601)          |
| `updated`     | datetime | Last update timestamp (ISO 8601)       |

## Error Responses

| Status Code | Description                               |
| ----------- | ----------------------------------------- |
| `401`       | Unauthorized - Invalid or missing API key |
| `500`       | Internal Server Error                     |

## Code Examples

{% code title="cURL" %}

```bash
curl -X GET "https://api.dyntube.com/v1/channels?page=1&size=20" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

{% endcode %}

{% code title="JavaScript" %}

```javascript
const response = await fetch(
  'https://api.dyntube.com/v1/channels?page=1&size=20',
  {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  }
);

const data = await response.json();
console.log(`Found ${data.pager.totalResults} channels`);

data.channels.forEach(channel => {
  console.log(`- ${channel.name} (${channel.key})`);
});
```

{% endcode %}

{% code title="Python" %}

```python
import requests

response = requests.get(
    'https://api.dyntube.com/v1/channels',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    params={'page': 1, 'size': 20}
)

data = response.json()
print(f"Found {data['pager']['totalResults']} channels")

for channel in data['channels']:
    print(f"- {channel['name']} ({channel['key']})")
```

{% endcode %}

{% code title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dyntube.com/v1/channels?page=1&size=20');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo "Found " . $data['pager']['totalResults'] . " channels\n";

foreach ($data['channels'] as $channel) {
    echo "- " . $channel['name'] . " (" . $channel['key'] . ")\n";
}
```

{% endcode %}

## Pagination Example

```javascript
async function getAllChannels() {
  const allChannels = [];
  let page = 1;
  let totalPages = 1;

  do {
    const response = await fetch(
      `https://api.dyntube.com/v1/channels?page=${page}&size=50`,
      {
        headers: {
          'Authorization': 'Bearer YOUR_API_KEY'
        }
      }
    );

    const data = await response.json();
    allChannels.push(...data.channels);
    totalPages = data.pager.totalPages;
    page++;
  } while (page <= totalPages);

  return allChannels;
}
```

## See Also

* [Get Channel](https://dev.dyntube.com/reference/channels/broken-reference) - Retrieve a single channel
* [Create Channel](https://dev.dyntube.com/reference/channels/broken-reference) - Create a new channel
* [Channels API Overview](https://dev.dyntube.com/reference/channels/broken-reference) - API overview and authentication
