# Buckets

## Create a bucket

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

Create an empty bucket, then you can upload audio files or add channels to this bucket to create your fingerprint database.

#### Headers

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

#### Request Body

| Name               | Type   | Description                                                      |
| ------------------ | ------ | ---------------------------------------------------------------- |
| name               | string | The bucket name                                                  |
| region             | string | eu-west-1,us-west-2,ap-southeast-1                               |
| type               | string | File,Live,LiveRec,LiveTimeshift                                  |
| net\_type          | number | 0,1,2                                                            |
| labels             | array  | The labels for the bucket. For examples: \["Music", "Comercial"] |
| metadata\_template | string | Metadata template                                                |

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

```
{
    "data": {
        "id": 8881,
        "uid": 1,
        "name": "bucket_music",
        "type": "File",
        "node": "127.0.0.1-871",
        "state": 1,
        "region": "ap-southeast-1",
        "metadata_template": "{\"artist\":{\"default\":\"abc\"}, \"album\":{\n\"type\":\"select\", \"default\":\"334\", \"options\":[\"123\", \"334\"]}}",
        "labels": [
            "Music",
            "Video"
        ],
        "net_type": 1,
        "created_at": "2019-03-01 15:31:25",
        "updated_at": "2019-08-16 07:17:32",
        "num": 10,
        "size": "300000",
        "access_permission": "private"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request POST 'https://api-v2.acrcloud.com/api/buckets' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{
	"name":"avbucket",
	"type":"File",
	"labels":["Music", "Video"],
	"net_type":1,
	"region":"ap-southeast-1"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

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

data={"name":"avbucket",
      "type":"File",
      "labels":["Music", "Video"],
      "net_type":1,
      "region":"ap-southeast-1"
}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer token'
}

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

print(response.text)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api-v2.acrcloud.com/api/buckets',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('name' => 'testbucket','region' => 'ap-southeast-1','type' => 'File'),
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Authorization: Bearer token'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({"name":"avbucket","type":"File","labels":["Music","Video"],"net_type":1,"region":"ap-southeast-1"});

var config = {
  method: 'post',
  url: 'https://api-v2.acrcloud.com/api/buckets',
  headers: { 
    'Accept': 'application/json', 
    'Authorization': 'Bearer token', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}
{% endtabs %}

## List Buckets

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

Return a list of your buckets.

#### Query Parameters

| Name      | Type   | Description                                |
| --------- | ------ | ------------------------------------------ |
| page      | number | The page number                            |
| per\_page | number | The results number per page. Default is 20 |
| region    | string | eu-west-1,us-west-2,ap-southeast-1         |
| type      | string | File,Live,LiveRec,LiveTimeshift            |

#### Headers

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

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

```
{
    "data": [
        {
            "id": 14791,
            "uid": 19,
            "name": "test",
            "type": "Live",
            "state": 1,
            "region": "eu-west-1",
            "metadata_template": null,
            "labels": [
                "TV"
            ],
            "net_type": 1,
            "created_at": "2020-07-16 11:09:20",
            "updated_at": "2020-07-16 11:09:20",
            "num": 0,
            "size": 0,
            "access_permission": "private"
        },
        {
            "id": 14556,
            "uid": 19,
            "name": "adsfasdf",
            "type": "LiveTimeshift",
            "state": 1,
            "region": "eu-west-1",
            "metadata_template": "",
            "labels": [
                ""
            ],
            "net_type": 1,
            "created_at": "2020-06-24 11:07:00",
            "updated_at": "2020-06-24 11:07:00",
            "num": 0,
            "size": 0,
            "access_permission": "private"
        },
        {
            "id": 12310,
            "uid": 19,
            "name": "eu_shared_bucket2",
            "type": "LiveRec",
            "state": 1,
            "region": "eu-west-1",
            "metadata_template": "",
            "labels": [
                "Radio"
            ],
            "net_type": 1,
            "created_at": "2019-10-30 07:54:56",
            "updated_at": "2019-10-30 07:54:56",
            "num": 0,
            "size": 0,
            "access_permission": "private"
        },
        {
            "id": 12309,
            "uid": 19,
            "name": "eu_shared_bucket",
            "type": "LiveRec",
            "node": "",
            "state": 1,
            "region": "eu-west-1",
            "metadata_template": "",
            "labels": [
                "Radio"
            ],
            "net_type": 1,
            "created_at": "2019-10-30 07:53:58",
            "updated_at": "2019-10-30 07:53:58",
            "num": 0,
            "size": 0,
            "access_permission": "private"
        },
        {
            "id": 1159,
            "uid": 19,
            "name": "us_bucket",
            "type": "File",
            "state": 1,
            "region": "global",
            "metadata_template": "",
            "labels": [
                "Music"
            ],
            "net_type": 0,
            "created_at": "2016-05-11 06:49:55",
            "updated_at": "2017-07-17 11:48:06",
            "num": 7,
            "size": "1487",
            "access_permission": "private"
        },
        {
            "id": 1116,
            "uid": 19,
            "name": "offline-bucket",
            "type": "File",
            "node": "10.12.12.236-850",
            "state": 1,
            "region": "eu-west-1",
            "metadata_template": "",
            "labels": [
                "Music"
            ],
            "net_type": 2,
            "created_at": "2016-05-01 07:10:16",
            "updated_at": "2018-01-05 16:41:15",
            "num": 0,
            "size": 0,
            "access_permission": "private"
        }
    ],
    "links": {
        "first": "https://api-v2.acrcloud.com/api/buckets?page=1",
        "last": "https://api-v2.acrcloud.com/api/buckets?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://api-v2.acrcloud.com/api/buckets",
        "per_page": 20,
        "to": 6,
        "total": 6
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
equest GET 'https://api-v2.acrcloud.com/api/buckets?region=eu-west-1' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api-v2.acrcloud.com/api/buckets?region=eu-west-1"

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

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

print(response.text)
```

{% endtab %}

{% tab title="PHP" %}

```php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api-v2.acrcloud.com/api/buckets?region=eu-west-1',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Authorization: Bearer token'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
var data = qs.stringify({
  
});
var config = {
  method: 'get',
  url: 'https://api-v2.acrcloud.com/api/buckets?region=eu-west-1',
  headers: { 
    'Accept': 'application/json', 
    'Authorization': 'Bearer token'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}
{% endtabs %}

## Get a bucket

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

Get the details of a bucket.

#### Path Parameters

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

#### Headers

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

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

```
{
    "data": {
        "id": 8881,
        "uid": 1,
        "name": "bucket_music",
        "type": "File",
        "node": "127.0.0.1-871",
        "state": 1,
        "region": "ap-southeast-1",
        "metadata_template": "{\"artist\":{\"default\":\"abc\"}, \"album\":{\n\"type\":\"select\", \"default\":\"334\", \"options\":[\"123\", \"334\"]}}",
        "labels": [
            "Music",
            "Video"
        ],
        "net_type": 1,
        "created_at": "2019-03-01 15:31:25",
        "updated_at": "2019-08-16 07:17:32",
        "num": 10,
        "size": "300000",
        "access_permission": "private"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --request GET 'https://api-v2.acrcloud.com/api/buckets/8881' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer your_access_token'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

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

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

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

print(response.text)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api-v2.acrcloud.com/api/buckets/966',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Authorization: Bearer your_access_token'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://api-v2.acrcloud.com/api/buckets/966',
  headers: { 
    'Accept': 'application/json', 
    'Authorization': 'Bearer your_access_token'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://api-v2.acrcloud.com/api/buckets/966',
  headers: { 
    'Accept': 'application/json', 
    'Authorization': 'Bearer your_access_token'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}
{% endtabs %}

## &#x20;Update a bucket

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

Update the details of the bucket.

#### Path Parameters

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

#### Headers

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

#### Request Body

| Name               | Type   | Description                   |
| ------------------ | ------ | ----------------------------- |
| metadata\_template | string | Update the metadata\_template |
| labels             | string | Update the labels             |
| name               | string | Update the bucket name        |

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

```
{
    "data": {
        "id": 8881,
        "uid": 1,
        "name": "bucket_music",
        "type": "File",
        "node": "127.0.0.1-871",
        "state": 1,
        "region": "ap-southeast-1",
        "metadata_template": "{\"artist\":{\"default\":\"abc\"}, \"album\":{\n\"type\":\"select\", \"default\":\"334\", \"options\":[\"123\", \"334\"]}}",
        "labels": [
            "Music",
            "Video"
        ],
        "net_type": 1,
        "created_at": "2019-03-01 15:31:25",
        "updated_at": "2019-08-16 07:17:32",
        "num": 10,
        "size": "300000",
        "access_permission": "private"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request PUT 'https://api-v2.acrcloud.com/api/buckets/8881' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{"name":"bucket-music"}'
```

{% endtab %}
{% endtabs %}

## Delete the bucket

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

Before you delete the bucket, you need to clean the bucket first.

#### Path Parameters

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

#### Headers

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

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

```
```

{% endtab %}
{% endtabs %}
