# 设备接口

# 接口地址

https://api.iflyos.cn/showcore/api/v1/

# 请求头部

Authorization: Bearer token

# 用户信息

# 获取用户信息

GET /profile

# 响应

{
  "avatar": "https://cdn.iflyos.cn/public/iflyos_users/avatars/4c28661b6257b62968c8b3cef8bb94e7/e1e1d1b5d73a496047f3258c352223ef.png",
  "birthday": null,
  "gender": null,
  "nickname": "zzboom",
  "phone": "136****5872"
}

# 设备信息

# 获取设备信息

GET /device

# 响应

{
  "status": "offline",
  "alias": "xxxx",
  "sleep": "22:00-7:00",
  "sleep_config": {
    "enable": true,
    "start": "22:00",
    "end": "07:00"
  },
  "speaker": "小飞小姐姐",
  "bluetooth_enable": true,
  "wakeword": "嘿,小飞",
  "new_version": false,
  "infrared": {
    "logo": "https://cdn.iflyos.cn/....",
    "client_id": "ceb62135-38a7-42c3-b721-842f3ed596a8"
  },
  "reboot": true,
  "reset_network": true,
  "restore_factory": true,
  "music_access": {
    "name": "畅听卡",
    "value": "2019-12-01",
    "redirect_url": "xxxx"
  },
  "children_mode": true
}

# 说明

字段 类型 说明
alias string 设备别名,没有设置时为null
sleep string 定时休眠配置,关闭时为null
sleep_config.enable boolean 定时休眠配置,是否开启
sleep_config.start boolean 定时休眠开始时间
sleep_config.end boolean 定时休眠结束时间
bluetooth_enable boolean 蓝牙是否开启
speaker string 发音人名称
wakeword string 唤醒词
new_version boolean 是否有新版本
infrared object 设备红外控制参数,字段不存在时红外配置
infrared.client_id object 红外控制设备 client_id
infrared.logo object 红外控制设备 logo
reboot boolean 设备重启,默认为 true
reset_network boolean 重新配网,默认为 true
restore_factory boolean 恢复出厂默认为 true
music_access object 音乐使用权限
music_access.name string 显示名称
music_access.value string 显示值
music_access.redirect_url string 跳转地址
status string 设备在离线状态
children_mode boolean 儿童模式是否开启

# 桌面推荐

# 获取桌面推荐列表

GET /banners

# 响应

[
  {
    "id": 1,
    "cover": "https://cdn.iflyos.cn/public/app_found_image/e7r4mheD9aoA4uXNL5fTRMQL",
    "title": "垃圾分类",
    "descriptions": ["你可以说: 蓝小飞, 打开垃圾分类"],
    "target": "skill",
    "content": "打开垃圾分类"
  },
  ...
]

# 说明

字段 类型 说明
target string 音频: audio / 视频: video / 技能: skill / 网页: webview
content string 音/视频: media_id / 技能: 触发文本 / 网页: 链接

# 技能商店

# 获取技能栏目

GET /skill_sections

# 响应

[
  {
    "id": 1,
    "title": "栏目标题"
    "skills": [
      {
        "id": 8,
        "name": "古诗词",
        "icon": "http://10.4.114.72:3000/images/icons/ic_poem.png",
        "examples": [
          "李白的赠汪伦",
          "举头望明月的上一句",
          "给我背一首诗"
        ],
        "description": "古人的智慧,基本都在这里了。可根据诗句或诗人诗名查询"
      },
      ...
    ]
  },
  ...
]

# 获取技能详情

GET /skills/:id

# 响应

{
  "id": 8,
  "name": "古诗词",
  "icon": "http://10.4.114.72:3000/images/icons/ic_poem.png",
  "examples": ["李白的赠汪伦", "举头望明月的上一句", "给我背一首诗"],
  "category_name": "教育",
  "description": "古人的智慧,基本都在这里了。可根据诗句或诗人诗名查询",
  "developer": "iFLYOS",
  "version": "v1.0",
  "updated_time": "2018年5月17日",
  "account_linked": false,
  "account_link_url": "..."
}

# 内容发现

# 获取内容栏目

GET /media_sections

# 响应

[
  {
    "id": 1,
    "abbr": "音乐",
    "display_mode": "tile",
    "has_more": false,
    "name": "热门榜单",
    "items": [
      {
        "name": "咪咕热销榜",
        "image": "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3526416775,3196812106&fm=58&bpow=512&bpoh=512",
        "id": "1",
        "description": "热销音乐",
        "source_type": "migu",
        "category_name": "分类1"
      }
    ],
    "descriptions": ["嘿,小飞,最近有什么新歌"]
  },
  ...
]

# 获取内容栏目详情

GET /media_sections/:id

# 参数

参数名 类型 必填 说明 示例
id integer 内容栏目 ID 1

# 响应

{
  "id": 2,
  "name": "热门节目",
  "items": [
    {
      "name": "抗癌:第一时间的抉择",
      "description": null,
      "image": "https://ttfm2018pub-oss-cdn.tingtingfm.com/cover/2018/0911/4d/db/4ddbe486d0dd4d14ab58430059a1474a.jpg?x-oss-process=image/resize,h_800,w_800",
      "id": "29",
      "category_name": "分类1"
    },
    ...
  ],
  "descriptions": ["嘿,小飞,最近有什么歌"]
}

# 获取内容详情

GET /media/:id

# 参数

参数名 类型 必填 说明 示例
id integer 内容 ID 12
page int 页数 1
limit int 每页数量 3

# 响应

{
  "id": 12,
  "items": [
    {
      "name": "我们(电影《后来的我们》主题曲)",
      "id": "c229e159dd60591d776ff08afbb66a83",
      "artist": "陈奕迅",
      "source_type": "migu",
      "liked": true,
      "available": true,
      "can_like": false
    },
    ...
  ],
  "from": "咪咕音乐",
  "name": "咪咕影视榜",
  "image": "http://p1.media.126.net/HJNFDYEAfvQlrQR_9q33zw==/109951163315205415.jpg"
}

# 媒体播放

# 播放内容

POST /media_player/play

# 参数

使用不同业务时,传不同的参数:

  1. 播放内容发现接口的内容
参数名 类型 必填 说明 示例
media_id integer 歌单 id, 对应/media/:id接口中的:id参数 12
audio_id string 音频 id, 对应/media/:id接口中返回的数据items.id的id字段。不设置时, 默认从歌单的第一首开始播放 fd246jxs
  1. 播放播放列表中的内容
参数名 类型 必填 说明 示例
stream object 播放列表资源 stream 信息 migu

# 响应

204 No Content

# 获取播放列表

GET /media_player/playlist

# 参数

参数名 类型 必填 说明 示例
media_type string 资源类型, 音频: audio / 视频: video audio

# 响应

{
  "list_loop": false,
  "playlist": [
    {
      "metadata": {
        "art": {
          "contentDescription": "有声的紫襟",
          "sources": [
            {
              "url": "http://imagev2.xmcdn.com/group32/M03/A2/30/wKgJnFm6gLOzBktSAAK9HRnbqms798.jpg!op_type=3&columns=180&rows=180"
            }
          ]
        },
        "source": "ximalaya",
        "subtitle": "有声的紫襟",
        "title": "【第一卷:食人晚宴】《无罪谋杀》第001章 监控拍到丧尸(1)(订阅呀!订阅呀!)"
      },
      "provider": {
        "logo": "",
        "name": "喜马拉雅"
      },
      "stream": {
        "offsetInMilliseconds": 0,
        "token": "50866476",
        "type": "AUDIO",
        "url": "http://aod.tx.xmcdn.com/group31/M09/BC/78/wKgJSVm6pPqDr2uvAEyGrBXFYYw809.m4a"
      }
    }
  ]
}

# 说明

字段 类型 说明
is_last boolean 是否最后一个音频
playlist.provider object 内容提供方的信息
playlist.stream object 云端媒体流信息
playlist.stream.type string 文件类型, 视频: VIDEO / 音频: AUDIO / 合成文本: SPEECH
playlist.stream.url string 媒体播放地址
playlist.metadata object 播放时展示在有屏设备上的数据

# 闹钟

# 闹钟列表

GET /alerts

# 响应

[
  {
    "id": "12345"
    "time": "08:00",
    "content": "起床",
    "description": "周一,周二",
    "device_id": "12345",
    "repeat_type": "WEEKLY",
    "repeat_weekdays": [1,2]
  },
  ...
]

# 说明

参数名 类型 说明 示例
id string 闹钟 id 12345
time string 闹钟时间的字符串 "08:00"
content string 闹钟的内容,没有内容时为 null "起床"
description string 闹钟的类型描述 "周一,周二"
device_id string 设备 id "12345"
repeat_type string 重复类型 重复类型: NONE(无), DAILY(每日), WORKDAY(工作日), RESTDAY(休息日), WEEKLY(每周), WEEKDAY(周一至周五), WEEKEND(周末), MONTHLY(每月), YEARLY(每年)
repeat_weekdays array WEEKLY 循环闹钟时存在 [1,2,3,4]
repeat_date_number integer MONTHLY 循环闹钟时存在 20
repeat_date string YEARLY 循环闹钟时存在 "08-01"
timestamp integer 闹钟的时间戳,只有 repeat_type 为 NONE 时存在 1533896292

# 创建闹钟

POST /alerts

# 参数 (单次闹钟)

参数名 类型 必填 说明 示例
alert_type string 闹钟类型, 单次为 single "single"
timestamp integer 时间戳(单位: 秒) 1533035393
content string 内容 "起床"

# 参数 (循环闹钟)

参数名 类型 必填 说明 示例
alert_type string 闹钟类型, 循环为 repeat "repeat"
time string 时间, 格式{hh}-{mm} "08:10"
repeat_type string 重复类型: DAILY(每日), WORKDAY(工作日), RESTDAY(休息日), WEEKLY(每周), WEEKDAY(周一至周五), WEEKEND(周末), MONTHLY(每月), YEARLY(每年) DAILY
repeat_weekdays array WEEKLY 循环闹钟需要 [1,2,3,4]
repeat_date_number integer MONTHLY 循环闹钟需要 20
repeat_date string YEARLY 循环闹钟需要 "08-01"
content string 内容 "起床"

# 响应

{}

# 编辑闹钟

PUT /alerts/:id

# 参数 (单次闹钟)

参数名 类型 必填 说明 示例
id string 闹钟 id "12345"
alert_type string 闹钟类型, 单次为 single "single"
timestamp integer 时间戳(单位: 秒) 1533035393
content string 内容 "起床"

# 参数 (循环闹钟)

参数名 类型 必填 说明 示例
id string 闹钟 id "12345"
alert_type string 闹钟类型, 循环为 repeat "repeat"
time string 时间, 格式{hh}-{mm} "08:10"
repeat_type string 重复类型: DAILY(每日), WORKDAY(工作日), RESTDAY(休息日), WEEKLY(每周), WEEKDAY(周一至周五), WEEKEND(周末), MONTHLY(每月), YEARLY(每年) DAILY
repeat_weekdays array WEEKLY 循环闹钟需要 [1,2,3,4]
repeat_date_number integer MONTHLY 循环闹钟需要 20
repeat_date string YEARLY 循环闹钟需要 "08-01"
content string 内容 "起床"

# 响应

{}

# 删除闹钟

DELETE /alerts/:id

# 参数

参数名 类型 必填 说明 示例
id string 闹钟 id "12345"

# 响应

{}

# 设备更新接口文档

# 设备检查更新接口

# 请求接口

GET https://ota.iflyos.cn/ota/client/check/packages

# 请求headers

Accpet:       application/json
Content-Type: application/json
X-Client-ID:  {{clientId}}
X-Device-ID:  {{deviceId}}
X-Version-ID: {{versionId}}
X-Timestamp:  1566550716
X-Nonce:      d47230b62805a0bc1cf7e5731b61112c
X-Signature:  SH1(X-Client-ID+":"+X-Device-ID+":"+X-Timestamp+":"+X-Nonce+":"+secretKey)

headers说明

请求headers(除X-Version-ID之外)必须带上签名参数,签名通过字符串拼接X-Client-ID+":"+X-Device-ID+":"+X-Timestamp+":"+X-Nonce+":"+secretKey再计算SH1**(小写)**

  • X-Client-ID: 设备clientId

  • X-Device-ID: 设备ID

  • X-Version-ID: 设备版本ID

  • X-Timestamp: 发起请求的时间戳,单位: 秒

  • X-Nonce: 32位随机字符串

  • X-Signature: SH1(X-Client-ID + ":" + X-Device-ID + ":" +X-Timestamp+":" + X-Nonce+":" + SecretKey)

注:SecretKeyiFLYOS企业平台 - 设备接入 - 自动更新的加密密钥

# 响应

[
    {
        "id": 42,
        "identity": "master",
        "version_id": 5,
        "version_name": "xxx",
        "description": "xxxxxxxx",
        "url": "https://cdn.iflyos.cn/public/ota_packages/xxx.zip"
    }
]

参数说明

参数名 类型 说明
id integer 更新包ID
identity string 更新包标示
version_id integer 更新包版本ID
version_name string 更新包版本名
description string 更新包描述
url string 更新包链接

# 设备模式

控制儿童模式,持续交互模式的开关

PUT /device

# 参数

参数名 类型 必填 说明
alias string 设备别名,body 参数
children_mode boolean 是否开启儿童模式,body 参数
continous_mode boolean 是否开启持续交互,body 参数

# 响应

{
	"message": "更新成功"
}

# 设备配置

# 恢复出厂

POST /device/restore_factory

响应

Status: 200 OK

{
	"message": "推送成功"
}

# 自定义设备唤醒词

说明

该接口需要开通权限,若需使用,请联系商务。

# 评估唤醒词

POST /wakewords/check

请求参数

参数名 类型 必填 说明
wakeword string 唤醒词文本

响应示例

POST /wakewords/check

{
	"score": 5,
	"valid": true
}
名称 类型 说明
score integer 评分
valid boolean 能否添加

# 设备唤醒词列表

GET /wakewords

响应示例

GET /wakewords

{
	"wakewords": [
		{
			"id": 1,
			"name": "嘿,小飞",
			"score": 5,
			"default": true,
			"enable": true,
			"status": "success"
		}
	]
}
名称 类型 说明
id integer 唤醒词id
name string 唤醒词文本
score integer 评分
default boolean 是否默认
enable boolean 是否使用中
status string 状态:
success(可以使用)
pending(制作中)
fail(制作失败)

# 更换设备唤醒词

PUT /wakeword

请求参数

参数名 类型 必填 说明
wakeword_id string body参数,唤醒词id

响应示例

PUT /wakeword

{
	"message": "设置成功"
}

# 添加并设置唤醒词

POST /wakewords

请求参数

参数名 类型 必填 说明
wakeword string 唤醒词文本

响应示例

POST /wakeword

{
	"message": "添加成功"
}

# 聊天设置

说明

该接口需要开通权限,若需使用,请联系商务。

# 获取设备聊天设置

GET /chat_config

响应示例

GET /devices/xxx.xxxx/interaction_modes

{
  "interaction_modes": [
    {
      "speakers": [
        {
          "voice_name": "飞飞",
          "voice_id": "x_feidie",
          "vcn": "x_feidie",
          "source_type": "default",
          "property_ids": ["adult"],
          "image": "https://cdn.iflyos.cn/public/speakers/image_x_feidie.png",
          "listen_url": "https://cdn.iflyos.cn/public/speakers/x_feidie.wav"
        },
        {
          "voice_name": "百合仙子",
          "voice_id": "x_yiping",
          "vcn": "x_yiping",
          "source_type": "default",
          "property_ids": [],
          "image": "https://cdn.iflyos.cn/public/speakers/image_x_feidie.png",
          "listen_url": "https://cdn.iflyos.cn/public/speakers/x_yiping.wav"
        }
      ],
      "name": "普通话交互",
      "interaction_mode_id": 5
    },
    {
      "speakers": [],
      "name": "粤语",
      "interaction_mode_id": 8
    },
    {
      "speakers": [],
      "name": "英语",
      "interaction_mode_id": 9
    }
  ],
  "property": [
    {
      "name": "成人",
      "property_id": "adult",
      "enable": true
    }
  ],
  "config": {
    "volume": 5,
    "vcn": "x_xiaoyuan",
    "speed": 1.08,
    "language": "cantonese",
    "interaction_mode_id": 8,
    "ent": "xtts"
  }
}
名称 类型 说明
interaction_modes array 交互模式列表
interaction_modes.name string 交互模式名称
interaction_modes.interaction_mode_id int 交互模式id
interaction_modes.speakers array 交互模式的发音人列表
interaction_modes.speakers.voice_name string 发音人名称
interaction_modes.speakers.voice_id string 发音人id
interaction_modes.speakers.vcn string 发音人标识
interaction_modes.speakers.listen_url string 发音人试听url
interaction_modes.speakers.property_ids string 人设id列表
property.name string 人设名称
property.property_ids array 人设id
property.enable boolean 能否设置
config object 设备当前聊天配置
config.vcn string 设备当前发音人id
config.volume int 音量
config.speed float 语速
config.interaction_mode_id int 设备当前交互模式id
config.property_id string 设备当前人设id

# 更新设备聊天设置

PUT /chat_config

请求参数

参数名 类型 必填 说明
interaction_mode_id int 交互模式id
property_id string 人设id
vcn string 发音人标识