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);
4.3 JavaScript
const apiKey = '******'; // 你的API KEY
const apiUrl = 'https://api.shiliuai.com/api/id_photo/v1/credit';
(async () => {
try {
const res = await fetch(apiUrl, {
method: 'POST',
headers: {
APIKEY: apiKey,
'Content-Type': 'application/json'
}
});
const data = await res.json();
if (data.code === 0) {
console.log('剩余积分:', data.credit);
} else {
console.error('请求失败:', data.msg_cn || data.msg);
}
} catch (e) {
console.error('发生错误:', e);
}
})();
4.4 C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var apiKey = "******"; // 你的API KEY
var url = "https://api.shiliuai.com/api/id_photo/v1/credit";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("APIKEY", apiKey);
var res = await client.PostAsync(url, new StringContent("{}", Encoding.UTF8, "application/json"));
var json = await res.Content.ReadAsStringAsync();
var doc = JsonDocument.Parse(json);
var root = doc.RootElement;
var code = root.GetProperty("code").GetInt32();
if (code == 0)
{
var credit = root.GetProperty("credit").GetInt32();
Console.WriteLine($"剩余积分: {credit}");
}
else
{
var msg = root.TryGetProperty("msg_cn", out var msgCn) ? msgCn.GetString() : root.GetProperty("msg").GetString();
Console.WriteLine($"请求失败: {msg}");
}
}
}
4.5 易语言
版本 2
.支持库 spec
.支持库 dp1
.子程序 积分查询_API_示例
.局部变量 局_网址, 文本型
.局部变量 局_方式, 整数型
.局部变量 局_提交数据, 文本型
.局部变量 局_提交协议头, 文本型
.局部变量 局_结果, 字节集
.局部变量 局_返回, 文本型
局_提交数据 = "{}"
局_网址 = "https://api.shiliuai.com/api/id_photo/v1/credit"
局_方式 = 1
局_提交协议头 = "APIKEY: 你的APIKEY" + #换行符 + "Content-Type: application/json"
局_结果 = 网页_访问_对象 (局_网址, 局_方式, 局_提交数据, , , 局_提交协议头, , , , , , , , , , , , , )
局_返回 = 到文本 (编码_编码转换对象 (局_结果, , , ))
返回 (局_返回)
4.6 天诺
public static string Api_Credit(string apiKey)
{
string url = "https://api.shiliuai.com/api/id_photo/v1/credit";
var headers = new Dictionary
{
{"Authorization", "APPCODE " + appcode},
{"Content-Type", "application/json"}
};
string body = "{}";
return CustomHelp.HttpPost(url, body, headers);
}
4.7 按键精灵-电脑版
Import "Encrypt.dll"
VBSBegin
Function api_credit(apiKey)
url = "https://api.shiliuai.com/api/id_photo/v1/credit"
jsonBody = "{}"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "POST", url, False
http.setRequestHeader "APIKEY", apiKey
http.setRequestHeader "Content-Type", "application/json"
http.send jsonBody
api_credit = http.responseText
End Function
VBSEnd
apiKey = "你的APIKEY"
res = api_credit(apiKey)
TracePrint res
4.8 按键精灵-手机版
Import "yd.luae"
Import "zm.luae"
Function api_credit(apiKey)
Dim url = "https://api.shiliuai.com/api/id_photo/v1/credit"
Dim body = "{}"
Dim headers = {null}
headers["APIKEY"] = apiKey
headers["Content-Type"] = "application/json"
Dim res = yd.HttpPost(url, body, headers)
api_credit = yd.JsonDecode(res)
End Function
Dim apiKey = "你的APIKEY"
Dim res = api_credit(apiKey)
TracePrint res["code"]
4.9 触动精灵
require("tsnet")
require "TSLib"
local ts = require("ts")
local json = ts.json
function api_credit(apiKey)
local url = "https://api.shiliuai.com/api/id_photo/v1/credit"
local body = "{}"
local headers = {}
headers["APIKEY"] = apiKey
headers["Content-Type"] = "application/json"
local resp = httpPost(url, body, { headers = headers })
return json.decode(resp)
end
4.10 懒人精灵
function api_credit(apiKey)
local url = "https://api.shiliuai.com/api/id_photo/v1/credit"
local body = "{}"
local headers = {}
headers["APIKEY"] = apiKey
headers["Content-Type"] = "application/json"
local resp = httpPost(url, body, { headers = headers })
return jsonLib.decode(resp)
end
4.11 EasyClick
function main()
local apiKey = "你的APIKEY"
local res = api_credit(apiKey)
logd(res.code)
if res.credit then logd(res.credit) end
end
function api_credit(apiKey)
local url = "https://api.shiliuai.com/api/id_photo/v1/credit"
local body = JSON.stringify({})
local params = {
url = url,
method = "POST",
headers = {
["APIKEY"] = apiKey,
["Content-Type"] = "application/json"
},
requestBody = body
}
local res = http.request(params)
return JSON.parse(res.body)
end