[关闭]
@soszrg 2017-09-21T06:18:37.000000Z 字数 7845 阅读 406

V3前端接口

v3文档 v3前端接口


服务地址

token说明

所有标明token认证的接口,需要在请求header中添加Authorization头域,如下示例:

  1. Authorization: token eyJhbGciOiJ...

ErrorCode说明

code 说明
10100 token过期
10101 token错误

参数说明


用户相关


获取验证码

POST /v3/accounts/vercode/

请求参数

参数名 类型 必须 说明
identification string 邮箱或手机号
type int 验证码类型

返回值

  1. {
  2. "meta": {
  3. "message": "短信发送成功",
  4. "code": 0
  5. },
  6. "data": {}
  7. }

或者

  1. {
  2. "meta": {
  3. "message": "邮件发送成功",
  4. "code": 0
  5. },
  6. "data": {}
  7. }

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段

用户注册

POST /v3/accounts/signup/

请求参数

参数名 类型 必须 说明
username string 用户名(全站唯一,)
identification string 邮箱或手机号码(全站唯一)
password string 设置的登录密码
vercode string 验证码

返回值

  1. {
  2. "meta": {
  3. "message": "注册成功",
  4. "code": 0
  5. },
  6. "data": {}
  7. }

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10300 验证码过期
10301 验证码错误
10050 未知错误

用户登录

POST /v3/accounts/signin/

请求参数

参数名 类型 必须 说明
identification string 邮箱或手机号码
password string 登录密码

返回值

  1. {
  2. "meta": {
  3. "message": "登录成功!",
  4. "code": 0
  5. },
  6. "data": {
  7. "token": "9d39bfef2d555f4863d091e8780b50ad8b8af34a",
  8. "user": {
  9. "user": {
  10. "email": "zhangrg@mxchip.com",
  11. "username": "zrg",
  12. "last_login": "2017-09-12T10:09:23.897582",
  13. "date_joined": "2017-05-25T14:11:46.133734"
  14. },
  15. "mugshot": null,
  16. "language": "en",
  17. "phone": "",
  18. "gender": null,
  19. "website": "ss",
  20. "name": "aaa",
  21. "location": "sss",
  22. "birth_date": null,
  23. "about_me": "",
  24. "companyname": "sss",
  25. "headimage": "https://mxchip-fog.oss-cn-beijing.aliyuncs.com/profile/jGySNXTsYB.jpg",
  26. "regtype": 0,
  27. "endpointname": "060b6684411111e7b7ac00163e30fc50",
  28. "mqtthost": "060b6684411111e7b7ac00163e30fc50.mqtt.iot.gz.baidubce.com:1883",
  29. "mqttssl": "060b6684411111e7b7ac00163e30fc50.mqtt.iot.gz.baidubce.com:1884",
  30. "mqttwss": "060b6684411111e7b7ac00163e30fc50.mqtt.iot.gz.baidubce.com:8884",
  31. "kafka": ""
  32. }
  33. }
  34. }

字段说明

字段 类型 说明
token string 用户token,用于需要token认证的接口
user.user.email string 用户注册邮箱
user.user.username string 用户名
user.user.last_login string 上次登录时间
user.user.date_joined string 注册时间
user.phone string 注册手机号
user.headimage string 用户头像

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10602 用户被禁用
10603 用户名或密码错误

注销接口(token)

POST /v3/accounts/signout/

请求参数

返回值

  1. {
  2. "meta": {
  3. "message": "注销成功!",
  4. "code": 0
  5. },
  6. "data": {}
  7. }

错误码


密码重置

PUT /v3/accounts/password/reset/

请求参数

参数名 类型 必须 说明
identification string 邮箱或手机号码
newpasswd string 新密码
vercode string 验证码

返回值

  1. {
  2. "meta": {
  3. "message": "重置密码成功!",
  4. "code": 0
  5. },
  6. "data": {}
  7. }

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段

产品相关


产品列表(token)

GET /v3/product/list/

请求参数

参数名 类型 必须 说明
type int 产品类别:0→消费电子类产品,1→工业类产品,2→OTA产品

返回值

  1. {
  2. "meta":{
  3. "message":"产品列表获取成功",
  4. "code":0
  5. },
  6. "data":{
  7. "count":2,
  8. "result":[
  9. {
  10. "productid":"f61f16a4...",
  11. "pname":"APP—球泡灯",
  12. "brand":"庆科",
  13. "model":"A10"
  14. },
  15. {
  16. "productid":"6da6efb294...",
  17. "pname":"APP—插座",
  18. "brand":"庆科",
  19. "model":"A09"
  20. }
  21. ]
  22. }
  23. }

字段说明

字段 类型 说明
productid string 产品ID
pname string 产品名字
brand string 品牌名
model string 型号名

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段

产品详情(token)

GET /v3/product/productinfo/

请求参数

参数名 类型 必须 说明
productid string 产品ID

返回值

  1. {
  2. "meta":{
  3. "message":"产品详情获取成功",
  4. "code":0
  5. },
  6. "data":{
  7. "productid":"30eb18c687...",
  8. "attributes":{
  9. },
  10. "pname":"faf",
  11. "brand":"faf",
  12. "model":"afaf",
  13. "commonflag":0,
  14. "abilitytype":0,
  15. "description":"",
  16. "url":"",
  17. "pic":"https://mxchip-fog.oss-cn-beijing.aliyuncs.com/product/BWsEhisZfT.png",
  18. "secretKey":"",
  19. "identifier":0,
  20. "pubtime":"2017-08-22T15:41:02.289170",
  21. "link_mode":"0",
  22. "gatewaytype":0,
  23. "checkvalidity":false,
  24. "ipstaticfiles":null,
  25. "status":0,
  26. "submittime":"2017-08-22T15:41:02.289198",
  27. "modifytime":null,
  28. "auditmark":3,
  29. "audittime":null,
  30. "wx_flag":false,
  31. "wx_product_id":"",
  32. "access_token_url":"",
  33. "istransfered":false,
  34. "activation_price":0,
  35. "message_price":0,
  36. "owner":4,
  37. "producttype":2,
  38. "submitter":4,
  39. "modifier":null,
  40. "auditor":null
  41. }
  42. }

字段说明

字段 类型 说明
productid string 产品ID
pname string 产品名字
brand string 品牌名
abilitytype string 产品类别:0→消费电子类产品,1→工业类产品,2→OTA产品
pic string 产品图标
pubtime string 产品发布时间
status int 当前状态:0→开发中,1→已上线,2→审核中
submittime string 产品创建时间
modifytime string 产品修改时间
istransfered bool 是否开启数据转存
owner int 拥有者
producttype int 产品所属类型
owner int 拥有者

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10150 产品ID错误
10151 当前用户无权限操作该产品

产品类型(token)

GET /v3/product/producttypelist/

请求参数

返回值

  1. {
  2. "meta":{
  3. "message":"产品类型列表获取成功",
  4. "code":0
  5. },
  6. "data":[
  7. {
  8. "id":2,
  9. "bigclass":"故事机",
  10. "smallclass":"故事机",
  11. "commonflag":0,
  12. "visible":false
  13. },
  14. {
  15. "id":4,
  16. "bigclass":"生活电器",
  17. "smallclass":"空气检测仪",
  18. "commonflag":0,
  19. "visible":false
  20. },
  21. {
  22. "id":5,
  23. "bigclass":"生活电器",
  24. "smallclass":"扫地机器人",
  25. "commonflag":0,
  26. "visible":false
  27. }
  28. ]
  29. }

字段说明

字段 类型 说明
id int 产品类型ID
bigclass string 产品大类名
smallclass string 产品子类名(前端显示该名字)
commonflag bool 公版标识:true→公版,false→订制
visible bool 是否对其他用户可见, true→可见,false→不可见

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10150 产品ID错误
10151 当前用户无权限操作该产品

创建产品(token)

POST /v3/product/productinfo/

请求参数

参数名 类型 必须 说明
abilitytype int 产品类别
brand string 品牌
model string 型号
pname string 产品名
producttype int 产品类型(通过产品类别接口获取类别list)

返回值

  1. {
  2. "meta":{
  3. "message":"产品创建成功",
  4. "code":0
  5. },
  6. "data":{
  7. "productid":"8b34fd32976c11e7b7ac00163e30fc50",
  8. "attributes":{
  9. },
  10. "pname":"aaa",
  11. "brand":"aa",
  12. "model":"aa",
  13. "commonflag":0,
  14. "abilitytype":0,
  15. "description":"",
  16. "url":"",
  17. "pic":"https://mxchip-fog.oss-cn-beijing.aliyuncs.com/product/productdefault.jpg",
  18. "secretKey":"",
  19. "identifier":0,
  20. "pubtime":"2017-09-12T11:43:30.586489",
  21. "link_mode":"",
  22. "gatewaytype":0,
  23. "checkvalidity":false,
  24. "ipstaticfiles":null,
  25. "status":0,
  26. "submittime":"2017-09-12T11:43:30.586626",
  27. "modifytime":null,
  28. "auditmark":3,
  29. "audittime":null,
  30. "wx_flag":false,
  31. "wx_product_id":"",
  32. "access_token_url":"",
  33. "istransfered":false,
  34. "activation_price":0,
  35. "message_price":0,
  36. "owner":4,
  37. "producttype":4,
  38. "submitter":4,
  39. "modifier":null,
  40. "auditor":null
  41. }
  42. }

字段说明

字段 类型 说明
productid string 产品ID
pname string 产品名字
brand string 品牌名
abilitytype string 产品类别:0→消费电子类产品,1→工业类产品,2→OTA产品
pic string 产品图标
pubtime string 产品发布时间
status int 当前状态:0→开发中,1→已上线,2→审核中
submittime string 产品创建时间
modifytime string 产品修改时间
istransfered bool 是否开启数据转存
owner int 拥有者
producttype int 产品所属类型
owner int 拥有者

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10150 产品ID错误
10151 当前用户无权限操作该产品

更新产品(token)

PUT /v3/product/productinfo/

请求参数

参数名 类型 必须 说明
productid string 产品ID
abilitytype int 产品类别
brand string 品牌
model string 型号
pname string 产品名
producttype int 产品类型(通过产品类别接口获取类别list)
checkvalidity bool 是否强制校验
description string 产品描述
pic string 产品图标
url string 产品介绍链接

返回值

  1. {
  2. "meta":{
  3. "message":"产品基本信息更新成功",
  4. "code":0
  5. },
  6. "data":{
  7. "productid":"30eb18c6870d...",
  8. "attributes":{
  9. },
  10. "pname":"faf",
  11. "brand":"faf",
  12. "model":"afaf",
  13. "commonflag":0,
  14. "abilitytype":0,
  15. "description":"",
  16. "url":"",
  17. "pic":"https://mxchip-fog.oss-cn-beijing.aliyuncs.com/product/BWsEhisZfT.png",
  18. "secretKey":"",
  19. "identifier":0,
  20. "pubtime":"2017-09-12T11:56:31.561388",
  21. "link_mode":"0",
  22. "gatewaytype":0,
  23. "checkvalidity":false,
  24. "ipstaticfiles":null,
  25. "status":0,
  26. "submittime":"2017-09-12T11:56:31.561417",
  27. "modifytime":null,
  28. "auditmark":3,
  29. "audittime":null,
  30. "wx_flag":false,
  31. "wx_product_id":"",
  32. "access_token_url":"",
  33. "istransfered":false,
  34. "activation_price":0,
  35. "message_price":0,
  36. "owner":4,
  37. "producttype":2,
  38. "submitter":4,
  39. "modifier":null,
  40. "auditor":null
  41. }
  42. }

字段说明

字段 类型 说明
productid string 产品ID
pname string 产品名字
brand string 品牌名
abilitytype string 产品类别:0→消费电子类产品,1→工业类产品,2→OTA产品
pic string 产品图标
pubtime string 产品发布时间
status int 当前状态:0→开发中,1→已上线,2→审核中
submittime string 产品创建时间
modifytime string 产品修改时间
istransfered bool 是否开启数据转存
owner int 拥有者
producttype int 产品所属类型

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10150 产品ID错误
10151 当前用户无权限操作该产品

删除产品(token)

DELETE /v3/product/productinfo/

请求参数

参数名 类型 必须 说明
productid string 产品ID

返回值

  1. {
  2. "meta":{
  3. "message":"产品基本信息删除成功",
  4. "code":0
  5. },
  6. "data":{
  7. "productid":"30eb18c6870d...",
  8. "attributes":{
  9. },
  10. "pname":"faf",
  11. "brand":"faf",
  12. "model":"afaf",
  13. "commonflag":0,
  14. "abilitytype":0,
  15. "description":"",
  16. "url":"",
  17. "pic":"https://mxchip-fog.oss-cn-beijing.aliyuncs.com/product/BWsEhisZfT.png",
  18. "secretKey":"",
  19. "identifier":0,
  20. "pubtime":"2017-09-12T11:56:31.561388",
  21. "link_mode":"0",
  22. "gatewaytype":0,
  23. "checkvalidity":false,
  24. "ipstaticfiles":null,
  25. "status":0,
  26. "submittime":"2017-09-12T11:56:31.561417",
  27. "modifytime":null,
  28. "auditmark":3,
  29. "audittime":null,
  30. "wx_flag":false,
  31. "wx_product_id":"",
  32. "access_token_url":"",
  33. "istransfered":false,
  34. "activation_price":0,
  35. "message_price":0,
  36. "owner":4,
  37. "producttype":2,
  38. "submitter":4,
  39. "modifier":null,
  40. "auditor":null
  41. }
  42. }

错误码

错误代码 错误说明
10000 参数错误:参考Response中的message字段
10150 产品ID错误
10151 当前用户无权限操作该产品
10152 当前产品已经有设备激活,无法删除

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注