案例vs-apiopen in new window的接口文档

描述

版本: v0.1.0
作者: breath57open in new window
e-mail: breath57@163.com
发布日期: 2022-6-27

该文档是vs-apiopen in new window项目HTTP请求的接口文档。

使用步骤

场景描述:注册一个新用户(账号:breath57, 密码:123456)

  • 步骤
    1. 准备url前缀http://localhost:5000
    2. 查看文档可知,请求地址为:POST /v1/user/register
    3. 拼接完整url
    4. 准备请求参数
      {
          "account": "breath57",
          "password": "123456"
      }
      
    5. http://localhost:5000/v1/user/register发起HTTP的POST请求

User 用户部分

注册

  • 请求地址
  POST /v1/user/register
  • 请求参数
属性类型默认值必填说明
accountstring账号
passwordstring密码
nicknamestring新用户昵称
emailstring邮箱

使用案例

  • 请求参数
属性取值
accountbreath57
password123456
  • 返回值
{
    "token": "eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Miwibmlja25hbWUiOiJcdTY1YjBcdTc1MjhcdTYyMzciLCJhY2NvdW50IjoiYnJlYXRoNTciLCJwYXNzd29yZCI6IjEyMzQ1NiIsInNjb3BlIjo4LCJleHAiOjIyNjQwMzQyNTh9.cImxRFDCk7WHE98vGY4D8JGqu7-jMB7WodQJf985RlQ",
    "msg": "新用户(account: breath57)注册!"
}
属性说明
token发起其它资源请求的令牌
msg提示信息

获取Token

  • 请求地址
  POST /v1/token/get
  • 请求参数
属性类型默认值必填说明
accountstring账号
passwordstring密码

使用案例

  • 请求参数
属性取值
accountbreath57
password123456

返回值

{
    "token": "eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Miwibmlja25hbWUiOiJcdTY1YjBcdTc1MjhcdTYyMzciLCJhY2NvdW50IjoiYnJlYXRoNTciLCJwYXNzd29yZCI6IjEyMzQ1NiIsInNjb3BlIjo4LCJleHAiOjIyNjQwMzQ3NzB9.1HfvG-xp1rTk6YdmshU7-UAtl16T5e3oYRQVZ3DuvSU",
    "msg": "新用户(account: breath57)的token获取成功!"
}
属性说明
token发起其它资源请求的令牌
msg提示信息

Resource 资源部分

资源上传

  • 请求地址
  POST /v1/resource/upload
  • 请求参数
属性类型默认值必填说明
tokenstring用户token
typestring上传的资源类型,{“1”:"单个视频", “2”:”章节“,“3”:”课程“}
fileFileObject文件对象, 当type=1时为必填
pathstring本地章节或者课程的根目录, 当type!=1是为必填
stepstring or intfps帧遍历步长
speedfloat3实际的step = step * speed
chapter_idint将视频上传到章节id为chapter_id的章节下
course_idint将视频上传到课程id为course_id的 章节id 为 chapter_id的章节下

使用案例

上传视频
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
file机器学习.mp4 (注意:此处需传入的是字节流构成的视频文件对象)
type1
step50
speed10
  • 返回值
{
    "msg": {
        "id": 1,
        "name": "机器学习",
        "type": 1,
        "config": {
            "step": 50.0,
            "speed": 10.0,
            "min_process_box_height": null,
            "min_searcher_box_with_height": null
        },
        "msg": "上传成功"
    },
    "error_code": 0,
    "request": "POST /v1/resource/upload"
}
上传章节
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
pathF:\Download\BaiduNetDiskDownLoad\101 - OpenCV三大经典项目实战 一次性掌握计算机视觉核心技能\第13章 机器学习
type2
stepfps
speed100
  • 返回值
{
    "name": "第13章 机器学习",
    "dir": "F:\\Download\\BaiduNetDiskDownLoad\\101 - OpenCV三大经典项目实战 一次性掌握计算机视觉核心技能\\第13章 机器学习",
    "belong_course": null,
    "fail_videos": []
}
属性说明
belong_course章节所属的课程
fail_videos章节中上传失败的视频列表
上传课程
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
pathF:\Download\BaiduNetDiskDownLoad\101 - OpenCV三大经典项目实战 一次性掌握计算机视觉核心技能\第13章 机器学习
type3
stepfps
speed60
  • 返回值
{
    "name": "数据分析",
    "dir": "F:\\Download\\BaiduNetDiskDownLoad\\数据分析",
    "fail_chapters": []
}
属性说明
fail_videos课程中上传失败的章节列表

单记录获取

  • 请求地址
  POST /v1/resource/get
  • 请求参数
属性类型默认值必填说明
tokenstring用户token
typestring资源类型,{“1”:"单个视频", “2”:”章节“,“3”:”课程“}
idint资源id

使用案例

根据id获取视频
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type1
id1
  • 返回值
{
    "id": 1,
    "name": "机器学习",
    "url": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0.mp4",
    "img": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/0%23500.png",
    "chapter_id": null,
    "kfs": [
        {
            "id": 500,
            "name": "0#500",
            "img": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/0%23500.png",
            "ms": 20000.0,
            "time": "00:00:20"
        },
 		 ....
        {
            "id": 13500,
            "name": "0#13500",
            "img": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/0%2313500.png",
            "ms": 540000.0,
            "time": "00:09:00"
        }
    ],
    "cw": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0.pdf",
    "create_time": [
        "2022-07-24",
        "10:37:25.177926"
    ]
}
属性描述
url视频的url地址
kfs关键帧列表
kfs.ms关键帧视频中出现的时间
pathF:\Download\BaiduNetDiskDownLoad\101 - OpenCV三大经典项目实战 一次性掌握计算机视觉核心技能\第13章 机器学习
cw生成的pdf课件的url地址
根据id获取章节

请参数

属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type2
id1
  • 返回值
{
    "id": 1,
    "name": "第13章 机器学习",
    "img": null,
    "course_id": null,
    "videos": [
        {
            "id": 2,
            "name": "13-1",
            "img": "http://localhost:5000/static/vsearch-output/chapters/%E7%AC%AC13%E7%AB%A0%20%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/13-1/0%232500.png",
            "create_time": [
                "2022-07-24",
                "10:52:59.650885"
            ]
        },
  		...
        {
            "id": 6,
            "name": "13-5",
            "img": "http://localhost:5000/static/vsearch-output/chapters/%E7%AC%AC13%E7%AB%A0%20%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/13-5/0%232500.png",
            "create_time": [
                "2022-07-24",
                "10:53:39.537382"
            ]
        }
    ],
    "create_time": [
        "2022-07-24",
        "10:52:51.410117"
    ]
}
属性描述
videos章节下的所有视频
videos[0].img视频的封面
根据id获取课程
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type3
id1
  • 返回值
{
    "id": 1,
    "name": "数据分析",
    "img": null,
    "chapters": [
        {
            "id": 2,
            "name": "第3章 单因子探索分析与可视化",
            "img": null,
            "course_id": 1,
            "create_time": [
                "2022-07-24",
                "10:55:49.223517"
            ]
        },
        {
            "id": 3,
            "name": "第4章 多因子探索分析",
            "img": null,
            "course_id": 1,
            "create_time": [
                "2022-07-24",
                "10:55:55.767599"
            ]
        }
    ],
    "create_time": [
        "2022-07-24",
        "10:55:49.169553"
    ]
}
属性描述
chapters课程下的所有章节

多记录获取

  • 请求地址
  POST /v1/resource/gets/pure
  • 请求参数
属性类型默认值必填说明
tokenstring用户token
typestring资源类型,{“1”:"单个视频", “2”:”章节“,“3”:”课程“}
offsetint0偏移量,也就是从第offset条记录开始向后取limit条记录
limitint20取的记录条数

使用案例

获取某个用户下的所属视频
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type1
  • 返回值
{
    "videos": [
        {
            "id": 1,
            "name": "机器学习",
            "img": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/0%23500.png",
            "create_time": [
                "2022-07-24",
                "10:37:25.177926"
            ]
        },
        {
            "id": 7,
            "name": "test6",
            "img": "http://localhost:5000/static/vsearch-output/videos/test6/0%231200.png",
            "create_time": [
                "2022-07-24",
                "10:54:53.412755"
            ]
        }
    ],
    "pager": {
        "offset": 0,
        "limit": 20
    }
}
属性描述
pager使用的分页参数
videos视频列表
获取某个用户下的所属章节
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type2
  • 返回值
{
    "chapters": [
        {
            "id": 1,
            "name": "第13章 机器学习",
            "img": null,
            "course_id": null,
            "create_time": [
                "2022-07-24",
                "10:52:51.410117"
            ]
        }
    ],
    "pager": {
        "offset": 0,
        "limit": 20
    }
}
属性描述
pager使用的分页参数
chapters章节列表
获取某个用户下的所属课程
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type3
  • 返回值
{
    "courses": [
        {
            "id": 1,
            "name": "数据分析",
            "img": null,
            "create_time": [
                "2022-07-24",
                "10:55:49.169553"
            ]
        }
    ],
    "pager": {
        "offset": 0,
        "limit": 20
    }
}
属性描述
pager使用的分页参数
courses课程列表

资源搜索

  • 请求地址
  POST /v1/resource/search
  • 请求参数
属性类型默认值必填说明
tokenstring用户token
idint资源id
typestring资源类型,{“1”:"单个视频", “2”:”章节“,“3”:”课程“}
keystring搜索关键词

使用案例

搜索某个视频的视频内容
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type1
id1
key机器学习
  • 返回值
{
    "id": 1,
    "name": "机器学习",
    "kfs": [
        {
            "id": 500,
            "name": "0#500",
            "img": "http://localhost:5000/static/vsearch-output/search-result/1658633292/54643800_.png",
            "ms": 20000.0,
            "time": "00:00:20"
        },
        {
            "id": 13000,
            "name": "0#13000",
            "img": "http://localhost:5000/static/vsearch-output/search-result/1658633292/76762000_.png",
            "ms": 520000.0,
            "time": "00:08:40"
        },
        {
            "id": 13500,
            "name": "0#13500",
            "img": "http://localhost:5000/static/vsearch-output/search-result/1658633292/98071300_.png",
            "ms": 540000.0,
            "time": "00:09:00"
        }
    ],
    "url": "http://localhost:5000/static/vsearch-output/videos/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0.mp4"
}
属性描述
kfs搜索到的关键帧列表
搜索章节下的所有视频内容
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type2
id1
key学习
  • 返回值
{
    "id": 1,
    "name": "第13章 机器学习",
    "videos": [
        {
            "id": 2,
            "name": "13-1",
            "kfs": [
                {
                    "id": 2500,
                    "name": "0#2500",
                    "img": "http://localhost:5000/static/vsearch-output/search-result/1658633398/29102600_.png",
                    "ms": 100000.0,
                    "time": "00:01:40"
                }
            ],
            "url": "http://localhost:5000/static/vsearch-output/chapters/%E7%AC%AC13%E7%AB%A0%20%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/13-1/13-1.mp4"
        },
        {
            "id": 5,
            "name": "13-4",
            "kfs": [
                {
                    "id": 0,
                    "name": "0#0",
                    "img": "http://localhost:5000/static/vsearch-output/search-result/1658633398/71443400_.png",
                    "ms": 0.0,
                    "time": "00:00:00"
                },
                {
                    "id": 25000,
                    "name": "0#25000",
                    "img": "http://localhost:5000/static/vsearch-output/search-result/1658633398/72926900_.png",
                    "ms": 1000000.0,
                    "time": "00:16:40"
                }
            ],
            "url": "http://localhost:5000/static/vsearch-output/chapters/%E7%AC%AC13%E7%AB%A0%20%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/13-4/13-4.mp4"
        }
    ]
}
属性描述
videos搜索到的视频列表
videos[0].kfs搜索到的视频关键帧列表
搜索课程下的所有视频内容
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type3
id1
key分析
  • 返回值
{
    "id": 1,
    "name": "数据分析",
    "chapters": [
        {
            "id": 2,
            "name": "第3章 单因子探索分析与可视化",
            "videos": [
                {
                    "id": 8,
                    "name": "3-01 数据使用案例介绍",
                    "kfs": [
                        {
                            "id": 0,
                            "name": "0#0",
                            "img": "http://localhost:5000/static/vsearch-output/search-result/1658633574/93821200_.png",
                            "ms": 0.0,
                            "time": "00:00:00"
                        }
                    ],
                    "url": "http://localhost:5000/static/vsearch-output/courses/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/3-01%20%E6%95%B0%E6%8D%AE%E6%A1%88%E4%BE%8B%E4%BB%8B%E7%BB%8D/3-01%20%E6%95%B0%E6%8D%AE%E6%A1%88%E4%BE%8B%E4%BB%8B%E7%BB%8D.mp4"
                }
            ]
        },
        {
            "id": 3,
            "name": "第4章 多因子探索分析",
            "videos": [
                {
                    "id": 10,
                    "name": "4-01 假设检验",
                    "kfs": [
                        {
                            "id": 0,
                            "name": "0#0",
                            "img": "http://localhost:5000/static/vsearch-output/search-result/1658633574/39821800_.png",
                            "ms": 0.0,
                            "time": "00:00:00"
                        }
                    ],
                    "url": "http://localhost:5000/static/vsearch-output/courses/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/4-01%20%E5%81%87%E8%AE%BE%E6%A3%80%E9%AA%8C/4-01%20%E5%81%87%E8%AE%BE%E6%A3%80%E9%AA%8C.mp4"
                }
            ]
        }
    ]
}
属性描述
chapters搜索到的章节列表
chapters[0].videos搜索到的视频列表
chapters[0].videos[0].kfs搜索到的视频关键帧列表

资源删除

  • 请求地址
  POST /v1/resource/del
  • 请求参数
属性类型默认值必填说明
tokenstring用户token
typestring资源类型,{“1”:"单个视频", “2”:”章节“,“3”:”课程“}
idint需要删除资源的id

使用案例

根据id删除视频
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type1
id1
  • 返回值
{
    "msg": {
        "id": 1,
        "name": "机器学习",
        "type": 1,
        "msg": "资源删除成功!"
    },
    "error_code": 0,
    "request": "POST /v1/resource/del"
}
根据id删除章节
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type2
id1
  • 返回值
{
    "msg": {
        "id": 1,
        "name": "第13章 机器学习",
        "type": 2,
        "msg": "资源删除成功!"
    },
    "error_code": 0,
    "request": "POST /v1/resource/del"
}
根据id删除课程
  • 请求参数
属性取值
tokeneyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSw
type3
id1
  • 返回值
{
    "msg": {
        "id": 1,
        "name": "数据分析",
        "type": 3,
        "msg": "资源删除成功!"
    },
    "error_code": 0,
    "request": "POST /v1/resource/del"
}