# gma-video API Documentation ## API Basic Instruction * Restful API * JWT * CORS * Basic path: `https://www.gmademo.com/api/v1` * Communicate using JSON ## User | Usage | Method | Path | parameters | Body | Auth | | :-------------------------- | ------ | ------------------------------- | -------------------- | --------------------------------------------------------- | ------------------------------- | | Register | POST | /user/registers | | username, email, phone, password | | | Login | POST | /user/logins | | email, password | | | Get Auth | GET | /user/auth | | | required | | Get channel(user) info | GET | /user/getuser/:userId | | | optional(for subscribed status) | | Get channel video list | GET | /user/channelvideolist/:userId | page、size(optional) | | | | Get user subscribed channel | GET | /user/getsubscribe/:userId | | page?、size? | | | Subscribe channel | GET | /user/subscribe/:userId | | | required | | Unsubscribe channel | GET | /user/unsubscribe/:userId | | | required | | User update | PUT | /user | | username?, email?, phone?, password?, channeldes?, image? | required | | Upload Avatar | POST | /user/avatar | | [avatar file] | required | ## Video | Usage | Method | Path | parameters | Body | Auth | | :----------------------------------------------------------- | ------ | ------------------------------------ | -------------------- | ----------------- | -------- | | Get all videos' list | GET | /video/videolist | page、size(optional) | | | | Get one video info | GET | /video/video/:videoId | | | | | Get video player link | GET | /video/getvideolink/:videoId | | | | | Get video comments' list | GET | /video/commentlist/:videoId | page、size(optional) | | required | | Post new comment | POST | /video/comment/:videoId | | content | required | | Get user's liked video info list | GET | /video/likelist | page、size(optional) | | required | | Like video | GET | /video/like/:videoId | | | required | | Dislike video | GET | /video/dislike/:videoId | | | required | | Get user's subscribed, like, dislike, save status to a video | GET | /video/videooperation/:videoId/video | | | required | | Save a video | GET | /video/collect/:videoId | | | required | | Get user's saved video list | GET | /video/collectlist | page、size(optional) | | required | | Get hot videos' list | GET | /video/hotvideos/:topNum | | | | | get vod id | GET | /video/getvod | | | required | | create video | POST | /video/createvideo/video | | title, vodvideoId | required | # Request and Response ## User Authentication ``` { headers: { 'authorization': "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mbyI6eyJjb3ZlciI6bnVsbCwiX2lkIjoiNjJiOWMwZDBkYmRkZmY3ODYwOTk2ZDU1IiwidXNlcm5hbWUiOiJoZWxsbzIiLCJlbWFpbCI6ImhlbGxvNUBnbWFpbC5jb20iLCJwaG9uZSI6IjEyMzQ0NDQ1NTU1IiwiaW1hZ2UiOiI5ZjhkM2U0ODY2ZjQ0NjA1YmM3NGY0ZjQzOWU4ZDZiYS5qcGVnIiwiY3JlYXRlQXQiOiIyMDIyLTA2LTI3VDE0OjA0OjU5LjA4NloiLCJ1cGRhdGVBdCI6IjIwMjItMDYtMjdUMTQ6MDQ6NTkuMDg2WiIsIl9fdiI6MCwiY2hhbm5lbGRlcyI6IuaWsOmgreWDj-S4gOi1t-a4rOippiIsInN1YnNjcmliZUNvdW50IjoyfSwiaWF0IjoxNjU4MTQyNzUwLCJleHAiOjE2NTgyMjkxNTB9.AuI3nc7efR-uiKmU2oMiDiz7zFvWe1yAdjdVT9kBXVI", } } ``` ## Users ### Register Request Example ``` { "username": "test1", "email": "test1@hotmail.com", "phone": "123456789", "password": "123456" } ``` Response Example ``` { "user": { "username": "test1", "email": "test1@hotmail.com", "phone": "1234567899", "image": null, "cover": null, "channeldes": null, "subscribeCount": 0, "_id": "62dcd05b1914c2d5edc00fb1", "createAt": "2022-07-24T04:53:47.275Z", "updateAt": "2022-07-24T04:53:47.275Z", "__v": 0 } } ``` ### Login Request Example ``` { "email": "test1@hotmail.com", "password": "123456" } ``` Response Example ``` { "_id": "62dcd05b1914c2d5edc00fb1", "username": "test1", "email": "test1@hotmail.com", "phone": "1234567899", "image": null, "cover": null, "channeldes": null, "subscribeCount": 0, "createAt": "2022-07-24T04:53:47.275Z", "updateAt": "2022-07-24T04:53:47.275Z", "__v": 0, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mbyI6eyJfaWQiOiI2MmRjZDA1YjE5MTRjMmQ1ZWRjMDBmYjEiLCJ1c2VybmFtZSI6InRlc3QxIiwiZW1haWwiOiJ0ZXN0MUBob3RtYWlsLmNvbSIsInBob25lIjoiMTIzNDU2Nzg5OSIsImltYWdlIjpudWxsLCJjb3ZlciI6bnVsbCwiY2hhbm5lbGRlcyI6bnVsbCwic3Vic2NyaWJlQ291bnQiOjAsImNyZWF0ZUF0IjoiMjAyMi0wNy0yNFQwNDo1Mzo0Ny4yNzVaIiwidXBkYXRlQXQiOiIyMDIyLTA3LTI0VDA0OjUzOjQ3LjI3NVoiLCJfX3YiOjB9LCJpYXQiOjE2NTg2Mzg1MjgsImV4cCI6MTY1ODcyNDkyOH0.UJPqExp5lSlMtTYC74xu2e4eQGjjt_Gq4jXeNfJ_Bjc" } ``` ### Get Auth Response Example ``` { "userInfo": { "_id": "62dcd05b1914c2d5edc00fb1", "username": "test1", "email": "test1@hotmail.com", "phone": "1234567899", "image": null, "cover": null, "channeldes": null, "subscribeCount": 0, "createAt": "2022-07-24T04:53:47.275Z", "updateAt": "2022-07-24T04:53:47.275Z", "__v": 0 } } ``` ### Get channel(user) info Response Example ``` { "_id": "62b9c0d0dbddff7860996d55", "username": "test2", "image": "9f8d3e4866f44605bc74f4f439e8d6ba.jpeg", "subscribeCount": 200, "cover": null, "channeldes": "This is channel description for user test2", "createAt": "2022-06-27T14:04:59.086Z", "isSubscribe": false } ``` ### Get channel video list ``` { "videoList": [ { "_id": "62bd17eb28ae45ab4874f218", "title": "Video1", "vodvideoid": "8c5ff10812e84a64a622bc96afc92864", "user": "62b9c0d0dbddff7860996d55", "createAt": "2022-06-30T03:26:05.489Z", "updateAt": "2022-06-30T03:26:05.489Z", "__v": 0, "commentCount": 5, "dislikeCount": 1, "likeCount": 0 }, { "_id": "62bd18cd7271e655d5b15e8b", "title": "Video2", "vodvideoid": "dc4b4e38df9542f1824afe5d0f36dd6e", "user": "62b9c0d0dbddff7860996d55", "createAt": "2022-06-30T03:27:57.412Z", "updateAt": "2022-06-30T03:29:57.412Z", "__v": 0, "commentCount": 1, "dislikeCount": 0, "likeCount": 2 }, { "_id": "62bd391bcccf8ea338c0ed9e", "title": "Video3", "vodvideoid": "aef6d9aede7840c2a71d4779ef618cae", "user": "62b9c0d0dbddff7860996d55", "createAt": "2022-06-30T03:28:57.412Z", "updateAt": "2022-06-30T03:29:57.412Z", "__v": 0, "commentCount": 4, "dislikeCount": 0, "likeCount": 1 } ] } ``` ### Get user subscribed channel Response Example ``` { "subscribeList": [ { "_id": "62bd60b8401ef87671062a50", "username": "bbb", "image": null, "subscribeCount": 2, "cover": null, "channeldes": "Channel aaa des", "createAt": "2022-06-30T08:21:07.237Z" }, { "_id": "62bd60b0401ef87671062a4c", "username": "aaa", "image": null, "subscribeCount": 1, "cover": null, "channeldes": "Channel bbb des", "createAt": "2022-06-30T08:21:07.237Z" } ] } ``` ### Subscribe a channel ``` { "msg": "Successfully unsubscribe Achannel" } ``` ### Unsubscribe a channel ``` { "msg": "Successfully unsubscribe Achannel" } ``` ### User update Request Example ``` { "username": "cccc", "email": "cc@gmail.com", "phone": "12233445566", "channeldes": "Updated ccc channeldes" } ``` Response Example ``` { "user": { "_id": "62bd60bf401ef87671062a54", "username": "cccc", "email": "cc@gmail.com", "phone": "12233445566", "image": null, "cover": null, "createAt": "2022-06-30T08:21:07.237Z", "updateAt": "2022-06-30T08:21:07.237Z", "__v": 0, "subscribeCount": 0, "channeldes": "Updated ccc channeldes" } } ``` ### Upload Avatar Request Example | KEY | VALUE | | ------ | ------------ | | avatar | example.jpeg | Response Example ``` { "filepath": "a6379b303db0f24e25145b3230f65e4f.jpeg" } ``` ## Video ### Get all videos' list Response Example(`/api/v1/video/videolist?size=3`) ``` { "videoList": [ { "_id": "62bd3939cccf8ea338c0eda0", "title": "Video5", "vodvideoid": "e74358d864244b9fa6601b057403253e", "user": { "cover": null, "_id": "62b9c0d0dbddff7860996d55", "username": "hello2" }, "createAt": "2022-06-30T03:30:57.412Z", "updateAt": "2022-06-30T03:29:57.412Z", "__v": 0, "commentCount": 0, "dislikeCount": 1, "likeCount": 1 }, { "_id": "62bd3930cccf8ea338c0ed9f", "title": "Video4", "vodvideoid": "4437259bea2a4d9e85073725a5221792", "user": { "cover": null, "_id": "62b9c0d0dbddff7860996d55", "username": "hello2" }, "createAt": "2022-06-30T03:29:57.412Z", "updateAt": "2022-06-30T03:29:57.412Z", "__v": 0, "commentCount": 0, "dislikeCount": 0, "likeCount": 1 }, { "_id": "62bd391bcccf8ea338c0ed9e", "title": "Video3", "vodvideoid": "aef6d9aede7840c2a71d4779ef618cae", "user": { "cover": null, "_id": "62b9c0d0dbddff7860996d55", "username": "hello2" }, "createAt": "2022-06-30T03:28:57.412Z", "updateAt": "2022-06-30T03:29:57.412Z", "__v": 0, "commentCount": 4, "dislikeCount": 0, "likeCount": 1 } ], "videoCount": 11 } ``` ### Get one video info response example ``` { "_id": "62c6a547c067f95994056d49", "title": "Video1", "vodvideoid": "8c5ff10812e84a64a622bc96afc92864", "user": { "_id": "62c59de1f736ccfb61bac374", "username": "tony", "cover": null, "subscribeCount": 2 }, "commentCount": 2, "createAt": "2022-07-17T08:10:02.889Z", "dislikeCount": 0, "likeCount": 1, "updateAt": "2022-07-17T08:10:02.889Z", "isLike": false, "isDislike": false, "isSubscribe": false } ``` ### Get video player link ``` { "response": { "VideoBase": { "Status": "Normal", "VideoId": "e74358d864244b9fa6601b057403253e", "TranscodeMode": "NoTranscode", "CreationTime": "2022-06-30T05:49:28Z", "Title": "Video5", "MediaType": "video", "CoverURL": "http://outin-641abe30f7b811ecb8a900163e1a3b4a.oss-cn-shanghai.aliyuncs.com/e74358d864244b9fa6601b057403253e/snapshots/d2b391dca23b4dcda15f35de81c1c9a8-00001.jpg?Expires=1658657416&OSSAccessKeyId=LTAIrkwb21KyGjJl&Signature=VrG4KqPZl7G2cx83cjjrGd1itn0%3D", "Duration": "14.2667", "OutputType": "oss" }, "RequestId": "68CE1C26-03DF-5CD1-A6CF-6D37DA59BD0E", "PlayInfoList": { "PlayInfo": [ { "Status": "Normal", "StreamType": "video", "Size": 2022128, "Definition": "OD", "Fps": "30", "Specification": "Original", "ModificationTime": "2022-06-30T05:49:28Z", "Duration": "14.2667", "Bitrate": "1133.9", "Encrypt": 0, "PreprocessStatus": "UnPreprocess", "Format": "mp4", "NarrowBandType": "0", "PlayURL": "https://outin-641abe30f7b811ecb8a900163e1a3b4a.oss-cn-shanghai.aliyuncs.com/sv/407b1760-181b328406d/407b1760-181b328406d.mp4?Expires=1658657416&OSSAccessKeyId=LTAIrkwb21KyGjJl&Signature=grs%2FG0StKSM2NpZ3g9o0GZoeSsE%3D", "CreationTime": "2022-06-30T05:49:28Z", "Height": 1280, "Width": 720, "JobId": "e74358d864244b9fa6601b057403253e02" } ] } } } ``` ### Get video comments' list response example ``` { "comments": [ { "_id": "62c4ac3a6f1c802af8554311", "content": "comment for test", "video": "62bd18cd7271e655d5b15e8b", "user": { "_id": "62b9c0d0dbddff7860996d55", "username": "hello2", "image": "9f8d3e4866f44605bc74f4f439e8d6ba.jpeg" }, "createAt": "2022-07-05T21:25:12.235Z", "updateAt": "2022-07-05T21:25:12.235Z", "__v": 0 } ], "commentCount": 1 } ``` ### Post new comment request example ``` { "content": "comment for test" } ``` response example ``` { "content": "comment for test", "video": "62bd17eb28ae45ab4874f218", "user": "62bd60bf401ef87671062a54", "_id": "62dd0d0df9cb93721667c0f4", "createAt": "2022-07-24T09:12:45.134Z", "updateAt": "2022-07-24T09:12:45.134Z", "__v": 0 } ``` ### Get user's liked video info list response example ``` { "likeInfo": [ { "_id": "62c1763834049d7e212eddc4", "user": "62bd60b0401ef87671062a4c", "video": { "_id": "62bd18cd7271e655d5b15e8b", "title": "Video2", "user": "62b9c0d0dbddff7860996d55" }, "like": 1, "createAt": "2022-07-03T10:57:15.927Z", "updateAt": "2022-07-03T10:57:15.927Z", "__v": 0 }, { "_id": "62d55f648ae631253170213f", "user": "62bd60b0401ef87671062a4c", "video": { "_id": "62d152116a3b527fc270c02c", "title": "istock-1053281736_preview", "user": "62bd60b0401ef87671062a4c" }, "like": 1, "createAt": "2022-07-18T13:25:56.839Z", "updateAt": "2022-07-18T13:25:56.839Z", "__v": 0 } ], "likeCount": 2 } ``` ### Like video response example ``` { "_id": "62bd17eb28ae45ab4874f218", "title": "Video1", "vodvideoid": "8c5ff10812e84a64a622bc96afc92864", "user": "62b9c0d0dbddff7860996d55", "createAt": "2022-06-30T03:26:05.489Z", "updateAt": "2022-06-30T03:26:05.489Z", "__v": 0, "commentCount": 6, "dislikeCount": 0, "likeCount": 1, "isLike": true } ``` ### Dislike video ``` { "_id": "62bd17eb28ae45ab4874f218", "title": "Video1", "vodvideoid": "8c5ff10812e84a64a622bc96afc92864", "user": "62b9c0d0dbddff7860996d55", "createAt": "2022-06-30T03:26:05.489Z", "updateAt": "2022-06-30T03:26:05.489Z", "__v": 0, "commentCount": 6, "dislikeCount": 1, "likeCount": 0, "isDislike": true } ``` ### Get user's subscribed, like, dislike, save status to a video response example ``` { "videoOperate": { "like": -1, "save": false, "subscribe": false } } ``` ### Save a video response example ``` //save { "userCollection": { "user": "62b9c0d0dbddff7860996d55", "video": "62bd17eb28ae45ab4874f218", "_id": "62dd0ecbf9cb93721667c119", "createAt": "2022-07-24T09:20:11.393Z", "updateAt": "2022-07-24T09:20:11.393Z", "__v": 0 } } ``` ``` //save again to cancel { "msg": "The video 62bd17eb28ae45ab4874f218 has been canceled saving" } ``` ### Get user's saved video list ``` { "collectList": [ { "_id": "62d43d486196b107cd9c9342", "user": "62bd60b0401ef87671062a4c", "video": { "_id": "62bd3939cccf8ea338c0eda0", "title": "Video5", "user": "62b9c0d0dbddff7860996d55" }, "createAt": "2022-07-17T15:27:53.013Z", "updateAt": "2022-07-17T15:27:53.013Z", "__v": 0 }, { "_id": "62d458096196b107cd9c9436", "user": "62bd60b0401ef87671062a4c", "video": { "_id": "62d152116a3b527fc270c02e", "title": "counter100 3_preview", "user": "62bd60b8401ef87671062a50" }, "createAt": "2022-07-17T15:27:53.013Z", "updateAt": "2022-07-17T15:27:53.013Z", "__v": 0 } ] } ``` ### Get hot videos' list example response ``` { "hotVideos": { "62bd17eb28ae45ab4874f218": "904", "62d152116a3b527fc270c02c": "485", "62bd18cd7271e655d5b15e8b": "204", "62bd3930cccf8ea338c0ed9f": "169", "62bd3939cccf8ea338c0eda0": "155", "62d152116a3b527fc270c02e": "86", "62d152116a3b527fc270c02b": "71", "62bd391bcccf8ea338c0ed9e": "66", "62b9c0d0dbddff7860996d55": "26", "62d152116a3b527fc270c02d": "22" } } ``` ### get vod id ``` { "vod": { "VideoId": "b99350f38b664f7db46e9126877e37b4", "UploadAddress": "eyJFbmRwb2ludCI6Imh0dHBzOi8vb3NzLWNuLXNoYW5naGFpLmFsaXl1bmNzLmNvbSIsIkJ1Y2tldCI6Im91dGluLTY0MWFiZTMwZjdiODExZWNiOGE5MDAxNjNlMWEzYjRhIiwiRmlsZU5hbWUiOiJzdi9kMTk1MzctMTgyMmY4OTY4ZmYvZDE5NTM3LTE4MjJmODk2OGZmLm1wNCJ9", "RequestId": "08D1DFD5-84A2-58AD-9D61-95096479410A", "UploadAuth": "eyJTZWN1cml0eVRva2VuIjoiQ0FJU2x3VjFxNkZ0NUIyeWZTaklyNWJDQ283NGlaY1ZnSWJlVGszUTFrUWVhdllZcTZLU2xqejJJSDlJZEhWb0FPOGZ2dlUwbTJ0WTdQc1psclVxRjhZZUZCR2FNWkF1c01rTHFWNy9KcGZadjh1ODRZQURpNUNqUWFoVTRvZ3hoSjI4V2Y3d2FmK0FVRTdHQ1RtZDVJd1lvOWJUY1RHbFFDWVBXLy90b0pWN2I5TVJjeENsWkQ1ZGZybC9MUmRqcjhsbzlCR3pVUEcyS1V6U24zYjNCa2hsc1JZZTcyUms4dmFIeGRhQXpSRGNnVmJtcUlrU3ZKK2pDWis4ZnU1bVBwcDBUN1hRMi9kdEpJWE16QWxhNlJWQjZNVU9pN2RmcXg3ZnB0eWJEMzViNFJpTkw0aXk5Y1owZmk5MGI2UWRFYXhKcCtTZTdQcGpvYjc4bXBqUXdSUkFOdjF3WGpqV0p2T24yOUNXT2VXb0t0Y3dhYnZlSm5EUjA4aU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leVNlY3JldCI6IjN4UkJMRDVFZUxvbWdHem4xWjVQR0FHTnpWcHV6aVdKeU1VeGhoSkFOZWY4IiwiRXhwaXJhdGlvbiI6IjM2MDAiLCJSZWdpb24iOiJjbi1zaGFuZ2hhaSJ9" } } ``` ### create video request example ``` { "title": "test title", "vodvideoid": "b99350f38b664f7db46e9126877e37b4" } ``` response example ``` { "dbBack": { "title": "test title", "vodvideoid": "b99350f38b664f7db46e9126877e37b4", "user": "62bd60b0401ef87671062a4c", "commentCount": 0, "likeCount": 0, "dislikeCount": 0, "_id": "62dd118a041b433c52eb3805", "createAt": "2022-07-24T09:31:54.052Z", "updateAt": "2022-07-24T09:31:54.052Z", "__v": 0 } } ```