读取计费用量摘要
读取当前 UTC 日的调用额度和包含今天在内最近 30 个 UTC 日的上游尝试数。
GET
/api/settings/billing请求参数
此操作无需提交参数。
请求示例
JavaScript 示例可在本站已登录的浏览器中运行。cURL 和 Python 示例读取你本机的 cookies.txt Cookie 文件。请将会话 Cookie 视为私密凭据。
cURL
curl -i -X GET 'https://social2api.com/api/settings/billing' \
--cookie ./cookies.txtPython
from urllib.error import HTTPError
from urllib.request import Request, HTTPCookieProcessor, build_opener
from http.cookiejar import MozillaCookieJar
request = Request(
"https://social2api.com/api/settings/billing",
method="GET",
)
cookies = MozillaCookieJar("./cookies.txt")
cookies.load(ignore_discard=True)
send = build_opener(HTTPCookieProcessor(cookies)).open
try:
with send(request) as response:
print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
print(error.code, error.read().decode("utf-8"))JavaScript
const response = await fetch("/api/settings/billing", {
method: "GET",
credentials: "same-origin",
});
console.log(response.status, await response.text());响应
200 · 示例响应
{
"usage": {
"day": "2026-01-15",
"used": 0,
"remaining": 100000,
"dailyLimit": 100000,
"periodStart": "2025-12-17",
"periodUsed": 0
}
}错误示例
{
"error": "请先登录。"
}| 字段 | 类型 | 说明 |
|---|---|---|
usage.day | YYYY-MM-DD | 当前 UTC 日期。 |
usage.used | integer | 当日已尝试的上游调用数。 |
usage.remaining | integer | null | 当日剩余调用次数。不限额时为 null。 |
usage.dailyLimit | integer | null | 当日上游调用上限,null 为不限额。 |
usage.periodStart | YYYY-MM-DD | 30 天窗口的首个 UTC 日期。 |
usage.periodUsed | integer | 30 天窗口已尝试的上游调用数。 |
错误状态
| HTTP | 原因与处理 |
|---|---|
401 | 控制台会话缺失、过期或无效。 |
405 | 请求方法不受支持。 |
503 | 此部署未配置该控制台服务。 |
使用细节
- 此摘要以调用次数为单位;供应商实际费用可在调用明细中查看。