REST API文档
高级配置-扩展功能
话机自动配置
查看话机信息
- 请求 URL:
/api/device_provisions
- 请求方式:
GET
- Body 信息:无
- 返回值:
{ "data": [ { "vendor": "huawei", "deleted_at": "", "mac": "", "created_at": "2022-05-17 15:06:04", "id": 1, "extn": "1007@demo.xswitch.cn", "name": "kf1", "updated_at": "2022-05-17 15:06:04", "type": "" } ], "rowCount": 1, "pageCount": 1, "page": 1 }
示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/device_provisions
新建话机配置
- 请求 URL:
/api/device_provisions
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见分配器信息说明。
Body:
{ "name": "我在测试", "vendor": "gs", "mac": "000B7461582D", "extn": "[{\"extn\":\"1001\"}]" //绑定的分机号 }
返回:
{ "data": "1", "code": 200, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"extn": "[{\"extn\":\"1007|demo.xswitch.cn\"}]","name": "kf1","vendor": "huawei","mac":"000B7461582D"}' \ -H "Content-Type: application/json" http://192.168.1.100:8081/api/device_provisions
批量创建话机配置
- 请求 URL:
/api/device_provisions/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见分配器信息说明。
Body:
{ "devices": [ { "名称": "我在测试", "分机号": "1002", "供应商": "潮流", "MAC": "000B7461582D" }, { "名称": "admin", "分机号": "1000", "供应商": "gs", "MAC": "000b82d74615" }, { "名称": "我在测试", "分机号": "1001", "供应商": "gs", "MAC": "000B7461582D" } ] }
返回:
{ "message": "success", "code": 200, "data": [ { "updated_at": "2022-11-16 14:08:47", "created_at": "2022-11-16 14:08:47", "extn": "1002", "vendor": "潮流", "mac": "000B7461582D", "id": 43, "deleted_at": "", "name": "我在测试", "type": "" }, { "updated_at": "2022-11-16 14:08:47", "created_at": "2022-11-16 14:08:47", "extn": "1000", "vendor": "gs", "mac": "000b82d74615", "id": 44, "deleted_at": "", "name": "admin", "type": "" }, { "updated_at": "2022-11-16 14:08:47", "created_at": "2022-11-16 14:08:47", "extn": "1001", "vendor": "gs", "mac": "000B7461582D", "id": 45, "deleted_at": "", "name": "我在测试", "type": "" } ] }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"data":[{"extn": "1031","mac": "00a859f6c74i","vendor": "xyt", "name": "lili"},{"extn": "1032","mac": "0a859f6c74o","vendor": "xyt", "name": "zhangsan"},{"extn": "1031","mac": "00a859f6c74p","vendor": "xyt", "name": "lisi"}]}' \ -H "Content-Type: application/json" http://192.168.1.100:8081/api/device_provisions
修改话机配置信息
- 请求 URL:
/api/device_provisions/:id
- 请求方式:
PUT
- Body 信息:
{ "extn": "1006", "id": 1 }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"extn": "1006", "id": 1}' \ 192.168.1.100:8081/api/device_provisions/1
- 返回值:
{ "message": "success", "code": 200, "data": "1" }
删除话机配置
- 请求 URL:
/api/device_provisions/:id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/device_provisions/1
返回:
{ "data": "1", "code": 200, "message": "success" }
媒体文件
媒体文件用于管理音视频文件、录音系统,也支持 TTS 和传真类型的文件管理。
媒体文件属性:
- channel_uuid:通话 UUID,可以为空
- type:媒体文件类型,参见下表
- name:文件名,可以为中文
- description:描述信息
- ext:扩展名
- mime:文件 MIME 类型
- file_size:文件大小,字节数
- abs_path:绝对路径
- dir_path:目录名
- rel_path:相对路径
- created_at:创建时间
- updated_at:更新时间
媒体文件类型:
- SYSTEM:系统内置
- UPLOAD:用户上传
- RECORD:系统录音文件
- SCRIPT:上传的脚本
- DATABASE:备份的数据库
- ASR:ASR 识别的文本文件
- VOICEMAIL: 语音留言的文件
- TTS:TTS生成的语音文件
- PDF:PDF 文件
- FAX:传真文件
查看所有媒体文件
- 请求 URL:
/api/media_files
- 请求方式:
GET
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/media_files
筛选:
- 请求 URL:
/api/media_files?uuid=$uuid
:返回指定通话 UUID 相关的媒体文件信息 - 请求 URL:
/api/media_files?type=UPLOAD
:返回全部上传的媒体文件信息 - 请求 URL:
/api/media_files?types=UPLOAD,TTS,SYSTEM
:返回全部上传文件、TTS 生成的以及系统内置的媒体文件信息
返回结果示例:
{ "rowCount": 5, "pageCount": 1, "data": [ { "abs_path": "/usr/local/freeswitch/storage/recordings/conference-record-713556038-demo.xswitch.cn-2022-05-17-01-30-09-6242c44b-c2f2-4882-8941-784d44ba9885.wav", "description": "713556038-demo.xswitch.cn", "id": 5, "bit_rate": 0, "user_id": 0, "thumb_path": "", "deleted_at": "", "file_name": "", "created_at": "2022-05-17 11:21:51", "original_file_name": "conference-record-713556038-demo.xswitch.cn-2022-05-17-01-30-09-6242c44b-c2f2-4882-8941-784d44ba9885.wav", "geo_position": "", "sample_rate": 0, "channel_uuid": "68b2dd28-cf52-4246-9002-7c1b8eeba5d0", "file_size": 321444, "processing_flag": 0, "channels": 0, "duration": 0, "meta": "", "updated_at": "2022-05-17 11:21:51", "rel_path": "conference-record-713556038-demo.xswitch.cn-2022-05-17-01-30-09-6242c44b-c2f2-4882-8941-784d44ba9885.wav", "ext": "wav", "type": "CONFERENCE", "mime": "audio/wave", "name": "713556038-demo.xswitch.cn", "dir_path": "" } ... ], "page": 1 }
请求单个媒体文件信息
- 请求 URL:
/api/media_files/$id
返回指定 ID 的媒体文件信息 - 请求方式:
GET
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/media_files/1
下载媒体文件
- 请求 URL:
/api/media_files/$id.$ext
返回指定 ID 的媒体文件内容 - 请求方式:
GET
- 返回值: code(200 即为正常),msg
- curl 示例:
其中:
$id
为媒体文件 ID$ext
为媒体文件扩展名
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/media_files/1.wav
对于媒体 MIME 类型为x-xui/phrase
类型的文件,支持.wav
和.mp3
两种方式下载。
媒体文件上传
支持form
方式的媒体文件上传,如:
curl -H "X-XTRA-AUTH-ID: e19c87cc-265e-4774-8f28-eca172f37b75" -F 'file=@./x.png' https://demo.xswitch.cn/api/upload [ { "abs_path": "/usr/local/freeswitch/storage/upload/upload-20200319162632-5b35d276-62cc-446b-8ff5-8e903c11d7c1.png", "bit_rate": "", "channel_uuid": "", "channels": "", "created_at": "2020-03-19 16:26:32", "deleted_at": "", "description": "UPLOAD", "dir_path": "/usr/local/freeswitch/storage/upload", "duration": "", "ext": "png", "file_name": "", "file_size": "24393", "geo_position": "", "id": "2", "meta": "", "mime": "image/png", "name": "x.png", "original_file_name": "x.png", "processing_flag": "0", "rel_path": "upload-20200319162632-5b35d276-62cc-446b-8ff5-8e903c11d7c1.png", "sample_rate": "", "thumb_path": "", "type": "UPLOAD", "updated_at": "2020-03-19 16:26:32", "user_id": "" } ]
修改指定媒体文件
- 请求 URL:
/api/media_files/:id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{"id": 1, name": "test", "description": "test"}
- 返回值:
状态 返回值
成功 JSON 信息 失败 500
- 示例:
Body:
{ "description": "UPLOAD", "id": "2", "name": "test.bat", "type": "UPLOAD" }
返回:
{ "message": "success", "data": "2", "code": 200 }
TTS生成语音文件
- 请求 URL:
/api/baidu/tts
支持百度TTS语音生成 - 请求 URL:
/api/ali/tts
支持阿里TTS语音生成 - 请求 URL:
/api/huawei/tts
支持华为TTS语音生成 - 请求方式:
POST
- 返回值: code(200 即为正常),msg
- 参数: 如下说明
参数 | 说明 |
---|---|
engine | baidu |
input | 你好,欢迎致电烟台小樱桃网络科技有限公司 |
- 新增数据body(示例):
{ "engine": "ali", "input": "你好,欢迎致电烟台小樱桃网络科技有限公司" }
- 返回(示例):
{ "description": "你好,欢迎致电烟台小樱桃网络科技有限公司", "channel_uuid": "94994d55-13bb-42be-a896-cecb10c6750e", "updated_at": "2024-07-15 17:44:38", "file_size": 3024, "created_at": "2024-07-15 17:44:38", "dir_path": "/usr/local/freeswitch/storage/upload", "original_file_name": "", "deleted_at": "", "processing_flag": 0, "thumb_path": "", "geo_position": "", "file_name": "", "mime": "audio/mp3", "id": 6162, "abs_path": "/usr/local/freeswitch/storage/upload/ali-tts-20240715174437-e6079965-a3ad-4fb3-8cfc-eaade0c0de4a.mp3", "ext": "", "rel_path": "ali-tts-20240715174437-e6079965-a3ad-4fb3-8cfc-eaade0c0de4a.mp3", "name": "你好,欢迎致电烟台小樱桃网络科技有限公司", "type": "TTS", "meta": "" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" \ -d '{"engine": "ali","input": "你好,欢迎致电烟台小樱桃网络科技有限公司"}' \ -H "Content-Type: application/json" 192.168.0.103:8081/api/ali/tts
删除指定媒体文件
- 请求 URL:
/api/media_files/:id
- 请求方式:
DELETE
- 返回值: code(200 即为正常)
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/media_files/2
- 返回(示例):
{ "data": "2", "code": 200, "message": "success" }
传感器管理
维护传感器相关数据
请求参数说明:
参数 | 说明 |
---|---|
page | 查询哪页数据 |
perPage | 每页查询条数 |
name | 需要查询的传感器名称 |
返回参数说明:
参数 | 说明 |
---|---|
page | 当前页 |
pageCount | 总页数 |
rowCount | 返回总数 |
获取传感器列表
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms?perPage=500&page=1
请求方式:
GET
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "pageCount": 1, "rowCount": 3, "page": 1, "data": [ { "call_duration": "100", "id": "3", "name": "传感器测试1001", "data": "{\"media_id\":\"209\",\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240327142532-018e7e95-d44f-7afc-930d-f0ce83ca9d2d.wav\",\"media_type\":\"UPLOAD\"}", "created_at": "2024-05-30 05:59:35", "action": "playback", "caller_number": "1001", "extn_id": "3", "deleted_at": "", "description": "传感器测试1001", "updated_at": "2024-05-30 05:59:35" }, { "call_duration": "100", "id": "2", "name": "传感器测试", "data": "{\"media_id\":\"207\",\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240327105825-018e7dd8-352a-756b-91ba-942a8550a2bc.mp3\",\"media_type\":\"UPLOAD\"}", "created_at": "2024-05-30 05:56:27", "action": "playback", "caller_number": "1000", "extn_id": "2", "deleted_at": "", "description": "传感器测试", "updated_at": "2024-05-30 05:56:27" }, { "call_duration": "1214", "id": "1", "name": "154564", "data": "{\"media_id\":\"203\",\"media_path\":\"$${sound_prefix}/ivr/8000/ivr-not_have_permission.wav\",\"media_type\":\"SYSTEM\"}", "created_at": "2024-05-16 02:43:52", "action": "playback", "caller_number": "12412", "extn_id": "3", "deleted_at": "", "description": "", "updated_at": "2024-05-16 02:43:52" } ] }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" "192.168.0.103:8081/api/extn_alarms?perPage=500&page=1"
根据名称检索传感器信息
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms?perPage=500&page=1&name=154564
请求方式:
GET
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "page": 1, "pageCount": 1, "rowCount": 1, "data": [ { "description": "", "caller_number": "12412", "name": "154564", "call_duration": "1214", "id": "1", "deleted_at": "", "created_at": "2024-05-16 02:43:52", "updated_at": "2024-05-16 02:43:52", "data": "{\"media_id\":\"203\",\"media_path\":\"$${sound_prefix}/ivr/8000/ivr-not_have_permission.wav\",\"media_type\":\"SYSTEM\"}", "extn_id": "3", "action": "playback" } ] }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" "192.168.0.103:8081/api/extn_alarms?perPage=500&page=1&name=154564"
新增传感器
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms
请求方式:
POST
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
新增数据body(示例):
{ "name": "新增传感器数据", "caller_number": "1000", "call_duration": "100", "extn_id": 2, "description": "测试新增传感器数据接口", "action": "playback", "data": 209 }
- 返回系统操作日志(示例):
{ "data": 4, "message": "success", "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" \ -d '{"name": "新增传感器数据001","caller_number": "1000","call_duration": "100","extn_id": 2,"description": "测试新增传感器数据接口","action": "playback","data": 209}' \ -H "Content-Type: application/json" 192.168.0.103:8081/api/extn_alarms
删除传感器
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/id
请求方式:
DELETE
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "code": 200, "data": "{}", "message": "success" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" -XDELETE http://192.168.0.103:8081/api/extn_alarms/3
传感器详情
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/id
请求方式:
GET
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "deleted_at": "", "name": "154564", "id": 1, "updated_at": "2024-05-16 02:43:52", "description": "", "call_duration": "1214", "data": { "media_path": "$${sound_prefix}/ivr/8000/ivr-not_have_permission.wav", "media_id": "203", "media_type": "SYSTEM" }, "caller_number": "12412", "created_at": "2024-05-16 02:43:52", "extn_id": "3", "action": "playback" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" -XGET 192.168.0.103:8081/api/extn_alarms/1
获取传感器下设备信息列表
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/id/alarms?page=1&perPage=500
请求方式:
GET
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "pageCount": 1, "rowCount": 2, "data": [ { "created_at": "2024-05-31 01:51:10", "device_name": "传感器设备002", "extn_alarms_id": "1", "event_name": "", "event_time": "", "deleted_at": "", "call_uuid": "", "device_id": "002", "id": "4", "updated_at": "2024-05-31 01:51:10", "status": "init" }, { "created_at": "2024-05-31 01:51:10", "device_name": "传感器设备001", "extn_alarms_id": "1", "event_name": "", "event_time": "", "deleted_at": "", "call_uuid": "", "device_id": "001", "id": "3", "updated_at": "2024-05-31 01:51:10", "status": "init" } ], "page": 1 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" -XGET "192.168.0.103:8081/api/extn_alarms/1/alarms?page=1&perPage=500"
修改传感器信息
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/id
请求方式:
PUT
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
修改数据body(示例):
{ "name": "修改名字", "caller_number": "12412", "call_duration": "1214", "extn_id": 3, "action": "playback" }
- 返回系统操作日志(示例):
{ "message": "success", "code": 200, "data": "1" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" \ -d '{"name": "修改名字001","caller_number": "12412","call_duration": "1214","extn_id": 3,"action": "playback"}' \ -H "Content-Type: application/json" 192.168.0.103:8081/api/extn_alarms/1
批量导入设备管理表
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/id/import
请求方式:
POST
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
批量增加数据body(示例):
{ "data": [ { "device_id": "003", "device_name": "传感器设备003" }, { "device_id": "004", "device_name": "传感器设备004" }, { "device_id": "005", "device_name": "传感器设备005" }, { "device_id": "006", "device_name": "传感器设备006" }, { "device_id": "007", "device_name": "传感器设备007" }, { "device_id": "008", "device_name": "传感器设备008" } ] }
- 返回系统操作日志(示例):
{ "data": "{}", "code": 200, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" \ -d '{"data": [{"device_id": "010","device_name": "传感器设备010"},{"device_id": "011","device_name": "传感器设备011"}]}' \ -H "Content-Type: application/json" 192.168.0.103:8081/api/extn_alarms/1/import
删除设备
请求 URL:
/api/extn_alarms
请求 URL:
/api/extn_alarms/alarm/id(设备ID)
请求方式:
DELETE
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "data": "{}", "code": 200, "message": "success" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" -XDELETE http://192.168.0.103:8081/api/extn_alarms/alarm/4
日志
操作日志查询支持按时间、操作员、资源、动作等精确查询。
请求参数说明:
参数 | 说明 |
---|---|
page | 查询哪页数据 |
perPage | 每页查询条数 |
operator | 按操作员查询 |
resource | 按资源查询 |
action | 按动作查询 |
startDate | 按起始时间查询 |
返回参数说明:
参数 | 说明 |
---|---|
page | 当前页 |
pageCount | 总页数 |
rowCount | 返回总数 |
resource | 资源 |
user_id | 操作用户 ID |
source_ip | 来源 IP |
message | 操作信息 |
user_name | 操作用户名称 |
action | 操作动作 |
summary | 摘要 |
获取系统操作日志
请求 URL:
/api/logs
请求 URL:
/api/logs?page=1&perPage=500&operator=Admin
请求方式:
GET
返回值: code(200 即为正常),msg
参数: 参考上述参数说明
返回系统操作日志(示例):
{ "page": 1, "pageCount": 4, "rowCount": 637, "data": [ { "id": "11", "resource": "XUI", "source_ip": "192.168.65.1", "user_id": "0", "message": "{\"DEVER\": \"1.11.44\"}", "summary": "1.11.44", "action": "UPDATE", "user_name": "SYSTEM", "created_at": "2020-08-03 11:25:18" }, { "id": "10", "resource": "XUI", "source_ip": "192.168.65.1", "user_id": "0", "message": "{\"DEVER\": \"1.11.43\"}", "summary": "1.11.43", "action": "UPDATE", "user_name": "SYSTEM", "created_at": "2020-08-03 11:25:17" } ... ] }
脚本检查
获取 xlonglive 脚本运行情况
- 请求 URL:
/api/check/:name
- 请求方式:
GET
- 返回值: code(0 为正在运行,200 为没有运行)
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XGET 192.168.1.100:8081/api/check/clean-file
- 返回(示例):
{ "msg": "Already Running", "code": 0 }
- 脚本名称与 name 对照表
脚本名称 | name | 描述 |
---|---|---|
clean_file.lua | clean-file | 定时清理文件 |
conference_manager_cdr.lua | conference-manager-cdr | 会议话单管理 |
conference_manager.lua | conference-manager | 会议管理 |
heartbeat.lua | heartbeat | 心跳 |
sip_trace.lua | sip-trace | SIP 跟踪 |