A self hosted livestreaming server.
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.

237 lines
6.2 KiB

  1. # Using Satyr's Rest API
  2. ## /api/instance/info
  3. Generic enformation about the instance.
  4. **Method**: GET
  5. **Authentication**: no
  6. **Parameters**: none
  7. **Response**: Returns a JSON object containing the name, domain, version, email, and whether registration is open. Email will be null if not specified.
  8. **Example**: `{name: "Example Instance", domain: "example.com", registration: false, version: 0.7, email: null}`
  9. ## /api/instance/config
  10. Configuration of the instance relating to media
  11. **Method**: GET
  12. **Authentication**: no
  13. **Parameters**: none
  14. **Response**: JSON object containing the port and ping_timeout for RTMP, whether clustering is enabled, public and private play endpoints, and whether adaptive livestreaming and VOD recording are enabled.
  15. **Example**:
  16. ```
  17. {
  18. rtmp: {
  19. cluster: false,
  20. port: 1935,
  21. ping_timeout: 60
  22. },
  23. media: {
  24. vods: false,
  25. publicEndpoint: 'live',
  26. privateEndpoint: 'stream',
  27. adaptive: true
  28. }
  29. }
  30. ```
  31. Public and private endpoints work like this, from the above example:
  32. stream to: rtmp://example.com/stream
  33. play from: rtmp://example.com/live/username or https://example.com/live/username/index.mpd
  34. ## /api/users/live/
  35. Returns the usernames and stream titles of 10 users who are currently streaming
  36. **Method**: POST
  37. **Authentication**: no
  38. **Parameters**: num (optional), sort (optional), page (optional)
  39. number is the number of results (maximum is 50)
  40. sort is the optional way to sort results. current options are "alphabet" and "alphabet-r" (reversed)
  41. page is the page number (i.e. skip the first num * page results)
  42. **Response**: Returns an array of JSON objects containing the username and title of each stream. Returns an empty array if no one is streaming. Returns `{"error":"error reason"}` in the event of an error. Will attempt to correct malformed requests to default values.
  43. The array will be wrapped in a JSON object under the key 'users'.
  44. **Example**: `{users: [{username:"foo", title:"bar"}] }`
  45. ## /api/users/all
  46. Same as above, but returns all users regardless of whether they are streaming and if they're streaming or not. Also returns a value 'live' indicating whether a user is currently streaming.
  47. **Example**: `{users: [{username:"foo", title:"bar", live:1}] }`
  48. ## /api/register
  49. Register a new user.
  50. **Method**: POST
  51. **Authentication**: no
  52. **Parameters**: Username, password, confirm, invite(optional)
  53. Invite is an optional invite code to bypass disabled registration.
  54. **Response**: If successful, returns a json object with the users stream key. Otherwise returns `{error: "error reason"}`
  55. **Examples**:
  56. `{stream_key: "asdfghjkltyuiop12345"}`
  57. `{error: "registration disabled"}`
  58. ## /api/login
  59. Obtain a signed json web token for authentication
  60. **Method**: POST
  61. **Authentication**: no
  62. **Parameters**: Username and password OR a valid JWT cookie expiring in less than 24 hours
  63. **Response**: If succesful, will return `{success: ""}` or `{success: "already verified"}` if the JWT provided is too early to be renewed. If unsuccesful, will return `{error: "invalid password"}` or `{error: "Username or Password Incorrect"}` depending on the authentication method. Note that if a JWT is available, the parameters will be ignored.
  64. **Notes**: The returned JWT is set as the cookie httponly 'Authorization'. It will also return a non httponly cookie X-Auth-As with the username of the authenticated user.
  65. ## /api/user/update
  66. Update the current user's information
  67. **Method**: POST
  68. **Authentication**: yes
  69. **Parameters**: title, bio, rec, twitch, twitch_key
  70. Rec is a boolean (whether to record VODs), twitch is a boolean (whether to mirror video streams to twitch) others are strings. Twitch_key is the stream key to use for twitch. Parameters that are not included in the request will not be updated.
  71. **Response**: Returns `{error: "error reason"}` or `{success: ""}`
  72. ## /api/user/update/chat
  73. Update the chatrooms on other platforms to integrate with the user's stream chat
  74. **Method**: POST
  75. **Authentication**: yes
  76. **Parameters**: discord, xmpp, twitch irc
  77. Strings corresponding to a channel name to mirror to. Parameters not included in the request will not be updated.
  78. **Response**: Returns `{error: "error reason"}` or `{success: ""}`
  79. ## /api/user/vods/delete
  80. Delete the specified vods of the current user
  81. **Method:** POST
  82. **Authentication**: yes
  83. **Paramters**: A string array of the names of vods to be deleted. (Do not include the file extension)
  84. **Response**: Returns `{error: "error reason"}` or `{success: ""}`
  85. ## /api/user/password
  86. Change the current user's password
  87. **Method**: POST
  88. **Authentication**: yes
  89. **Parameters**: The user's current password, the new password, AND a valid JWT cookie.
  90. **Response**: Returns `{error: "error reason"}` or `{success: ""}`
  91. ## /api/user/streamkey
  92. Change the current user's stream key. This will not affect the stream if the user is currently live.
  93. **Method**: POST
  94. **Authentication**: yes
  95. **Parameters**: A valid JWT cookie. No other parameters.
  96. **Response**: Returns `{error: "error reason"}` or `{success: "new_stream_key"}`
  97. ## /api/:user/vods
  98. Get a list of the named users VODs
  99. **Method**: GET
  100. **Authentication**: no
  101. **Parameters**: user
  102. **Response**: Returns an array of VODs inside a JSON object with the format `{"vods": [{"name":"yote.mp4"},{"name":"yeet.mp4"}] }`
  103. **Notes**: VODs are always available at http://domain/publicEndpoint/username/filename
  104. ## /api/:user/config
  105. Get information about the specified user.
  106. **Method**: GET
  107. **Authentication**: optional
  108. **Parameters**: user
  109. **Response**: Returns a JSON object with available information about the user. If the user is authenticated and searching for their own information, will return all available information. Otherwise it will return only the stream title, bio, and whether the stream is live. In the case of searching for a user that does not exist, the returned object will contain only the username searched for.
  110. **Example**: `{username: "foo", title: "bar", about: "This is an example bio", live: 0}`
  111. ## /api/user/streamkey/current
  112. Returns the current stream key for the authenticated user.
  113. **Method**: GET
  114. **Authentication**: yes
  115. **Parameters**: none
  116. **Response**: returns a JSON object with the stream key
  117. **Example**: `{stream_key: "abcdefghijklmno12345"}` or `{error:"error reason"}`