openApi管理 /查询API调用额度

# 查询 API 调用额度

> 接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。

## 接口说明

### 接口英文名

getApiQuota

### 功能描述

本接口用于查询公众号/小程序/第三方平台等接口的每日调用接口的额度以及调用次数。

### 注意事项

1、如果查询的 api 属于公众号的接口,则需要用[公众号的access_token](https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html);如果查询的 api 属于小程序的接口,则需要用[小程序的access_token](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html);如果查询的接口属于第三方平台的接口,则需要用[第三方平台的component_access_token](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/component_access_token.html)

2、如果是第三方服务商代公众号或者小程序查询公众号或者小程序的api,则需要用[authorizer_access_token](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html)

3、每个接口都有调用次数限制,请开发者合理调用接口

4、”/xxx/sns/xxx“这类接口不支持使用该接口,会出现76022报错。

## 调用方式

### HTTPS 调用

```text
POST https://api.weixin.qq.com/cgi-bin/openapi/quota/get?access_token=ACCESS_TOKEN 
```

### 第三方调用

- 调用方式以及出入参和 HTTPS 相同,仅是调用的 token 不同

### 请求参数

| 属性         | 类型   | 必填 | 说明                                                         |
| :----------- | :----- | :--- | :----------------------------------------------------------- |
| access_token | string | 是   | 第三方平台接口调用凭证[authorizer_access_token](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html),该参数为 URL 参数,非 Body 参数。 |
| cgi_path     | string | 是   | api的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会76003的报错 |

### 返回参数

|      | 属性                                                         | 类型   | 说明      |
| :--- | :----------------------------------------------------------- | :----- | :-------- |
|      | errcode                                                      | number | 返回码    |
|      | errmsg                                                       | string | 错误信息  |
|      | quota                                                        | object | quota详情 |
|      | 属性类型说明daily_limitnumber当天该账号可调用该接口的次数usednumber当天已经调用的次数remainnumber当天剩余调用次数 |        |           |

## 调用示例

> 示例说明: 请求示例:

### 请求数据示例

```json
{
"cgi_path":"/wxa/gettemplatedraftlist"
} 
```

### 返回数据示例

```json
{
  "errcode": 0,
  "errmsg": "ok",
  "quota":{
    "daily_limit": 0,
    "used": 0,
    "remain": 0}
} 
```

### 错误码

| 错误码 | 错误码取值                                 | 解决方案                                                     |
| :----- | :----------------------------------------- | :----------------------------------------------------------- |
| 0      | ok                                         | ok                                                           |
| 76021  | cgi_path not found, please check           | cgi_path填错了                                               |
| 76022  | could not use this cgi_path,no permission | 当前调用接口使用的 token 与api所属账号不符,详情可看注意事项的说明 |

|      |      |      |
| :--- | :--- | :--- |
|      |      |      |
|      |      |      |
|      |      |      |