# Live Channels

## Create a live channel

<mark style="color:green;">`POST`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/channels`

#### Path Parameters

| Name       | Type   | Description   |
| ---------- | ------ | ------------- |
| bucket\_id | number | The bucket id |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

#### Request Body

| Name          | Type   | Description                                                           |
| ------------- | ------ | --------------------------------------------------------------------- |
| title         | string | The channel title                                                     |
| url           | string | The channel URL for ingesting the fingerprint from local server       |
| user\_defined | string | User-defined metadata. JSON format                                    |
| timeshift     | string | If enable the timeshifted fingerprint ingesting. 0 or 1. default is 0 |

{% tabs %}
{% tab title="201 Cake successfully retrieved." %}

```
{
    "data": {
        "uid": 1,
        "bucket_id": 8894,
        "acr_id": "b46ba66d2548b23611c6efabed035182",
        "state": 0,
        "title": "test",
        "url": "udp://192.168.1.10",
        "user_defined": {
            "city": "New York"
        },
        "timeshift": 0,
        "updated_at": "2020-12-25T05:05:17.000000Z",
        "created_at": "2020-12-25T05:05:17.000000Z",
        "id": 8,
        "bucket_type": "Live"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request POST 'https://api-v2.acrcloud.com/api/buckets/8894/channels' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{"title":"test", "url":"udp://192.168.1.10", "user_defined":{"city":"New York"}}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api-v2.acrcloud.com/api/buckets/8894/channels"

payload={
  "title":"test", 
  "url":"udp://192.168.1.10", 
  "user_defined":{"city":"New York"}
}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer token',
  'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, json=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

## List the channels

<mark style="color:blue;">`GET`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/channels`

#### Path Parameters

| Name       | Type   | Description   |
| ---------- | ------ | ------------- |
| bucket\_id | number | The bucket id |

#### Query Parameters

| Name      | Type   | Description                         |
| --------- | ------ | ----------------------------------- |
| search    | string | The title name.                     |
| page      | string | Page number                         |
| per\_page | string | The results number per page.        |
|           | string | asc or desc. Default is desc        |
| sort      | string | sort by id or status. default is id |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

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

```
{
    "data": [
        {
            "id": 8,
            "uid": 1,
            "bucket_id": 8894,
            "acr_id": "b46ba66d2548b23611c6efabed035182",
            "channel_id": "",
            "state": 1,
            "title": "test",
            "url": "udp://192.168.1.10",
            "user_defined": {
                "city": "New York"
            },
            "timeshift": 0,
            "created_at": "2020-12-25T05:05:17.000000Z",
            "updated_at": "2020-12-25T05:05:17.000000Z",
            "bucket_type": "Live"
        },
        {
            "id": 7,
            "uid": 1,
            "bucket_id": 8894,
            "acr_id": "3482b6e845a0fed8c129108d54ed9e20",
            "channel_id": "",
            "state": 1,
            "title": "123",
            "url": "123",
            "user_defined": {},
            "timeshift": 1,
            "created_at": "2020-09-16T03:36:59.000000Z",
            "updated_at": "2020-09-16T03:36:59.000000Z",
            "bucket_type": "Live"
        },
        {
            "id": 4,
            "uid": 1,
            "bucket_id": 8894,
            "acr_id": "f59e5c0e31a73db957b6c68fcda38c44",
            "channel_id": "",
            "state": 1,
            "title": "channel-4",
            "url": "http://127.0.0.1:123",
            "user_defined": {},
            "timeshift": 1,
            "created_at": "2019-06-25T07:46:24.000000Z",
            "updated_at": "2020-09-16T03:49:43.000000Z",
            "bucket_type": "Live"
        },
        {
            "id": 3,
            "uid": 1,
            "bucket_id": 8894,
            "acr_id": "6cc839537aa40b2854f4e520b7d0d58b",
            "channel_id": "",
            "state": 1,
            "title": "channel-3",
            "url": "http://127.0.0.1:123",
            "user_defined": {},
            "timeshift": 0,
            "created_at": "2019-06-25T07:46:21.000000Z",
            "updated_at": "2019-11-22T11:51:57.000000Z",
            "bucket_type": "Live"
        }
    ],
    "links": {
        "first": "https://api-v2.acrcloud.com/api/buckets/8894/channels?page=1",
        "last": "https://api-v2.acrcloud.com/api/buckets/8894/channels?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://api-v2.acrcloud.com/api/buckets/8894/channels",
        "per_page": 20,
        "to": 4,
        "total": 4
    }
}
```

{% endtab %}
{% endtabs %}

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

```
curl --location --request GET 'https://api-v2.acrcloud.com/api/buckets/8894/channels' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token'
```

{% endtab %}
{% endtabs %}

## Update a channel

<mark style="color:orange;">`PUT`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/channels/:id`

#### Path Parameters

| Name       | Type   | Description |
| ---------- | ------ | ----------- |
| bucket\_id | string | bucket id   |
| id         | string | channel id  |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

#### Request Body

| Name          | Type   | Description                                                     |
| ------------- | ------ | --------------------------------------------------------------- |
| title         | string | The channel title                                               |
| url           | string | The channel URL for ingesting fingerprints on your local server |
| user\_defined | string | User-define                                                     |
| timeshift     | string | If enable the timeshifted fingerprint ingestring. 0 or 1.       |

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

```
{
    "data": {
        "uid": 1,
        "bucket_id": 8894,
        "acr_id": "b46ba66d2548b23611c6efabed035182",
        "state": 0,
        "title": "test",
        "url": "udp://192.168.1.10",
        "user_defined": {
            "city": "New York"
        },
        "timeshift": 0,
        "updated_at": "2020-12-25T05:05:17.000000Z",
        "created_at": "2020-12-25T05:05:17.000000Z",
        "id": 8,
        "bucket_type": "Live"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request PUT 'https://api-v2.acrcloud.com/api/buckets/8884/channels/8' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{"title":"test"}'
```

{% endtab %}
{% endtabs %}

## Delete ingesting channels

<mark style="color:red;">`DELETE`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/channels/:ids`

#### Path Parameters

| Name       | Type   | Description                           |
| ---------- | ------ | ------------------------------------- |
| bucket\_id | string | The bucket id                         |
| ids        | string | One or multiple ids, separated by ',' |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

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

```
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request DELETE 'https://api-v2.acrcloud.com/api/buckets/8894/channels/8' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token'
```

{% endtab %}
{% endtabs %}

## Import channels

<mark style="color:green;">`POST`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/rec-channels`

Import channels to LiveRec bucket.

#### Path Parameters

| Name       | Type   | Description |
| ---------- | ------ | ----------- |
| bucket\_id | string | Bucket id   |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

#### Request Body

| Name | Type   | Description                                    |
| ---- | ------ | ---------------------------------------------- |
| ids  | string | One or multiple channels ids. Separated by ',' |

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

```
{
    "data": [
        {
            "id": 5,
            "acr_id": "a25b69e996f6f220ddb7a0c4a53a11c1",
            "title": "channel-5",
            "state": 0,
            "bucket_id": 8885,
            "original_bucket_id": 8882,
            "created_at": "2020-12-25 07:39:29",
            "updated_at": "2020-12-25 07:39:29",
            "bucket_type": "LiveRec",
            "user_defined": {}
        },
        {
            "id": 6,
            "acr_id": "08e491a33c5c1bb7418ce49254fc35ed",
            "title": "adf",
            "state": 0,
            "bucket_id": 8885,
            "original_bucket_id": 8882,
            "created_at": "2020-12-25 07:39:29",
            "updated_at": "2020-12-25 07:39:29",
            "bucket_type": "LiveRec",
            "user_defined": {
                "channel_name": "abc",
                "channel_type": "def"
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request POST 'https://api-v2.acrcloud.com/api/buckets/8885/rec-channels' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{"ids":[5,6]}'
```

{% endtab %}
{% endtabs %}

## Delete rec channels

<mark style="color:red;">`DELETE`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/rec-channels/:ids`

#### Path Parameters

| Name       | Type   | Description                                   |
| ---------- | ------ | --------------------------------------------- |
| bucket\_id | number | The bucket id                                 |
| ids        | string | One or multiple channel ids. Separated by ',' |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

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

```
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request DELETE 'https://api-v2.acrcloud.com/api/buckets/8895/rec-channels/5,6' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token'
```

{% endtab %}
{% endtabs %}

## Create timeshift channels

<mark style="color:green;">`POST`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/timeshift-channels`

#### Path Parameters

| Name       | Type   | Description   |
| ---------- | ------ | ------------- |
| bucket\_id | number | The bucket id |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

#### Request Body

| Name | Type   | Description                                                                   |
| ---- | ------ | ----------------------------------------------------------------------------- |
| time | number | The timeshift fingerprints keep-alive time (In hours). The default is 1 hour. |
| id   | number | The live channel id                                                           |

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

```
{
    "data": {
        "id": 5,
        "title": "channel-5",
        "state": 0,
        "bucket_id": 8893,
        "acr_id": "a25b69e996f6f220ddb7a0c4a53a11c1",
        "time": 24,
        "original_bucket_id": 8882,
        "created_at": "2020-12-25 07:57:52",
        "updated_at": "2020-12-25 07:57:52",
        "bucket_type": "LiveTimeshift",
        "user_defined": {}
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request POST 'https://api-v2.acrcloud.com/api/buckets/8893/timeshift-channels' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{"id":5, "time":24}'
```

{% endtab %}
{% endtabs %}

## Delete timeshift channels

<mark style="color:red;">`DELETE`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/timeshift-channels/:ids`

#### Path Parameters

| Name       | Type   | Description                                   |
| ---------- | ------ | --------------------------------------------- |
| ids        | string | One or multiple channel ids, Separated by ',' |
| bucket\_id | number | The bucket id                                 |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

## Get Live/Timeshift Channels status

<mark style="color:red;">`GET`</mark> `https://api-v2.acrcloud.com/api/buckets/:bucket_id/channels-stat`

#### Path Parameters

| Name       | Type   | Description                  |
| ---------- | ------ | ---------------------------- |
| bucket\_id | number | The Live/Timeshift bucket id |

#### Query Parameters

| Name | Type     | Description                       |
| ---- | -------- | --------------------------------- |
| date | datetime | <p>For example:<br>2024-05-17</p> |

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer token |

#### Response

|         |        |                                                                                                                                                                                                                                                                                                                                                                                          |
| ------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id      | number | The channel id                                                                                                                                                                                                                                                                                                                                                                           |
| title   | string | The channel name                                                                                                                                                                                                                                                                                                                                                                         |
| acr\_id | string | acr id                                                                                                                                                                                                                                                                                                                                                                                   |
| hour    | string | Hour (24-hour clock) as a zero-padded decimal number. utf+0                                                                                                                                                                                                                                                                                                                             |
| seconds | number | <p>The fingerprint duration that the server side received.</p><p>This value has a certain margin of error (mainly due to the possibility of silence at the beginning or end of fingerprint fragments). We consider that if the total duration of fingerprints received in a complete hour is 3500 < seconds <= 3600, it indicates that the data received during this hour is normal.</p> |

```json
[ {
            "id": 1800,
            "title": "channel1",
            "acr_id": "556ddb768bba7d38fa22fcb3eaf7b6ea",
            "stats": {
                "2024-05-17": [
                    {
                        "hour": "00", 
                        "seconds": 3578
                    },
                    {
                        "hour": "01",
                        "seconds": 3582
                    },
                    {
                        "hour": "02",
                        "seconds": 3578
                    },
                    {
                        "hour": "03",
                        "seconds": 288
                    }
                ]
            }
  },
……
]
```

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

```bash
curl --location 'https://ap-api-v2.acrcloud.com/api/buckets/12334/channels-stat?date=2024-05-17' \
--header 'Authorization: Bearer YOUR_TOKEN’ \
--header 'Accept: application/json'
```

{% endtab %}

{% tab title="Python" %}

````python
```python
import requests

url = "https://api-v2.acrcloud.com/api/buckets/12334/channels-stat?date=2024-05-17"

payload = {}
headers = {
  'Authorization': 'Bearer YOUR_TOKEN',
  'Accept': 'application/json'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```
````

{% endtab %}
{% endtabs %}


---

# 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.acrcloud.com/reference/console-api/buckets/live-channels.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.
