ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

quickstart.md 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # REST API quick start
  2. ## Detect a PeerTube instance
  3. There are several ways to know if a website uses the PeerTube software:
  4. * The server exposes NodeInfo information: https://peertube2.cpy.re/nodeinfo/2.0.json
  5. * The server sends a `x-powered-by: PeerTube` header response to API requests
  6. * HTML pages include a `<meta property="og:platform" content="PeerTube">` tag
  7. ## Authentication
  8. ### Get client
  9. Some endpoints need authentication. We use OAuth 2.0 so first fetch the client tokens:
  10. ```bash
  11. curl https://peertube.example.com/api/v1/oauth-clients/local
  12. ```
  13. Response example:
  14. ```json
  15. {
  16. "client_id": "v1ikx5hnfop4mdpnci8nsqh93c45rldf",
  17. "client_secret": "AjWiOapPltI6EnsWQwlFarRtLh4u8tDt"
  18. }
  19. ```
  20. ### Get user token
  21. Now you can fetch the user token:
  22. ```bash
  23. curl -X POST \
  24. -d "client_id=v1ikx5hnfop4mdpnci8nsqh93c45rldf&client_secret=AjWiOapPltI6EnsWQwlFarRtLh4u8tDt&grant_type=password&response_type=code&username=your_user&password=your_password" \
  25. https://peertube.example.com/api/v1/users/token
  26. ```
  27. Response example:
  28. ```json
  29. {
  30. "access_token": "90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0",
  31. "token_type": "Bearer",
  32. "expires_in": 14399,
  33. "refresh_token": "2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7"
  34. }
  35. ```
  36. Just use the `access_token` in the `Authorization` header:
  37. ```bash
  38. curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
  39. ```
  40. ## List videos
  41. ```bash
  42. curl https://peertube.example.com/api/v1/videos
  43. ```
  44. ## Libraries
  45. [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:
  46. - [python](https://framagit.org/framasoft/peertube/clients/python)
  47. - [go](https://framagit.org/framasoft/peertube/clients/go)
  48. - [kotlin](https://framagit.org/framasoft/peertube/clients/kotlin)
  49. 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.