2018-04-17 05:11:25 -04:00
# REST API quick start
## Authentication
### Get client
Some endpoints need authentication. We use OAuth 2.0 so first fetch the client tokens:
2018-11-20 19:02:47 -05:00
```bash
2023-04-04 03:16:53 -04:00
curl https://peertube.example.com/api/v1/oauth-clients/local
2018-04-17 05:11:25 -04:00
```
Response example:
2018-11-20 19:02:47 -05:00
```json
2018-04-17 05:11:25 -04:00
{
"client_id": "v1ikx5hnfop4mdpnci8nsqh93c45rldf",
"client_secret": "AjWiOapPltI6EnsWQwlFarRtLh4u8tDt"
}
```
### Get user token
Now you can fetch the user token:
2018-11-20 19:02:47 -05:00
```bash
2023-04-04 03:16:53 -04:00
curl -X POST \
2018-04-17 05:11:25 -04:00
-d "client_id=v1ikx5hnfop4mdpnci8nsqh93c45rldf& client_secret=AjWiOapPltI6EnsWQwlFarRtLh4u8tDt& grant_type=password& response_type=code& username=your_user& password=your_password" \
https://peertube.example.com/api/v1/users/token
```
Response example:
2018-11-20 19:02:47 -05:00
```json
2018-04-17 05:11:25 -04:00
{
"access_token": "90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0",
"token_type": "Bearer",
"expires_in": 14399,
"refresh_token": "2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7"
}
```
Just use the `access_token` in the `Authorization` header:
2018-11-20 19:02:47 -05:00
```bash
2023-04-04 03:16:53 -04:00
curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
2018-06-11 08:45:43 -04:00
```
2019-05-23 08:58:34 -04:00
## List videos
2018-06-11 08:45:43 -04:00
2018-11-20 19:02:47 -05:00
```bash
2023-04-04 03:16:53 -04:00
curl https://peertube.example.com/api/v1/videos
2018-11-19 16:07:29 -05:00
```
2020-02-17 03:33:45 -05:00
## Libraries
[Convenience libraries ](https://framagit.org/framasoft/peertube/clients ) are generated automatically from the [OpenAPI specification ](https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/api/openapi.yaml ) for the following languages:
- [python ](https://framagit.org/framasoft/peertube/clients/python )
- [go ](https://framagit.org/framasoft/peertube/clients/go )
- [kotlin ](https://framagit.org/framasoft/peertube/clients/kotlin )
Other [languages supported by the OpenAPI generator ](https://openapi-generator.tech/docs/generators/#client-generators ) can be added to the generation, provided they make a common enough use case.