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_flag1?
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": ""
}
高级配置-模块配置