PeerTube

v8.3.0
Base URLs
https://peertube2.cpy.reLive Test Server (live data - latest nightly version)
https://peertube3.cpy.reLive Test Server (live data - latest RC version)
https://peertube.cpy.reLive Test Server (live data - stable version)

The PeerTube API is built on HTTP(S) and is RESTful. You can use your favorite HTTP/REST library for your programming language to use PeerTube.

See the REST API quick start for a few examples of using the PeerTube API.

Authentication

When you sign up for an account on a PeerTube instance, you are given the possibility to generate sessions on it, and authenticate there using an access token. Only one access token can currently be used at a time.

Roles

Accounts are given permissions based on their role. There are three roles on PeerTube: Administrator, Moderator, and User. See the roles guide for a detail of their permissions.

Errors

The API uses standard HTTP status codes to indicate the success or failure of the API call, completed by a RFC7807-compliant response body.

HTTP 1.1 404 Not Found
Content-Type: application/problem+json; charset=utf-8

{
  "detail": "Video not found",
  "docs": "/api-rest-reference.html#operation/getVideo",
  "status": 404,
  "title": "Not Found",
  "type": "about:blank"
}

We provide error type (following RFC7807) and code (internal PeerTube code) values for a growing number of cases, but it is still optional. Types are used to disambiguate errors that bear the same status code and are non-obvious:

HTTP 1.1 403 Forbidden
Content-Type: application/problem+json; charset=utf-8

{
  "detail": "Cannot get this video regarding follow constraints",
  "docs": "/api-rest-reference.html#operation/getVideo",
  "status": 403,
  "title": "Forbidden",
  "type": "/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints"
}

Here a 403 error could otherwise mean that the video is private or blocklisted.

Validation errors

Example:

HTTP 1.1 400 Bad Request
Content-Type: application/problem+json; charset=utf-8

{
  "detail": "Incorrect request parameters: id",
  "docs": "/api-rest-reference.html#operation/getVideo",
  "instance": "/api/v1/videos/9c9de5e8-0a1e-484a-b099-e80766180",
  "invalid-params": {
    "id": {
      "location": "params",
      "msg": "Invalid value",
      "param": "id",
      "value": "9c9de5e8-0a1e-484a-b099-e80766180"
    }
  },
  "status": 400,
  "title": "Bad Request",
  "type": "about:blank"
}

Where id is the name of the field concerned by the error, within the route definition. invalid-params.<field>.location can be either 'params', 'body', 'header', 'query' or 'cookies'. invalid-params.<field>.value reports the value that didn't pass validation whose invalid-params.<field>.msg is about.

max_file_size_reached

The uploaded file exceeds the instance-wide file size limit.

quota_reached

The uploaded file exceeds the user's storage quota.

does_not_respect_follow_constraints

The requested remote resource cannot be accessed because the instance does not follow its origin.

live_not_enabled

Live streaming is not enabled on the instance.

live_not_allowing_replay

Saving live replays is disabled on this instance, so a live cannot be created or updated with saveReplay enabled.

live_conflicting_permanent_and_save_replay

Not returned by PeerTube anymore: permanent lives can save replays.

max_instance_lives_limit_reached

The instance has reached its maximum number of simultaneous live streams.

max_user_lives_limit_reached

The user has reached the maximum number of simultaneous live streams.

incorrect_files_in_torrent

The torrent does not contain exactly one usable video file.

comment_not_associated_to_video

The comment is not associated with the requested video.

invalid_grant

The OAuth grant or refresh token is invalid.

invalid_client

Client authentication failed.

invalid_token

The access token is expired, revoked, malformed, or otherwise invalid.

unauthorized_request

The endpoint requires authentication but no access token was provided.

invalid_request

The authentication or token request is malformed: missing grant_type, malformed Authorization header, access token sent using more than one method, or sent in the query string.

unsupported_grant_type

The grant_type is not supported. PeerTube supports password and refresh_token.

unauthorized_client

The OAuth client is not allowed to use the requested grant_type.

server_error

An unexpected error occurred while checking the access token.

missing_two_factor

The required two-factor authentication header is missing.

too_long_password

The password exceeds the maximum allowed length.

invalid_two_factor

The two-factor authentication code is invalid.

account_blocked

The account is blocked.

email_not_verified

The account email address has not been verified.

account_waiting_for_approval

The account is waiting for administrator approval.

account_approval_rejected

The account approval request was rejected.

runner_job_not_in_processing_state

The runner job is not in the processing state.

runner_job_not_in_pending_state

The runner job is not in the pending state.

unknown_runner_token

The runner token is unknown.

video_requires_password

A password is required to access the video.

incorrect_video_password

The password provided for the video is incorrect.

video_already_being_transcoded

The video is already being transcoded.

video_already_being_transcribed

The video is already being transcribed.

video_already_has_captions

The video already has captions.

max_user_video_quota_exceeded_for_user_export

The user requested an export including video files, but the total size of their videos is above the maximum allowed by the instance for such exports. Request an export without video files instead.

current_password_is_invalid

The current password is invalid.

current_password_is_missing

The action requires a password confirmation but currentPassword is missing.

password_confirmation_unavailable

The action requires a password confirmation but the user authenticates with an external auth plugin (OpenID Connect, SAML...), so PeerTube cannot check their password.

Rate limits

We are rate-limiting all endpoints of PeerTube's API. Custom values can be set by administrators:

Endpoint (prefix: /api/v1)CallsTime frame
/*5010 seconds
POST /users/token155 minutes
POST /users/register2*5 minutes
POST /users/ask-send-verify-email35 minutes

Depending on the endpoint, *failed requests are not taken into account. A service limit is announced by a 429 Too Many Requests status code.

You can get details about the current state of your rate limit by reading the following headers:

HeaderDescription
X-RateLimit-LimitNumber of max requests allowed in the current time period
X-RateLimit-RemainingNumber of remaining requests in the current time period
X-RateLimit-ResetTimestamp of end of current time period as UNIX timestamp
Retry-AfterSeconds to delay after the first 429 is received

Password confirmation

If the webadmin.password_confirmation.enabled setting is enabled (default), sensitive administrator actions require the user password in the currentPassword field of the request body:

  • Install or update a plugin/theme
  • Change the custom JavaScript or CSS of the instance (instance.customizations of the custom configuration)
  • Create an administrator, or give the administrator role to a user
  • Change the password, email or auth plugin (pluginAuth) of an administrator

After 10 failed password confirmations in 10 minutes (configurable), the user receives a 429 Too Many Requests status code until the end of the time frame, even with the correct password.

CORS

This API features Cross-Origin Resource Sharing (CORS), allowing cross-domain communication from the browser for some routes:

| Endpoint | |------------------------- ---| | /api/* | | /download/* | | /lazy-static/* | | /.well-known/webfinger |

In addition, all routes serving ActivityPub are CORS-enabled for all origins.

/api-rest-reference.html

Authentication

OAuth2oauth2

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.

password
Token URL
/api/v1/users/token
Scopes
  • admin- Admin scope
  • moderator- Moderator scope
  • user- User scope

Static endpoints

Download

Video Download

Download video files

Feeds

Auth

Session

Sessions deal with access tokens over time. Only one session token can currently be used at a time.

Accounts

Accounts

Accounts encompass remote accounts discovered across the federation, and correspond to the main Actor, along with video channels a user can create, which are also Actors. When a comment is posted, it is done with your Account's Actor.

Users

Using some features of PeerTube require authentication, for which User provide different levels of permission as well as associated user information. Each user has a corresponding local Account for federation.

User Exports

To create an archive of user data.

My Subscriptions

Operations related to your subscriptions to video channels, their new videos, and how to keep up to date with their latest publications!

My Notifications

Notifications following new videos, follows or reports. They allow you to keep track of the interactions and overall important information that concerns you. You MAY set per-notification type delivery preference, to receive the info either by mail, by in-browser notification or both.

Videos

Video Upload

Operations dealing with adding video or audio. PeerTube supports two upload modes, and three import modes.

Upload

  • legacy, where the video file is sent in a single request
  • resumable, where the video file is sent in chunks

You can upload videos more reliably by using the resumable variant. Its protocol lets you resume an upload operation after a network interruption or other transmission failure, saving time and bandwidth in the event of network failures.

Favor using resumable uploads in any of the following cases:

  • You are transferring large files
  • The likelihood of a network interruption is high
  • Uploads are originating from a device with a low-bandwidth or unstable Internet connection, such as a mobile device

Import

  • URL-based: where the URL points to any service supported by youtube-dl
  • magnet-based: where the URI resolves to a BitTorrent resource containing a single supported video file
  • torrent-based: where the metainfo file resolves to a BitTorrent resource containing a single supported video file

The import function is practical when the desired video/audio is available online. It makes PeerTube download it for you, saving you as much bandwidth and avoiding any instability or limitation your network might have.

Video Imports

Operations dealing with listing, adding and removing video imports.

Video Captions

Operations dealing with listing, adding and removing closed captions of a video.

Video Chapters

Operations dealing with managing chapters of a video.

Video Comments

Operations dealing with comments to a video. Comments are organized in threads: adding a comment in response to the video starts a thread, adding a reply to a comment adds it to its root comment thread.

Video Mirroring

PeerTube instances can mirror videos from one another, and help distribute some videos.

For importing videos as your own, refer to video imports.

Video Transcoding

Video transcoding related operations

Search

Moderation

Video Blocks

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

Instance

Client Config

Configuration of the web client.

Homepage

Get and update the custom homepage

Instance Follows

Managing servers which the instance interacts with is crucial to the concept of federation in PeerTube and external video indexation. The PeerTube server then deals with inter-server ActivityPub operations and propagates information across its social graph by posting activities to actors' inbox endpoints.

https://docs.joinpeertube.org/admin/following-instances#instances-follows

Instance Redundancy

Redundancy is part of the inter-server solidarity that PeerTube fosters. Manage the list of instances you wish to help by seeding their videos according to the policy of video selection of your choice. Note that you have a similar functionality to mirror individual videos, see video mirroring.

https://docs.joinpeertube.org/admin/following-instances#instances-redundancy

Logs

Operations dealing with client, server and audit logs.

Job

Jobs are long-running tasks enqueued and processed by the instance itself. No additional worker registration is currently available.

Remote Jobs

Runner Registration Token

Manage runner registration tokens.

Player Settings

Operations dealing with video player settings for videos and channels.

Contact

Send a message to the instance administrators.

Debug

Administrative debug endpoints.

Models