PeerTube Session API

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

Operations 5

GET /api/v1/oauth-clients/local Login prerequisite #
POST /api/v1/users/token Login #
POST /api/v1/users/revoke-token Logout #
GET /api/v1/users/{id}/token-sessions List token sessions #
GET /api/v1/users/{id}/token-sessions/{tokenSessionId}/revoke List token sessions #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/peertube-session-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

peertube-session-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: PeerTube Session API
  version: 8.1.0
  contact:
    name: PeerTube Community
    url: https://joinpeertube.org
  license:
    name: AGPLv3.0
    url: https://github.com/Chocobozzz/PeerTube/blob/master/LICENSE
  x-logo:
    url: https://joinpeertube.org/img/brand.png
    altText: PeerTube Project Homepage
  description: The PeerTube API is built on HTTP(S) and is RESTful.
servers:
- url: https://peertube2.cpy.re
  description: Live Test Server (live data - latest nightly version)
- url: https://peertube3.cpy.re
  description: Live Test Server (live data - latest RC version)
- url: https://peertube.cpy.re
  description: Live Test Server (live data - stable version)
tags:
- name: Session
  x-displayName: Login/Logout
  description: Sessions deal with access tokens over time. Only __one session token can currently be used at a time__.
paths:
  /api/v1/oauth-clients/local:
    get:
      summary: Login prerequisite
      description: You need to retrieve a client id and secret before logging in.
      operationId: getOAuthClient
      tags:
      - Session
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthClient'
          links:
            UseOAuthClientToLogin:
              operationId: getOAuthToken
              parameters:
                client_id: $response.body#/client_id
                client_secret: $response.body#/client_secret
      x-codeSamples:
      - lang: Shell
        source: 'API="https://peertube2.cpy.re/api/v1"


          ## AUTH

          curl -s "$API/oauth-clients/local"

          '
  /api/v1/users/token:
    post:
      summary: Login
      operationId: getOAuthToken
      description: With your client id and secret, you can retrieve an access and refresh tokens.
      tags:
      - Session
      parameters:
      - name: x-peertube-otp
        in: header
        schema:
          type: string
        required: false
        description: If the user enabled two factor authentication, you need to provide the OTP code in this header
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              oneOf:
              - $ref: '#/components/schemas/OAuthToken-password'
              - $ref: '#/components/schemas/OAuthToken-refresh_token'
              discriminator:
                propertyName: grant_type
                mapping:
                  password: '#/components/schemas/OAuthToken-password'
                  refresh_token: '#/components/schemas/OAuthToken-refresh_token'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  token_type:
                    type: string
                    example: Bearer
                  access_token:
                    type: string
                    example: 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0
                    description: valid for 1 day
                  refresh_token:
                    type: string
                    example: 2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7
                    description: valid for 2 weeks
                  expires_in:
                    type: integer
                    minimum: 0
                    example: 14399
                  refresh_token_expires_in:
                    type: integer
                    minimum: 0
                    example: 1209600
        '400':
          x-summary: client or credentials are invalid
          description: 'Disambiguate via `code`:

            - `invalid_client` for an unmatched `client_id`

            - `invalid_grant` for unmatched credentials

            '
        '401':
          x-summary: token expired or two factor header is missing
          description: 'Disambiguate via `code`:

            - default value for a regular authentication failure

            - `invalid_token` for an expired token

            - `missing_two_factor` if two factor header is missing

            '
      x-codeSamples:
      - lang: Shell
        source: "## DEPENDENCIES: jq\nAPI=\"https://peertube2.cpy.re/api/v1\"\nUSERNAME=\"<your_username>\"\nPASSWORD=\"<your_password>\"\n\n## AUTH\nclient_id=$(curl -s \"$API/oauth-clients/local\" | jq -r \".client_id\")\nclient_secret=$(curl -s \"$API/oauth-clients/local\" | jq -r \".client_secret\")\ncurl -s \"$API/users/token\" \\\n  --data client_id=\"$client_id\" \\\n  --data client_secret=\"$client_secret\" \\\n  --data grant_type=password \\\n  --data username=\"$USERNAME\" \\\n  --data-urlencode password=\"$PASSWORD\" \\\n  | jq -r \".access_token\"\n"
  /api/v1/users/revoke-token:
    post:
      summary: Logout
      description: Revokes your access token and its associated refresh token, destroying your current session.
      operationId: revokeOAuthToken
      tags:
      - Session
      security:
      - OAuth2: []
      responses:
        '200':
          description: successful operation
  /api/v1/users/{id}/token-sessions:
    get:
      summary: List token sessions
      parameters:
      - $ref: '#/components/parameters/id'
      tags:
      - Session
      security:
      - OAuth2: []
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: integer
                    example: 1
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/TokenSession'
      operationId: getApiV1UsersByIdTokenSessions
      x-operation-id-source: derived
  /api/v1/users/{id}/token-sessions/{tokenSessionId}/revoke:
    get:
      summary: List token sessions
      parameters:
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/tokenSessionId'
      tags:
      - Session
      security:
      - OAuth2: []
      responses:
        '200':
          description: successful operation
      operationId: getApiV1UsersByIdTokenSessionsByTokenSessionIdRevoke
      x-operation-id-source: derived
components:
  parameters:
    id:
      name: id
      in: path
      required: true
      description: Entity id
      schema:
        $ref: '#/components/schemas/id'
    tokenSessionId:
      name: tokenSessionId
      in: path
      required: true
      description: Token session Id
      schema:
        $ref: '#/components/schemas/id'
  schemas:
    TokenSession:
      properties:
        id:
          type: integer
        currentSession:
          type: boolean
          description: Is this session the current one?
        loginDevice:
          type: string
          description: Device used to login
        loginIP:
          type: string
          format: ipv4
          description: IP address used to login
        loginDate:
          type: string
          format: date-time
          description: Date of the login
        lastActivityDevice:
          type: string
        lastActivityIP:
          type: string
          format: ipv4
        lastActivityDate:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
    OAuthToken-password:
      allOf:
      - $ref: '#/components/schemas/OAuthClient'
      - type: object
        properties:
          grant_type:
            type: string
            enum:
            - password
          username:
            $ref: '#/components/schemas/User/properties/username'
          password:
            $ref: '#/components/schemas/password'
          externalAuthToken:
            type: string
            description: If you want to authenticate using an external authentication token you got from an auth plugin (like `peertube-plugin-auth-openid-connect` for example) instead of a password or a refresh token, provide it here.
      required:
      - client_id
      - client_secret
      - grant_type
      - username
    password:
      type: string
      format: password
      minLength: 6
      maxLength: 50
    OAuthToken-refresh_token:
      allOf:
      - $ref: '#/components/schemas/OAuthClient'
      - type: object
        properties:
          grant_type:
            type: string
            enum:
            - refresh_token
          refresh_token:
            type: string
            example: 2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7
      required:
      - client_id
      - client_secret
      - grant_type
      - refresh_token
    username:
      type: string
      description: immutable name of the user, used to find or mention its actor
      example: chocobozzz
      pattern: /^[a-z0-9._]+$/
      minLength: 1
      maxLength: 50
    User:
      properties:
        id:
          $ref: '#/components/schemas/id'
        username:
          $ref: '#/components/schemas/username'
        email:
          type: string
          format: email
          description: The user email
        emailVerified:
          type: boolean
          description: Has the user confirmed their email address?
        emailPublic:
          type: boolean
          description: Has the user accepted to display the email publicly?
        nsfwPolicy:
          $ref: '#/components/schemas/NSFWPolicy'
        nsfwFlagsDisplayed:
          $ref: '#/components/schemas/NSFWFlag'
        nsfwFlagsHidden:
          $ref: '#/components/schemas/NSFWFlag'
        nsfwFlagsWarned:
          $ref: '#/components/schemas/NSFWFlag'
        nsfwFlagsBlurred:
          $ref: '#/components/schemas/NSFWFlag'
        adminFlags:
          $ref: '#/components/schemas/UserAdminFlags'
        autoPlayNextVideo:
          type: boolean
          description: Automatically start playing the upcoming video after the currently playing video
        autoPlayNextVideoPlaylist:
          type: boolean
          description: Automatically start playing the video on the playlist after the currently playing video
        autoPlayVideo:
          type: boolean
          description: Automatically start playing the video on the watch page
        p2pEnabled:
          type: boolean
          description: whether to enable P2P in the player or not
        videosHistoryEnabled:
          type: boolean
          description: whether to keep track of watched history or not
        videoLanguages:
          type: array
          items:
            type: string
          description: list of languages to filter videos down to
        language:
          type: string
          description: default language for this user
        videoQuota:
          type: integer
          description: The user video quota in bytes
          example: -1
        videoQuotaDaily:
          type: integer
          description: The user daily video quota in bytes
          example: -1
        role:
          type: object
          properties:
            id:
              $ref: '#/components/schemas/UserRole'
            label:
              type: string
              enum:
              - User
              - Moderator
              - Administrator
        theme:
          type: string
          description: Theme enabled by this user
        account:
          $ref: '#/components/schemas/Account'
        notificationSettings:
          $ref: '#/components/schemas/UserNotificationSettings'
        videoChannels:
          type: array
          items:
            $ref: '#/components/schemas/VideoChannel'
        blocked:
          type: boolean
        blockedReason:
          type: string
        noInstanceConfigWarningModal:
          type: boolean
        noAccountSetupWarningModal:
          type: boolean
        noWelcomeModal:
          type: boolean
        createdAt:
          type: string
        pluginAuth:
          type: string
          description: Auth plugin to use to authenticate the user
        lastLoginDate:
          type: string
          format: date-time
        twoFactorEnabled:
          type: boolean
          description: Whether the user has enabled two-factor authentication or not
        newFeaturesInfoRead:
          type: number
          description: New features information the user has read
    OAuthClient:
      properties:
        client_id:
          type: string
          pattern: /^[a-z0-9]$/
          maxLength: 32
          minLength: 32
          example: v1ikx5hnfop4mdpnci8nsqh93c45rldf
        client_secret:
          type: string
          pattern: /^[a-zA-Z0-9]$/
          maxLength: 32
          minLength: 32
          example: AjWiOapPltI6EnsWQwlFarRtLh4u8tDt
    id:
      type: integer
      minimum: 1
      example: 42
  securitySchemes:
    OAuth2:
      description: '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

        '
      type: oauth2
      flows:
        password:
          tokenUrl: /api/v1/users/token
          scopes:
            admin: Admin scope
            moderator: Moderator scope
            user: User scope
externalDocs:
  url: https://docs.joinpeertube.org/api-rest-reference.html
x-tagGroups:
- name: Static endpoints
  tags:
  - Static Video Files
- name: Download
  tags:
  - Video Download
- name: Feeds
  tags:
  - Video Feeds
- name: Auth
  tags:
  - Register
  - Session
- name: Accounts
  tags:
  - Accounts
  - Users
  - User Exports
  - User Imports
  - My User
  - My Subscriptions
  - My Notifications
  - My History
- name: Videos
  tags:
  - Video
  - Video Upload
  - Video Imports
  - Video Captions
  - Video Chapters
  - Video Channels
  - Video Comments
  - Video Rates
  - Video Playlists
  - Video Stats
  - Ownership Change
  - Video Mirroring
  - Video Files
  - Video Transcoding
  - Live Videos
  - Channels Sync
  - Video Passwords
  - Video Embed Privacy
- name: Search
  tags:
  - Search
- name: Moderation
  tags:
  - Abuses
  - Video Blocks
  - Account Blocklist
  - Server Blocklist
  - Automatic Tags
  - Watched Words
- name: Instance
  tags:
  - Config
  - Client Config
  - Homepage
  - Instance Follows
  - Instance Redundancy
  - Plugins
  - Stats
  - Logs
  - Job
- name: Remote Jobs
  tags:
  - Runner Registration Token
  - Runner Jobs
  - Runners