REST API文档
计费管理
费率
费率信息说明如下:
参数 | 说明 |
---|---|
type | 计费类型或名称 |
description | 描述 |
unit | 金额单位 默认RMB |
rate | 费率 |
bill_interval | 跳表间隔,默认60秒 |
获取费率
请求 URL:
/api/bill_rates
返回所有费率信息请求 URL:
/api/bill_rates/$id
返回指定 ID 的费率信息请求方式:
GET
返回值: 费率 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/bill_rates
- 返回值:
{ "data": [ { "rate": "0.8", "id": "1", "unit": "RMB", "description": "", "bill_interval": "60", "type": "本地呼叫" } ], "pageCount": 1, "rowCount": 1, "page": 1 }
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/bill_rates/14
创建费率
- 请求 URL:
/api/bill_rates
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见费率信息说明。
- 返回值: 创建费率的 id
Body:
{ "type": "local", "description": "test", "unit": "RMB", "rate": "0.1" }
返回:
{ "code": 200, "message": "success", "data": 1 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"type": "local","description": "test","unit": "RMB","rate": "0.1"}' \ -H "Content-Type: application/json" http://192.168.1.100:8081/api/bill_rates
修改费率
- 请求 URL:
/api/bill_rates/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{ "type": "local", "description": "test", "rate": "0.1" }
- 返回值:
{ "code": 200, "data": "1", "message": "success" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"type": "local","description": "test","rate": "0.1" }' \ http://192.168.1.100:8081/api/bill_rates/1
删除费率
- 请求 URL:
/api/bill_rates/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
{ "message": "success", "code": 200, "data": "1" }
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/bill_rates/1
计费账户信息
计费账户信息说明如下:
参数 | 说明 |
---|---|
account | 账户 |
password | 密码 |
description | 描述 |
amount | 余额 |
last_recharge_amount | 上次预存金额 |
获取计费账户信息
请求 URL:
/api/bill_accounts
返回所有计费账户信息请求 URL:
/api/bill_accounts/$id
返回指定 ID 的计费账户信息请求方式:
GET
返回值: 计费账户 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/bill_accounts
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/bill_accounts/1
- 返回值:
{ "page": 1, "rowCount": 1, "data": [ { "description": "", "deleted_at": "", "account": "小明", "last_recharge_amount": 0, "amount": 200, "updated_at": "2023-03-25 06:53:13", "password": "$VeryGoodPassw0rd", "id": 1, "created_at": "2023-03-25 06:53:13" } ], "pageCount": 1 }
创建计费账户信息
- 请求 URL:
/api/bill_accounts
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见计费账户信息说明。
- 返回值: 创建计费账户信息的 id
Body:
{ "account": "1001", "password": "$VeryGoodPassw0rd", "description": "1001", "amount": "200" }
返回:
{ "data": 1, "message": "success", "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"account": "1001","password": "$VeryGoodPassw0rd","description": "1001","amount": "200"}' \ -H "Content-Type: application/json" http://192.168.1.100:8081/api/bill_accounts
删除计费账户信息
- 请求 URL:
/api/bill_accounts/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/bill_accounts/1
返回:
{ "data": "1", "message": "success", "code": 200 }
对指定 ID 的计费账户进行充值
- 请求 URL:
/api/bill_accounts/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见计费账户信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | 空 JSON {} |
失败 | -ERR Cannot execute script |
- 示例:
Body:
{ "account": "小明", "last_recharge_amount": "100" }
返回:
{ "message": "success", "data": "2", "code": 200 }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"account": "小明","last_recharge_amount": "100" }' \ http://192.168.1.100:8081/api/bill_accounts/2
计费账单
返回数据信息
返回参数 | 说明 |
---|---|
amount | 开始时间 |
audio_codec | 音频编码 |
audio_in_bytes | 接收音频字节数 |
audio_out_bytes | 发送音频收字节数 |
bill_interval | 计费间隔 |
bill_rate | 费率 |
bill_target | 计费目标 |
bill_type | 计费类型 |
billsec | 计费时长 |
cid_number | 计费时长最大时长 |
cost | 主叫号码 |
dest_number | 主叫号码 |
direction | 方向 |
domain | 域名 |
duration | 总时长 |
ended_at | 结束时间 |
network_addr | 网络地址 |
other_uuid | |
process_flag | 1? |
resource_cost | 金额 |
started_at | 开始时间 |
ticks | 计次 |
username | 用户名 |
video_codec | 视频编码 |
video_height | 视频分辨率(高) |
video_in_bytes | 接收视频字节数 |
video_out_bytes | 发送视频字节数 |
video_width | 视频分辨率(宽) |
查询参数信息说明
查询参数 | 说明 |
---|---|
startDate | 开始时间 |
endDate | 结束时间 |
uuid | 通话UUID |
startBillsec | 计费时长最小时长 |
endBillsec | 计费时长最大时长 |
cidNumber | 主叫号码 |
destNumber | 被叫号码 |
获取计费账单信息
- 请求 URL:
/api/bills/data
查询所有计费账单信息 - 请求 URL:
/api/bills/data?startDate=2024-07-11&endDate=2024-07-18&startBillsec=&endBillsec=&cidNumber=&uuid=0190beca-eced-77a0-801c-c4219c555b03&destNumber=
按条件查询指定计费账单信息 - 请求 URL:
/api/bills/0190beca-eced-77a0-801c-c4219c555b03
查询指定某个UUID的计费账单信息 - 请求方式:
GET
- 返回值: 计费账单 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
返回:
{ "page": 1, "rowCount": 7, "data": [ { "amount": 0, "ticks": 1, "video_in_bytes": 0, "started_at": "2023-03-25 14:37:23", "cid_number": "system", "audio_codec": "PCMA", "audio_out_bytes": 0, "duration": 4, "uuid": "afbdc049-e5bd-44ea-b1c5-3f897e27230d", "bill_rate": 0, "audio_in_bytes": 0, "other_uuid": "", "username": "", "direction": 1, "bill_target": "", "dest_number": "6000", "billsec": 2, "process_flag": 1, "network_addr": "172.18.0.1", "ended_at": "2023-03-25 14:37:25", "bill_type": "", "video_width": 0, "video_height": 0, "video_out_bytes": 0, "video_codec": "", "domain": "xswitch.cn" }, ... { "amount": 0, "ticks": 1, "video_in_bytes": 0, "started_at": "2023-03-23 14:49:22", "cid_number": "phrase", "audio_codec": "", "audio_out_bytes": 0, "duration": 0, "uuid": "d073e712-9492-4d53-b2c8-5f7a7f2e87ff", "bill_rate": 0, "audio_in_bytes": 0, "other_uuid": "", "username": "", "direction": 1, "bill_target": "", "dest_number": "welcome_short@xui", "billsec": 0, "process_flag": 1, "network_addr": "", "ended_at": "2023-03-23 14:49:22", "bill_type": "", "video_width": 0, "video_height": 0, "video_out_bytes": 0, "video_codec": "", "domain": "xswitch.cn" } ], "pageCount": 1 }
获取计费账单周报和月报信息
- 请求 URL:
/api/bills/usage
- 请求方式:
GET
- 返回值: 通话信息详情 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
{ "weekly_usage": [ { "amount": "0.0000", "total": 0.21666666666666667, "title": "2023-03-25" }, { "amount": "0.0000", "total": 0.31666666666666665, "title": "2023-03-24" }, { "amount": "0.0000", "total": 0, "title": "2023-03-23" }, { "amount": "0.00", "total": 0, "title": "2023-03-22" }, { "amount": "0.00", "total": 0, "title": "2023-03-21" }, { "amount": "0.00", "total": 0, "title": "2023-03-20" }, { "amount": "0.00", "total": 0, "title": "2023-03-19" } ], "monthly_usage_data": [ { "month": 1, "amount": "0.00", "minutes": 0 }, { "month": 2, "amount": "0.00", "minutes": 0 }, { "month": 3, "amount": "0.0000", "minutes": 6 }, { "month": 4, "amount": "0.00", "minutes": 0 }, { "month": 5, "amount": "0.00", "minutes": 0 }, { "month": 6, "amount": "0.00", "minutes": 0 }, { "month": 7, "amount": "0.00", "minutes": 0 }, { "month": 8, "amount": "0.00", "minutes": 0 }, { "month": 9, "amount": "0.00", "minutes": 0 }, { "month": 10, "amount": "0.00", "minutes": 0 }, { "month": 11, "amount": "0.00", "minutes": 0 }, { "month": 12, "amount": "0.00", "minutes": 0 } ] }
根据指定通话 UUID 获取该条通话的详细信息
- 请求 URL:
/api/bills/$uuid
指定通话 UUID 获取该条通话的详细信息 - 请求方式:
GET
- 返回值: 通话信息详情 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
返回:
{ "username": "", "domain": "xswitch.cn", "direction": 1, "bill_type": "", "amount": 0, "bill_rate": 0, "ended_at": "2023-03-23 14:49:22", "dest_number": "welcome_short@xui", "audio_codec": "", "uuid": "d073e712-9492-4d53-b2c8-5f7a7f2e87ff", "audio_in_bytes": 0, "ticks": 1, "network_addr": "", "other_uuid": "", "started_at": "2023-03-23 14:49:22", "cid_number": "phrase", "process_flag": 1, "duration": 0, "video_in_bytes": 0, "video_width": 0, "video_height": 0, "video_out_bytes": 0, "audio_out_bytes": 0, "billsec": 0, "video_codec": "", "bill_target": "" }