# Plugins

Managing plugins installed from a local path or from NPM, or search for new ones.


## List plugins

`GET /api/v1/plugins`

Authentication (security requirement alternatives):

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

- 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

Parameters:

- `pluginType` (query, integer, optional)
  Type: integer

- `uninstalled` (query, boolean, optional)
  Type: boolean

- `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 column
  Type: string
  
  Example:
  
  ```json
  "-createdAt"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: PluginResponse

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

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

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

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/plugins?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/plugins?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List available plugins

`GET /api/v1/plugins/available`

Authentication (security requirement alternatives):

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

- 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

Parameters:

- `search` (query, string, optional)
  Type: string

- `pluginType` (query, integer, optional)
  Type: integer

- `currentPeerTubeEngine` (query, string, optional)
  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 column
  Type: string
  
  Example:
  
  ```json
  "-createdAt"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: PluginResponse

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

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

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

- 503: plugin index unavailable

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/plugins/available?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/plugins/available?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Install a plugin

`POST /api/v1/plugins/install`

Authentication (security requirement alternatives):

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

- 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

Request body: application/json

Type: object

oneOf:
  Type: object
  
  - `npmName` (required)
    Type: string
    
    Example:
    
    ```json
    "peertube-plugin-auth-ldap"
    ```
  
  - `currentPassword` (optional)
    Reference: [currentPassword](https://docs.joinpeertube.org/api-rest-reference/api/models/currentpassword.md); Type: currentPassword, password
    
    Password of the authenticated user, required if [password confirmation](https://docs.joinpeertube.org/api-rest-reference/api.md#password-confirmation) is enabled
  
  Additional properties: false

  Type: object
  
  - `path` (required)
    Type: string
  
  - `currentPassword` (optional)
    Reference: [currentPassword](https://docs.joinpeertube.org/api-rest-reference/api/models/currentpassword.md); Type: currentPassword, password
    
    Password of the authenticated user, required if [password confirmation](https://docs.joinpeertube.org/api-rest-reference/api.md#password-confirmation) is enabled
  
  Additional properties: false

Responses:

- 204: successful operation

- 400: should have either `npmName` or `path` set, or `currentPassword` is missing

- 403: invalid `currentPassword`, or password confirmation unavailable for this user

- 429: too many failed password confirmations

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/plugins/install' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}'
```

### JavaScript

```javascript
const body = `{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}`;

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

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

### Python

```python
import requests

body = '''{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}'''

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


## Update a plugin

`POST /api/v1/plugins/update`

Authentication (security requirement alternatives):

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

- 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

Request body: application/json

Type: object

oneOf:
  Type: object
  
  - `npmName` (required)
    Type: string
    
    Example:
    
    ```json
    "peertube-plugin-auth-ldap"
    ```
  
  - `currentPassword` (optional)
    Reference: [currentPassword](https://docs.joinpeertube.org/api-rest-reference/api/models/currentpassword.md); Type: currentPassword, password
    
    Password of the authenticated user, required if [password confirmation](https://docs.joinpeertube.org/api-rest-reference/api.md#password-confirmation) is enabled
  
  Additional properties: false

  Type: object
  
  - `path` (required)
    Type: string
  
  - `currentPassword` (optional)
    Reference: [currentPassword](https://docs.joinpeertube.org/api-rest-reference/api/models/currentpassword.md); Type: currentPassword, password
    
    Password of the authenticated user, required if [password confirmation](https://docs.joinpeertube.org/api-rest-reference/api.md#password-confirmation) is enabled
  
  Additional properties: false

Responses:

- 204: successful operation

- 400: should have either `npmName` or `path` set, or `currentPassword` is missing

- 403: invalid `currentPassword`, or password confirmation unavailable for this user

- 404: existing plugin not found

- 429: too many failed password confirmations

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/plugins/update' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}'
```

### JavaScript

```javascript
const body = `{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}`;

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

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

### Python

```python
import requests

body = '''{
  "npmName": "peertube-plugin-auth-ldap",
  "currentPassword": "********"
}'''

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


## Uninstall a plugin

`POST /api/v1/plugins/uninstall`

Authentication (security requirement alternatives):

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

- 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

Request body: application/json

Type: object

- `npmName` (required)
  Type: string
  
  name of the plugin/theme in its package.json
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

Responses:

- 204: successful operation

- 404: existing plugin not found

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/plugins/uninstall' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "npmName": "peertube-plugin-auth-ldap"
}'
```

### JavaScript

```javascript
const body = `{
  "npmName": "peertube-plugin-auth-ldap"
}`;

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

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

### Python

```python
import requests

body = '''{
  "npmName": "peertube-plugin-auth-ldap"
}'''

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


## Get a plugin

`GET /api/v1/plugins/{npmName}`

Authentication (security requirement alternatives):

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

- 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

Parameters:

- `npmName` (path, string, required) - name of the plugin/theme on npmjs.com or in its package.json
  Type: string
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: Plugin

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

- `name` (optional)
  Type: string
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

- `type` (optional)
  Type: integer
  
  - `1`: PLUGIN
  - `2`: THEME
  
  
  enum: [1,2]

- `latestVersion` (optional)
  Type: string
  
  Example:
  
  ```json
  "0.0.3"
  ```

- `version` (optional)
  Type: string
  
  Example:
  
  ```json
  "0.0.1"
  ```

- `enabled` (optional)
  Type: boolean

- `uninstalled` (optional)
  Type: boolean

- `peertubeEngine` (optional)
  Type: string
  
  Example:
  
  ```json
  "2.2.0"
  ```

- `description` (optional)
  Type: string

- `homepage` (optional)
  Type: string, url
  
  Example:
  
  ```json
  "https://framagit.org/framasoft/peertube/official-plugins/tree/master/peertube-plugin-auth-ldap"
  ```

- `settings` (optional)
  Type: object
  
  Additional properties: true

- `createdAt` (optional)
  Type: string, date-time

- `updatedAt` (optional)
  Type: string, date-time

- 404: plugin not found

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap', {
  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/plugins/peertube-plugin-auth-ldap',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Set a plugin's settings

`PUT /api/v1/plugins/{npmName}/settings`

Authentication (security requirement alternatives):

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

- 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

Parameters:

- `npmName` (path, string, required) - name of the plugin/theme on npmjs.com or in its package.json
  Type: string
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

Request body: application/json

Type: object

- `settings` (optional)
  Type: object
  
  Additional properties: true

Responses:

- 204: successful operation

- 404: plugin not found

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/settings' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "settings": {}
}'
```

### JavaScript

```javascript
const body = `{
  "settings": {}
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/settings', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "settings": {}
}'''

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


## Get a plugin's public settings

`GET /api/v1/plugins/{npmName}/public-settings`

Authentication: no security requirement declared for this operation.

Parameters:

- `npmName` (path, string, required) - name of the plugin/theme on npmjs.com or in its package.json
  Type: string
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: object

Additional properties: true

- 404: plugin not found

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/public-settings'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/public-settings', {
  method: 'GET',
});

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

### Python

```python
import requests

response = requests.get('https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/public-settings')
print(response.text)
```


## Get a plugin's registered settings

`GET /api/v1/plugins/{npmName}/registered-settings`

Authentication (security requirement alternatives):

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

- 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

Parameters:

- `npmName` (path, string, required) - name of the plugin/theme on npmjs.com or in its package.json
  Type: string
  
  Example:
  
  ```json
  "peertube-plugin-auth-ldap"
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: object

Additional properties: true

- 404: plugin not found

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/registered-settings' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/plugins/peertube-plugin-auth-ldap/registered-settings', {
  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/plugins/peertube-plugin-auth-ldap/registered-settings',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
