2024-01-14 12:30:33 +02:00

51 lines
13 KiB
Python

# coding: utf-8
"""
PeerTube
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. 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 - we generate some client SDKs automatically: - [Python](https://framagit.org/framasoft/peertube/clients/python) - [Go](https://framagit.org/framasoft/peertube/clients/go) - [Kotlin](https://framagit.org/framasoft/peertube/clients/kotlin) See the [REST API quick start](https://docs.joinpeertube.org/api/rest-getting-started) 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](https://docs.joinpeertube.org/admin/managing-users#roles) 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](https://tools.ietf.org/html/rfc7807) response body. ``` HTTP 1.1 404 Not Found Content-Type: application/problem+json; charset=utf-8 { \"detail\": \"Video not found\", \"docs\": \"https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\", \"status\": 404, \"title\": \"Not Found\", \"type\": \"about:blank\" } ``` We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/src/server/core-error-code.enum.ts), 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\": \"https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\", \"status\": 403, \"title\": \"Forbidden\", \"type\": \"https://docs.joinpeertube.org/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 Each parameter is evaluated on its own against a set of rules before the route validator proceeds with potential testing involving parameter combinations. Errors coming from validation errors appear earlier and benefit from a more detailed error description: ``` HTTP 1.1 400 Bad Request Content-Type: application/problem+json; charset=utf-8 { \"detail\": \"Incorrect request parameters: id\", \"docs\": \"https://docs.joinpeertube.org/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', and `invalid-params.<field>.value` reports the value that didn't pass validation whose `invalid-params.<field>.msg` is about. ### Deprecated error fields Some fields could be included with previous versions. They are still included but their use is deprecated: - `error`: superseded by `detail` - `code`: superseded by `type` (which is now an URI) # Rate limits We are rate-limiting all endpoints of PeerTube's API. Custom values can be set by administrators: | Endpoint (prefix: `/api/v1`) | Calls | Time frame | |------------------------------|---------------|--------------| | `/*` | 50 | 10 seconds | | `POST /users/token` | 15 | 5 minutes | | `POST /users/register` | 2<sup>*</sup> | 5 minutes | | `POST /users/ask-send-verify-email` | 3 | 5 minutes | Depending on the endpoint, <sup>*</sup>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: | Header | Description | |-------------------------|------------------------------------------------------------| | `X-RateLimit-Limit` | Number of max requests allowed in the current time period | | `X-RateLimit-Remaining` | Number of remaining requests in the current time period | | `X-RateLimit-Reset` | Timestamp of end of current time period as UNIX timestamp | | `Retry-After` | Seconds to delay after the first `429` is received | # CORS This API features [Cross-Origin Resource Sharing (CORS)](https://fetch.spec.whatwg.org/), 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.
The version of the OpenAPI document: 5.2.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from setuptools import setup, find_packages # noqa: H301
# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "peertube"
VERSION = "1.0.0"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0",
"python-dateutil",
"pydantic >= 2",
"typing-extensions >= 4.7.1",
]
setup(
name=NAME,
version=VERSION,
description="PeerTube",
author="PeerTube Community",
author_email="team@openapitools.org",
url="",
keywords=["OpenAPI", "OpenAPI-Generator", "PeerTube"],
install_requires=REQUIRES,
packages=find_packages(exclude=["test", "tests"]),
include_package_data=True,
license="AGPLv3.0",
long_description_content_type='text/markdown',
long_description="""\
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. 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 - we generate some client SDKs automatically: - [Python](https://framagit.org/framasoft/peertube/clients/python) - [Go](https://framagit.org/framasoft/peertube/clients/go) - [Kotlin](https://framagit.org/framasoft/peertube/clients/kotlin) See the [REST API quick start](https://docs.joinpeertube.org/api/rest-getting-started) 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](https://docs.joinpeertube.org/admin/managing-users#roles) 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](https://tools.ietf.org/html/rfc7807) response body. &#x60;&#x60;&#x60; HTTP 1.1 404 Not Found Content-Type: application/problem+json; charset&#x3D;utf-8 { \&quot;detail\&quot;: \&quot;Video not found\&quot;, \&quot;docs\&quot;: \&quot;https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\&quot;, \&quot;status\&quot;: 404, \&quot;title\&quot;: \&quot;Not Found\&quot;, \&quot;type\&quot;: \&quot;about:blank\&quot; } &#x60;&#x60;&#x60; We provide error &#x60;type&#x60; values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/src/server/core-error-code.enum.ts), but it is still optional. Types are used to disambiguate errors that bear the same status code and are non-obvious: &#x60;&#x60;&#x60; HTTP 1.1 403 Forbidden Content-Type: application/problem+json; charset&#x3D;utf-8 { \&quot;detail\&quot;: \&quot;Cannot get this video regarding follow constraints\&quot;, \&quot;docs\&quot;: \&quot;https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\&quot;, \&quot;status\&quot;: 403, \&quot;title\&quot;: \&quot;Forbidden\&quot;, \&quot;type\&quot;: \&quot;https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints\&quot; } &#x60;&#x60;&#x60; Here a 403 error could otherwise mean that the video is private or blocklisted. ### Validation errors Each parameter is evaluated on its own against a set of rules before the route validator proceeds with potential testing involving parameter combinations. Errors coming from validation errors appear earlier and benefit from a more detailed error description: &#x60;&#x60;&#x60; HTTP 1.1 400 Bad Request Content-Type: application/problem+json; charset&#x3D;utf-8 { \&quot;detail\&quot;: \&quot;Incorrect request parameters: id\&quot;, \&quot;docs\&quot;: \&quot;https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\&quot;, \&quot;instance\&quot;: \&quot;/api/v1/videos/9c9de5e8-0a1e-484a-b099-e80766180\&quot;, \&quot;invalid-params\&quot;: { \&quot;id\&quot;: { \&quot;location\&quot;: \&quot;params\&quot;, \&quot;msg\&quot;: \&quot;Invalid value\&quot;, \&quot;param\&quot;: \&quot;id\&quot;, \&quot;value\&quot;: \&quot;9c9de5e8-0a1e-484a-b099-e80766180\&quot; } }, \&quot;status\&quot;: 400, \&quot;title\&quot;: \&quot;Bad Request\&quot;, \&quot;type\&quot;: \&quot;about:blank\&quot; } &#x60;&#x60;&#x60; Where &#x60;id&#x60; is the name of the field concerned by the error, within the route definition. &#x60;invalid-params.&lt;field&gt;.location&#x60; can be either &#39;params&#39;, &#39;body&#39;, &#39;header&#39;, &#39;query&#39; or &#39;cookies&#39;, and &#x60;invalid-params.&lt;field&gt;.value&#x60; reports the value that didn&#39;t pass validation whose &#x60;invalid-params.&lt;field&gt;.msg&#x60; is about. ### Deprecated error fields Some fields could be included with previous versions. They are still included but their use is deprecated: - &#x60;error&#x60;: superseded by &#x60;detail&#x60; - &#x60;code&#x60;: superseded by &#x60;type&#x60; (which is now an URI) # Rate limits We are rate-limiting all endpoints of PeerTube&#39;s API. Custom values can be set by administrators: | Endpoint (prefix: &#x60;/api/v1&#x60;) | Calls | Time frame | |------------------------------|---------------|--------------| | &#x60;/*&#x60; | 50 | 10 seconds | | &#x60;POST /users/token&#x60; | 15 | 5 minutes | | &#x60;POST /users/register&#x60; | 2&lt;sup&gt;*&lt;/sup&gt; | 5 minutes | | &#x60;POST /users/ask-send-verify-email&#x60; | 3 | 5 minutes | Depending on the endpoint, &lt;sup&gt;*&lt;/sup&gt;failed requests are not taken into account. A service limit is announced by a &#x60;429 Too Many Requests&#x60; status code. You can get details about the current state of your rate limit by reading the following headers: | Header | Description | |-------------------------|------------------------------------------------------------| | &#x60;X-RateLimit-Limit&#x60; | Number of max requests allowed in the current time period | | &#x60;X-RateLimit-Remaining&#x60; | Number of remaining requests in the current time period | | &#x60;X-RateLimit-Reset&#x60; | Timestamp of end of current time period as UNIX timestamp | | &#x60;Retry-After&#x60; | Seconds to delay after the first &#x60;429&#x60; is received | # CORS This API features [Cross-Origin Resource Sharing (CORS)](https://fetch.spec.whatwg.org/), allowing cross-domain communication from the browser for some routes: | Endpoint | |------------------------- ---| | &#x60;/api/*&#x60; | | &#x60;/download/*&#x60; | | &#x60;/lazy-static/*&#x60; | | &#x60;/.well-known/webfinger&#x60; | In addition, all routes serving ActivityPub are CORS-enabled for all origins.
""", # noqa: E501
package_data={"peertube": ["py.typed"]},
)