API参考
学分查询 API
AI发型设计 API - 学分查询 API 文档和使用指南。
GET
/
common
/
query-credits
Querying credits
curl --request GET \
--url https://api.aihairstyle.cn/common/query-credits \
--header 'ailabapi-api-key: <api-key>'import requests
url = "https://api.aihairstyle.cn/common/query-credits"
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'ailabapi-api-key': '<api-key>'}};
fetch('https://api.aihairstyle.cn/common/query-credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aihairstyle.cn/common/query-credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.aihairstyle.cn/common/query-credits"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.aihairstyle.cn/common/query-credits")
.header("ailabapi-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihairstyle.cn/common/query-credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["ailabapi-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": 0,
"error_code_str": "",
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"data": {
"unique_sign": "",
"name": "",
"balance": 0,
"total": 0,
"last_recharge_balance": 0,
"balance_warning": 0,
"first_buy_time": 0,
"last_update_time": 0
}
}请求
- URL: /common/query-credits
- 方法:
GET
请求头
| 字段 | 必填 | 类型 | 描述 |
|---|---|---|---|
ailabapi-api-key | 是 | String | 应用 API KEY。 获取 API KEY |
响应
响应字段处理流程-
处理
公共响应字段解析并验证公共响应字段,检查状态码或响应消息以确保请求成功且无错误。 -
处理
业务响应字段如果公共响应字段有效且无错误,则继续处理业务响应字段中的业务逻辑。
公共响应字段
查看公共响应字段和错误代码业务响应字段
| 字段 | 类型 | 范围 | 描述 | |
|---|---|---|---|---|
data | array | 数据数组 | ||
+name | string | 名称。 | \ | |
+balance | float | 积分余额。 | \ | |
+total | float | 总积分。 | \ | |
+last_recharge_balance | float | 上次购买后的余额。 | \ | |
+balance_warning | float | 积分余额预警值。 | \ | |
+first_buy_time | integer | 首次购买时间。 | \ | |
+last_update_time | integer | 最后更新时间。 | \ |
响应示例
{
"error_code": 0,
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"data": [
{
"unique_sign": "",
"name": "",
"balance": 0,\
"total": 0,
"last_recharge_balance": 0,
"balance_warning": 0,
"first_buy_time": 0,
"last_update_time": 0
}
]
}
Was this page helpful?
⌘I
Querying credits
curl --request GET \
--url https://api.aihairstyle.cn/common/query-credits \
--header 'ailabapi-api-key: <api-key>'import requests
url = "https://api.aihairstyle.cn/common/query-credits"
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'ailabapi-api-key': '<api-key>'}};
fetch('https://api.aihairstyle.cn/common/query-credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aihairstyle.cn/common/query-credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.aihairstyle.cn/common/query-credits"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.aihairstyle.cn/common/query-credits")
.header("ailabapi-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihairstyle.cn/common/query-credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["ailabapi-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": 0,
"error_code_str": "",
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"data": {
"unique_sign": "",
"name": "",
"balance": 0,
"total": 0,
"last_recharge_balance": 0,
"balance_warning": 0,
"first_buy_time": 0,
"last_update_time": 0
}
}