
# 月用量统计 - ShowMonthUsages
#### 功能介绍
设备月用量统计
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/GSL/doc?api=ShowMonthUsages)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-ocgsl/gsl_07_0026.html)。
#### URI
POST /v1/sim-cards/month-usages
#### 请求参数
表1请求Body参数 
| 参数             | 是否必选 | 参数类型             | 描述                                                                                                                       |
|:---|:---|:---|:---|
| sim_card_ids   | 否    | Array of longs   | sim卡id列表，最多支持传入500个SIM卡id。sim_card_ids与iccids不能同时为空，sim_card_ids参数为空则根据iccids参数处理 最小值：**0** 数组长度：**0 - 500**             |
| iccids         | 否    | Array of strings | iccid列表，最多支持传入500个iccid。sim_card_ids与iccids不能同时为空，sim_card_ids参数为空则根据iccids参数处理 最小长度：**19** 最大长度：**20** 数组长度：**0 - 500** |
| billing_cycles | 是    | Array of strings | 账期，最多支持传入本月在内的6个月账期，例如\[2022-07, 2022-06\]，不支持传入未来账期。 最小长度：**0** 最大长度：**7** 数组长度：**0 - 6**                               |
   
#### 响应参数
**状态码：200**
表2响应Body参数 
| 参数           | 参数类型                                                                                                               | 描述    |
|:---|:---|:---|
| month_usages | Array of [MonthUsageVo] objects | 月用量列表 |
   
 表3MonthUsageVo 
| 参数          | 参数类型                                                                                                             | 描述               |
|:---|:---|:---|
| sim_card_id | Long                                                                                                             | SIM卡ID 最小值：**0** |
| iccid       | String                                                                                                           | iccid 最小长度：**0** |
| flow_usages | Array of [FlowUsageVo] objects | 月用量              |
   
 表4FlowUsageVo 
| 参数            | 参数类型   | 描述       |
|:---|:---|:---|
| billing_cycle | String | 账期       |
| flow_used     | Double | 已用流量（MB） |
   
**状态码：400**
表5响应Body参数 
| 参数         | 参数类型   | 描述   |
|:---|:---|:---|
| error_code | String | 错误码  |
| error_msg  | String | 错误描述 |
   
**状态码：500**
表6响应Body参数 
| 参数         | 参数类型   | 描述   |
|:---|:---|:---|
| error_code | String | 错误码  |
| error_msg  | String | 错误描述 |
   
#### 请求示例
- 查询SIM卡的历史月用量，卡ID为"4710226018477568"，账期为"2022-07"。
  ```
  POST https://{endpoint}/v1/sim-cards/month-usages
  {
    "sim_card_ids" : [ 4710226018477568 ],
    "billing_cycles" : [ "2022-07" ]
  }
  ```
- 查询SIM卡的历史月用量。当参数sim_card_ids不传或长度为0时，根据iccids，查询卡标识为"8695xxxxxxxx"的历史月用量，账期为"2022-07"。
  ```
  POST https://{endpoint}/v1/sim-cards/month-usages
  {
    "iccids" : [ "8695xxxxxxxx" ],
    "billing_cycles" : [ "2022-07" ]
  }
  ```
#### 响应示例
**状态码：200**
OK
```
{
  "month_usages" : [ {
    "sim_card_id" : 4710226018477568,
    "iccid" : "8695xxxxxxxx",
    "flow_usages" : [ {
      "billing_cycle" : "202207",
      "flow_used" : 85.27
    } ]
  } ]
}
```
**状态码：400**
Parameter Invalid
```
{
  "error_code" : "GSL.00010004",
  "error_msg" : "参数异常"
}
```
**状态码：500**
Internal Server Error
```
{
  "error_code" : "GSL.00010003",
  "error_msg" : "系统繁忙，请稍后重试。"
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK                    |
| 400 | Parameter Invalid     |
| 500 | Internal Server Error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-ocgsl/ErrorCode.html)。
