# Video Blocks

Operations dealing with blocking videos (removing them from view and preventing interactions).

## Block a video

`POST /api/v1/videos/{id}/blacklist`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "admin",
      "moderator"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: admin, moderator

Parameters:

- `id` (path, id | UUIDv4 | shortUUID, required) - The object id, uuid or short uuid
  Type: id | UUIDv4 | shortUUID
  
  oneOf:
    Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```
  
    Reference: [UUIDv4](https://docs.joinpeertube.org/api-rest-reference/api/models/uuidv4.md); Type: UUIDv4, uuid
    
    minLength: 36
    
    maxLength: 36
    
    pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    
    Example:
    
    ```json
    "9c9de5e8-0a1e-484a-b099-e80766180a6d"
    ```
  
    Reference: [shortUUID](https://docs.joinpeertube.org/api-rest-reference/api/models/shortuuid.md); Type: shortUUID
    
    translation of a uuid v4 with a bigger alphabet to have a shorter uuid
    
    Example:
    
    ```json
    "2y84q2MQUMWPbiEcxNXMgC"
    ```

Request body: application/json

Type: VideoBlacklistCreate

Schema: [VideoBlacklistCreate](https://docs.joinpeertube.org/api-rest-reference/api/models/videoblacklistcreate.md)

- `reason` (optional)
  Type: string
  
  Reason for the block (public)

- `unfederate` (optional)
  Type: boolean
  
  Whether to unfederate the video

- `internalNote` (optional)
  Type: string
  
  Internal note for moderators/admins

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/videos/42/blacklist' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "reason": "string",
  "unfederate": true,
  "internalNote": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "reason": "string",
  "unfederate": true,
  "internalNote": "string"
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/videos/42/blacklist', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "reason": "string",
  "unfederate": true,
  "internalNote": "string"
}'''

response = requests.post(
    'https://peertube2.cpy.re/api/v1/videos/42/blacklist',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Update a video block

`PUT /api/v1/videos/{id}/blacklist`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "admin",
      "moderator"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: admin, moderator

Parameters:

- `id` (path, id | UUIDv4 | shortUUID, required) - The object id, uuid or short uuid
  Type: id | UUIDv4 | shortUUID
  
  oneOf:
    Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```
  
    Reference: [UUIDv4](https://docs.joinpeertube.org/api-rest-reference/api/models/uuidv4.md); Type: UUIDv4, uuid
    
    minLength: 36
    
    maxLength: 36
    
    pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    
    Example:
    
    ```json
    "9c9de5e8-0a1e-484a-b099-e80766180a6d"
    ```
  
    Reference: [shortUUID](https://docs.joinpeertube.org/api-rest-reference/api/models/shortuuid.md); Type: shortUUID
    
    translation of a uuid v4 with a bigger alphabet to have a shorter uuid
    
    Example:
    
    ```json
    "2y84q2MQUMWPbiEcxNXMgC"
    ```

Request body: application/json

Type: VideoBlacklistUpdate

Schema: [VideoBlacklistUpdate](https://docs.joinpeertube.org/api-rest-reference/api/models/videoblacklistupdate.md)

- `reason` (optional)
  Type: string
  
  Reason for the block (displayed publicly)

- `internalNote` (optional)
  Type: string
  
  Internal note for moderators/admins

Responses:

- 204: successful operation

- 404: block not found

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/videos/42/blacklist' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "reason": "string",
  "internalNote": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "reason": "string",
  "internalNote": "string"
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/videos/42/blacklist', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "reason": "string",
  "internalNote": "string"
}'''

response = requests.put(
    'https://peertube2.cpy.re/api/v1/videos/42/blacklist',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Unblock a video by its id

`DELETE /api/v1/videos/{id}/blacklist`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "admin",
      "moderator"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: admin, moderator

Parameters:

- `id` (path, id | UUIDv4 | shortUUID, required) - The object id, uuid or short uuid
  Type: id | UUIDv4 | shortUUID
  
  oneOf:
    Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
    
    minimum: 1
    
    Example:
    
    ```json
    42
    ```
  
    Reference: [UUIDv4](https://docs.joinpeertube.org/api-rest-reference/api/models/uuidv4.md); Type: UUIDv4, uuid
    
    minLength: 36
    
    maxLength: 36
    
    pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    
    Example:
    
    ```json
    "9c9de5e8-0a1e-484a-b099-e80766180a6d"
    ```
  
    Reference: [shortUUID](https://docs.joinpeertube.org/api-rest-reference/api/models/shortuuid.md); Type: shortUUID
    
    translation of a uuid v4 with a bigger alphabet to have a shorter uuid
    
    Example:
    
    ```json
    "2y84q2MQUMWPbiEcxNXMgC"
    ```

Responses:

- 204: successful operation

- 404: block not found

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/videos/42/blacklist' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/videos/42/blacklist', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.delete(
    'https://peertube2.cpy.re/api/v1/videos/42/blacklist',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List video blocks

`GET /api/v1/videos/blacklist`

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "admin",
      "moderator"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: admin, moderator

Parameters:

- `type` (query, integer, optional) - list only blocks that match this type:
- `1`: manual block
- `2`: automatic block that needs review

  Type: integer
  
  enum: [1,2]

- `search` (query, string, optional) - plain search that will match with video titles, and more
  Type: string

- `start` (query, integer, optional) - Offset used to paginate results
  Type: integer
  
  minimum: 0

- `count` (query, integer, optional) - Number of items to return
  Type: integer
  
  default: 15
  
  minimum: 1
  
  maximum: 100

- `sort` (query, string, optional) - Sort blocklists by criteria
  Type: string
  
  enum: ["-id","name","-duration","-views","-likes","-dislikes","-uuid","-createdAt"]

Responses:

- 200: successful operation

Content type: application/json

Type: object

- `total` (optional)
  Type: integer
  
  Example:
  
  ```json
  1
  ```

- `data` (optional)
  Type: Array<VideoBlacklist>
  
  Items:
    Reference: [VideoBlacklist](https://docs.joinpeertube.org/api-rest-reference/api/models/videoblacklist.md); Type: VideoBlacklist

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/videos/blacklist?count=15' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/videos/blacklist?count=15', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://peertube2.cpy.re/api/v1/videos/blacklist?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
