]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - support/doc/api/openapi.yaml
Bumped to version v1.2.0-rc.1
[github/Chocobozzz/PeerTube.git] / support / doc / api / openapi.yaml
index 9f2997774382c0c8c7d7f3f232f3a52430309ff8..cca55580689372c37caf469214cbbb2113349615 100644 (file)
@@ -1,7 +1,7 @@
 openapi: 3.0.0
 info:
   title: PeerTube
-  version: 1.1.0-alpha.2
+  version: 1.2.0-rc.1
   contact:
     name: PeerTube Community
     url: 'https://joinpeertube.org'
@@ -10,27 +10,41 @@ info:
     url: 'https://github.com/Chocobozzz/PeerTube/blob/master/LICENSE'
   x-logo:
     url: 'https://joinpeertube.org/img/brand.png'
+    altText: PeerTube Project Homepage
   description: |
     # Introduction
     The PeerTube API is built on HTTP(S). Our API is RESTful. It has predictable
     resource URLs. It returns HTTP response codes to indicate errors. It also
     accepts and returns JSON in the HTTP body. You can use your favorite
     HTTP/REST library for your programming language to use PeerTube. No official
-    SDK is currently provided.
+    SDK is currently provided, but the spec API is fully compatible with
+    [openapi-generator](https://github.com/OpenAPITools/openapi-generator/wiki/API-client-generator-HOWTO)
+    which generates a client SDK in the language of your choice.
 
     # Authentication
     When you sign up for an account, you are given the possibility to generate
-    sessions, and authenticate using this session token. One session token can 
+    sessions, and authenticate using this session token. One session token can
     currently be used at a time.
+
+    # Errors
+    The API uses standard HTTP status codes to indicate the success or failure
+    of the API call. The body of the response will be JSON in the following
+    format.
+
+    ```
+    {
+      "code": "unauthorized_request", // example inner error code
+      "error": "Token is invalid." // example exposed error message
+    }
+    ```
+externalDocs:
+  url: https://docs.joinpeertube.org/api.html
 tags:
   - name: Accounts
     description: >
       Using some features of PeerTube require authentication, for which Accounts
-
       provide different levels of permission as well as associated user
-      information.
-
-      Accounts also encompass remote accounts discovered across the federation.
+      information. Accounts also encompass remote accounts discovered across the federation.
   - name: Config
     description: >
       Each server exposes public information regarding supported videos and
@@ -42,23 +56,15 @@ tags:
   - name: Job
     description: >
       Jobs are long-running tasks enqueued and processed by the instance
-      itself. 
-
-      No additional worker registration is currently available.
-  - name: ServerFollowing
+      itself. No additional worker registration is currently available.
+  - name: Server Following
     description: >
       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 
-
+      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.
-  - name: VideoAbuse
+  - name: Video Abuse
     description: |
       Video abuses deal with reports of local or remote videos alike.
   - name: Video
@@ -70,16 +76,50 @@ tags:
       Videos from other instances federated by the instance (that is, instances
       followed by the instance) can be found via keywords and other criteria of
       the advanced search.
-  - name: VideoComment
+  - name: Video Comment
     description: >
       Operations dealing with comments to a video. Comments are organized in
       threads.
-  - name: VideoChannel
+  - name: Video Channel
     description: >
       Operations dealing with creation, modification and video listing of a
-      user's
-
-      channels.
+      user's channels.
+  - name: Video Blacklist
+    description: >
+      Operations dealing with blacklisting videos (removing them from view and
+      preventing interactions).
+  - name: Video Rate
+    description: >
+      Voting for a video.
+x-tagGroups:
+  - name: Accounts
+    tags:
+      - Accounts
+      - User
+  - name: Videos
+    tags:
+      - Video
+      - Video Channel
+      - Video Comment
+      - Video Following
+      - Video Rate
+  - name: Moderation
+    tags:
+      - Video Abuse
+      - Video Blacklist
+  - name: Instance Configuration
+    tags:
+      - Config
+      - Server Following
+  - name: Notifications
+    tags:
+      - Feeds
+  - name: Jobs
+    tags:
+      - Job
+  - name: Search
+    tags:
+      - Search
 paths:
   '/accounts/{name}':
     get:
@@ -126,6 +166,37 @@ paths:
           source: |
             # pip install httpie
             http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos
+        - lang: Ruby
+          source: |
+            require 'uri'
+            require 'net/http'
+
+            url = URI("https://peertube2.cpy.re/api/v1/accounts/{name}/videos")
+
+            http = Net::HTTP.new(url.host, url.port)
+            http.use_ssl = true
+            http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+
+            request = Net::HTTP::Post.new(url)
+            request["content-type"] = 'application/json'
+            response = http.request(request)
+            puts response.read_body
+        - lang: Python
+          source: |
+            import http.client
+
+            conn = http.client.HTTPSConnection("https://peertube2.cpy.re/api/v1")
+
+            headers = {
+              'content-type': "application/json"
+            }
+
+            conn.request("POST", "/accounts/{name}/videos", None, headers)
+
+            res = conn.getresponse()
+            data = res.read()
+
+            print(data.decode("utf-8"))
   /accounts:
     get:
       tags:
@@ -144,7 +215,7 @@ paths:
     get:
       tags:
         - Config
-      summary: Get the configuration of the server
+      summary: Get the public configuration of the server
       responses:
         '200':
           description: successful operation
@@ -152,6 +223,45 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ServerConfig'
+  /config/about:
+    get:
+      summary: Get the instance about page content
+      tags:
+        - Config
+      responses:
+        '200':
+          description: successful operation
+  /config/custom:
+    get:
+      summary: Get the runtime configuration of the server
+      tags:
+        - Config
+      security:
+        - OAuth2:
+            - admin
+      responses:
+        '200':
+          description: successful operation
+    put:
+      summary: Set the runtime configuration of the server
+      tags:
+        - Config
+      security:
+        - OAuth2:
+            - admin
+      responses:
+        '200':
+          description: successful operation
+    delete:
+      summary: Delete the runtime configuration of the server
+      tags:
+        - Config
+      security:
+        - OAuth2:
+            - admin
+      responses:
+        '200':
+          description: successful operation
   '/feeds/videos.{format}':
     get:
       summary: >-
@@ -190,7 +300,7 @@ paths:
       responses:
         '200':
           description: successful operation
-  /jobs:
+  /jobs/{state}:
     get:
       summary: Get list of jobs
       security:
@@ -205,6 +315,12 @@ paths:
           description: The state of the job
           schema:
             type: string
+            enum:
+              - active
+              - completed
+              - failed
+              - waiting
+              - delayed
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
         - $ref: '#/components/parameters/sort'
@@ -223,7 +339,7 @@ paths:
         - OAuth2:
             - admin
       tags:
-        - ServerFollowing
+        - Server Following
       summary: Unfollow a server by hostname
       parameters:
         - name: host
@@ -238,7 +354,7 @@ paths:
   /server/followers:
     get:
       tags:
-        - ServerFollowing
+        - Server Following
       summary: Get followers of the server
       parameters:
         - $ref: '#/components/parameters/start'
@@ -256,7 +372,7 @@ paths:
   /server/following:
     get:
       tags:
-        - ServerFollowing
+        - Server Following
       summary: Get servers followed by the server
       parameters:
         - $ref: '#/components/parameters/start'
@@ -276,7 +392,7 @@ paths:
         - OAuth2:
             - admin
       tags:
-        - ServerFollowing
+        - Server Following
       summary: Follow a server
       responses:
         '204':
@@ -317,7 +433,7 @@ paths:
       parameters:
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
-        - $ref: '#/components/parameters/sort'
+        - $ref: '#/components/parameters/usersSort'
       responses:
         '200':
           description: successful operation
@@ -376,7 +492,8 @@ paths:
     get:
       summary: Get current user information
       security:
-        - OAuth2: []
+        - OAuth2:
+          - user
       tags:
         - User
       responses:
@@ -391,7 +508,8 @@ paths:
     put:
       summary: Update current user information
       security:
-        - OAuth2: []
+        - OAuth2:
+          - user
       tags:
         - User
       responses:
@@ -407,7 +525,8 @@ paths:
     get:
       summary: Get current user used quota
       security:
-        - OAuth2: []
+        - OAuth2:
+          - user
       tags:
         - User
       responses:
@@ -442,7 +561,71 @@ paths:
     get:
       summary: Get videos of the current user
       security:
-        - OAuth2: []
+        - OAuth2:
+          - user
+      tags:
+        - User
+      parameters:
+        - $ref: '#/components/parameters/start'
+        - $ref: '#/components/parameters/count'
+        - $ref: '#/components/parameters/sort'
+      responses:
+        '200':
+          description: successful operation
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/Video'
+  /users/me/subscriptions:
+    get:
+      summary: Get subscriptions of the current user
+      security:
+        - OAuth2:
+            - user
+      tags:
+        - User
+      parameters:
+        - $ref: '#/components/parameters/start'
+        - $ref: '#/components/parameters/count'
+        - $ref: '#/components/parameters/sort'
+      responses:
+        '200':
+          description: successful operation
+    post:
+      summary: Add subscription to the current user
+      security:
+        - OAuth2:
+            - user
+      tags:
+        - User
+      responses:
+        '200':
+          description: successful operation
+  /users/me/subscriptions/exist:
+    get:
+      summary: Get if subscriptions exist for the current user
+      security:
+        - OAuth2:
+            - user
+      tags:
+        - User
+      parameters:
+        - $ref: '#/components/parameters/subscriptionsUris'
+      responses:
+        '200':
+          description: successful operation
+          content:
+            application/json:
+              schema:
+                type: object
+  /users/me/subscriptions/videos:
+    get:
+      summary: Get videos of subscriptions of the current user
+      security:
+        - OAuth2:
+          - user
       tags:
         - User
       parameters:
@@ -458,6 +641,31 @@ paths:
                 type: array
                 items:
                   $ref: '#/components/schemas/Video'
+  '/users/me/subscriptions/{uri}':
+    get:
+      summary: Get subscription of the current user for a given uri
+      security:
+        - OAuth2:
+            - user
+      tags:
+        - User
+      responses:
+        '200':
+          description: successful operation
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/VideoChannel'
+    delete:
+      summary: Delete subscription of the current user for a given uri
+      security:
+        - OAuth2:
+            - user
+      tags:
+        - User
+      responses:
+        '200':
+          description: successful operation
   /users/register:
     post:
       summary: Register a user
@@ -506,15 +714,16 @@ paths:
       tags:
         - Video
       parameters:
-        - name: category
-          in: query
-          required: false
-          description: category id of the video
-          schema:
-            type: number
+        - $ref: '#/components/parameters/categoryOneOf'
+        - $ref: '#/components/parameters/tagsOneOf'
+        - $ref: '#/components/parameters/tagsAllOf'
+        - $ref: '#/components/parameters/licenceOneOf'
+        - $ref: '#/components/parameters/languageOneOf'
+        - $ref: '#/components/parameters/nsfw'
+        - $ref: '#/components/parameters/filter'
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
-        - $ref: '#/components/parameters/sort'
+        - $ref: '#/components/parameters/videosSort'
       responses:
         '200':
           description: successful operation
@@ -634,7 +843,9 @@ paths:
                   type: string
                 tags:
                   description: Video tags
-                  type: string
+                  type: array
+                  items:
+                    type: string
                 commentsEnabled:
                   description: Enable or disable comments for this video
                   type: string
@@ -701,6 +912,85 @@ paths:
       responses:
         '204':
           $ref: '#/paths/~1users~1me/put/responses/204'
+  '/videos/{id}/watching':
+    put:
+      summary: Set watching progress of a video by its id for a user
+      tags:
+        - Video
+      security:
+        - OAuth2: []
+      parameters:
+        - $ref: '#/components/parameters/id2'
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/UserWatchingVideo'
+        required: true
+      responses:
+        '204':
+          $ref: '#/paths/~1users~1me/put/responses/204'
+  /videos/ownership:
+    get:
+      summary: Get list of video ownership changes requests
+      tags:
+        - Video
+      security:
+        - OAuth2: []
+      parameters:
+        - $ref: '#/components/parameters/id2'
+      responses:
+        '200':
+          description: successful operation
+  '/videos/ownership/{id}/accept':
+    post:
+      summary: Refuse ownership change request for video by its id
+      tags:
+        - Video
+      security:
+        - OAuth2: []
+      parameters:
+        - $ref: '#/components/parameters/id2'
+      responses:
+        '204':
+          $ref: '#/paths/~1users~1me/put/responses/204'
+  '/videos/ownership/{id}/refuse':
+    post:
+      summary: Accept ownership change request for video by its id
+      tags:
+        - Video
+      security:
+        - OAuth2: []
+      parameters:
+        - $ref: '#/components/parameters/id2'
+      responses:
+        '204':
+          $ref: '#/paths/~1users~1me/put/responses/204'
+  '/videos/{id}/give-ownership':
+    post:
+      summary: Request change of ownership for a video you own, by its id
+      tags:
+        - Video
+      security:
+        - OAuth2: []
+      parameters:
+        - $ref: '#/components/parameters/id2'
+      requestBody:
+        required: true
+        content:
+          application/x-www-form-urlencoded:
+            schema:
+              type: object
+              properties:
+                username:
+                  type: string
+              required:
+                - username
+      responses:
+        '204':
+          $ref: '#/paths/~1users~1me/put/responses/204'
+        '400':
+          description: 'Changing video ownership to a remote account is not supported yet'
   /videos/upload:
     post:
       summary: Upload a video file with its metadata
@@ -762,7 +1052,9 @@ paths:
                   type: string
                 tags:
                   description: Video tags
-                  type: string
+                  type: array
+                  items:
+                    type: string
                 commentsEnabled:
                   description: Enable or disable comments for this video
                   type: string
@@ -803,11 +1095,11 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoAbuse
+        - Video Abuse
       parameters:
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
-        - $ref: '#/components/parameters/sort'
+        - $ref: '#/components/parameters/abusesSort'
       responses:
         '200':
           description: successful operation
@@ -823,7 +1115,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoAbuse
+        - Video Abuse
       parameters:
         - $ref: '#/components/parameters/id2'
       responses:
@@ -837,7 +1129,7 @@ paths:
             - admin
             - moderator
       tags:
-        - VideoBlacklist
+        - Video Blacklist
       parameters:
         - $ref: '#/components/parameters/id2'
       responses:
@@ -850,7 +1142,7 @@ paths:
             - admin
             - moderator
       tags:
-        - VideoBlacklist
+        - Video Blacklist
       parameters:
         - $ref: '#/components/parameters/id2'
       responses:
@@ -864,11 +1156,11 @@ paths:
             - admin
             - moderator
       tags:
-        - VideoBlacklist
+        - Video Blacklist
       parameters:
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
-        - $ref: '#/components/parameters/sort'
+        - $ref: '#/components/parameters/blacklistsSort'
       responses:
         '200':
           description: successful operation
@@ -882,7 +1174,7 @@ paths:
     get:
       summary: Get list of video channels
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
@@ -901,7 +1193,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoChannel
+        - Video Channel
       responses:
         '204':
           $ref: '#/paths/~1users~1me/put/responses/204'
@@ -911,7 +1203,7 @@ paths:
     get:
       summary: Get a video channel by its id
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/id3'
       responses:
@@ -926,7 +1218,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/id3'
       responses:
@@ -939,7 +1231,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/id3'
       responses:
@@ -949,7 +1241,7 @@ paths:
     get:
       summary: Get videos of a video channel by its id
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/id3'
       responses:
@@ -963,7 +1255,7 @@ paths:
     get:
       summary: Get video channels of an account by its name
       tags:
-        - VideoChannel
+        - Video Channel
       parameters:
         - $ref: '#/components/parameters/name'
       responses:
@@ -979,7 +1271,7 @@ paths:
     get:
       summary: Get the comment threads of a video by its id
       tags:
-        - VideoComment
+        - Video Comment
       parameters:
         - $ref: '#/components/parameters/id2'
         - $ref: '#/components/parameters/start'
@@ -997,7 +1289,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoComment
+        - Video Comment
       parameters:
         - $ref: '#/components/parameters/id2'
       responses:
@@ -1011,7 +1303,7 @@ paths:
     get:
       summary: 'Get the comment thread by its id, of a video by its id'
       tags:
-        - VideoComment
+        - Video Comment
       parameters:
         - $ref: '#/components/parameters/id2'
         - name: threadId
@@ -1033,7 +1325,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoComment
+        - Video Comment
       parameters:
         - $ref: '#/components/parameters/id2'
         - $ref: '#/components/parameters/commentId'
@@ -1049,7 +1341,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoComment
+        - Video Comment
       parameters:
         - $ref: '#/components/parameters/id2'
         - $ref: '#/components/parameters/commentId'
@@ -1062,7 +1354,7 @@ paths:
       security:
         - OAuth2: []
       tags:
-        - VideoRate
+        - Video Rate
       parameters:
         - $ref: '#/components/parameters/id2'
       responses:
@@ -1076,7 +1368,7 @@ paths:
       parameters:
         - $ref: '#/components/parameters/start'
         - $ref: '#/components/parameters/count'
-        - $ref: '#/components/parameters/sort'
+        - $ref: '#/components/parameters/videosSearchSort'
         - name: search
           in: query
           required: true
@@ -1093,8 +1385,12 @@ paths:
                 items:
                   $ref: '#/components/schemas/Video'
 servers:
+  - url: 'https://peertube.cpy.re/api/v1'
+    description: Live Test Server (live data - stable version)
   - url: 'https://peertube2.cpy.re/api/v1'
-    description: Live Server
+    description: Live Test Server (live data - bleeding edge version)
+  - url: 'https://peertube3.cpy.re/api/v1'
+    description: Live Test Server (live data - bleeding edge version)
 components:
   parameters:
     start:
@@ -1118,6 +1414,74 @@ components:
       description: Sort column (-createdAt for example)
       schema:
         type: string
+    videosSort:
+      name: sort
+      in: query
+      required: false
+      description: Sort videos by criteria
+      schema:
+        type: string
+        enum:
+        - -name
+        - -duration
+        - -createdAt
+        - -publishedAt
+        - -views
+        - -likes
+        - -trending
+    videosSearchSort:
+      name: sort
+      in: query
+      required: false
+      description: Sort videos by criteria
+      schema:
+        type: string
+        enum:
+        - -name
+        - -duration
+        - -createdAt
+        - -publishedAt
+        - -views
+        - -likes
+        - -match
+    blacklistsSort:
+      name: sort
+      in: query
+      required: false
+      description: Sort blacklists by criteria
+      schema:
+        type: string
+        enum:
+        - -id
+        - -name
+        - -duration
+        - -views
+        - -likes
+        - -dislikes
+        - -uuid
+        - -createdAt
+    usersSort:
+      name: sort
+      in: query
+      required: false
+      description: Sort users by criteria
+      schema:
+        type: string
+        enum:
+        - -id
+        - -username
+        - -createdAt
+    abusesSort:
+      name: sort
+      in: query
+      required: false
+      description: Sort abuses by criteria
+      schema:
+        type: string
+        enum:
+        - -id
+        - -createdAt
+        - -state
     name:
       name: name
       in: path
@@ -1155,6 +1519,103 @@ components:
       description: The comment id
       schema:
         type: number
+    categoryOneOf:
+      name: categoryOneOf
+      in: query
+      required: false
+      description: category id of the video
+      schema:
+        oneOf:
+        - type: number
+        - type: array
+          items:
+            type: number
+      style: form
+      explode: false
+    tagsOneOf:
+      name: tagsOneOf
+      in: query
+      required: false
+      description: tag(s) of the video
+      schema:
+        oneOf:
+        - type: string
+        - type: array
+          items:
+            type: string
+      style: form
+      explode: false
+    tagsAllOf:
+      name: tagsAllOf
+      in: query
+      required: false
+      description: tag(s) of the video, where all should be present in the video
+      schema:
+        oneOf:
+        - type: string
+        - type: array
+          items:
+            type: string
+      style: form
+      explode: false
+    languageOneOf:
+      name: languageOneOf
+      in: query
+      required: false
+      description: language id of the video
+      schema:
+        oneOf:
+        - type: string
+        - type: array
+          items:
+            type: string
+      style: form
+      explode: false
+    licenceOneOf:
+      name: licenceOneOf
+      in: query
+      required: false
+      description: licence id of the video
+      schema:
+        oneOf:
+        - type: number
+        - type: array
+          items:
+            type: number
+      style: form
+      explode: false
+    nsfw:
+      name: nsfw
+      in: query
+      required: false
+      description: whether to include nsfw videos, if any
+      schema:
+        type: string
+        enum:
+        - 'true'
+        - 'false'
+    filter:
+      name: filter
+      in: query
+      required: false
+      description: >
+        Special filters (local for instance) which might require special rights:
+         * `local` - only videos local to the instance
+         * `all-local` - only videos local to the instance, but showing private and unlisted videos (requires Admin privileges)
+      schema:
+        type: string
+        enum:
+        - local
+        - all-local
+    subscriptionsUris:
+      name: uris
+      in: query
+      required: true
+      description: list of uris to check if each is part of the user subscriptions
+      schema:
+        type: array
+        items:
+          type: string
   requestBodies:
     VideoChannelInput:
       content:
@@ -1414,6 +1875,10 @@ components:
           type: array
           items:
             $ref: '#/components/schemas/VideoChannel'
+    UserWatchingVideo:
+      properties:
+        currentTime:
+          type: number
     ServerConfig:
       properties:
         signup:
@@ -1538,7 +2003,12 @@ components:
           type: string
           description: 'The user videoQuota '
         role:
-          type: string
+          type: integer
+          format: int32
+          enum:
+            - 0
+            - 1
+            - 2
           description: 'The user role '
       required:
         - username