1. 接口说明
积分查询 API:查询当前账号剩余 API 积分额度,便于在调用计费接口前进行额度判断或在控制台展示余额。
2. 请求信息
2.1 请求地址(URL)
POST https://api.shiliuai.com/api/id_photo/v1/credit
2.2 请求方式
POST
2.3 请求头(header)
| 参数 | 类型 | 说明 |
|---|---|---|
| Content-Type | string | application/json |
| APIKEY | string | 您的 API KEY |
3. 返回信息
3.1 返回类型
JSON
3.2 返回字段
| 参数 | 说明 |
|---|---|
| code | 错误码 |
| msg | 错误信息(英文) |
| msg_cn | 错误信息(中文) |
| credit | 剩余 API 积分(当 code==0 时返回) |
3.3 返回示例
{
"code": 0,
"msg": "OK",
"msg_cn": "成功",
"credit": 1200
}
3.4 错误码说明
| 错误码 | 说明 |
|---|---|
| 0 | 成功 |
| 101 | API-KEY 不正确 |
4. 示例代码
4.1 Python
import requests
import json
api_key = '******' # 你的API KEY
url = 'https://api.shiliuai.com/api/id_photo/v1/credit'
headers = {'APIKEY': api_key, "Content-type": "application/json"}
response = requests.post(url=url, headers=headers)
response = json.loads(response.content)
"""
成功:{'code': 0, 'credit': credit, 'msg': 'OK'}
or
失败:{'code': error_code, 'msg': error_msg}
"""
4.2 PHP
$url = "https://api.shiliuai.com/api/id_photo/v1/credit"; $method = "POST"; $apikey = "******"; $header = array(); array_push($header, "APIKEY:" . $apikey); array_push($header, "Content-Type:application/json"); $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($curl); var_dump($response);