更新偏好和每日额度

保存控制台语言、每日调用限额和邮件提醒设置。

PATCH/api/settings
认证
控制台会话 Cookie。
成功状态
200

请求参数

参数类型位置必填说明
OriginURIheader是当前站点的完整来源。
localezh | enbody否偏好语言。
dailyLimitinteger | nullbody否0–10,000,000 次,0 禁用实时调用,null 为不限额。新账号默认 100,000。
lowBalancebooleanbody否打开低额度邮件提醒。
lowBalanceThresholdintegerbody否1–10,000,000 次。剩余额度低于该值时触发提醒。
runFailedbooleanbody否打开任务失败及部分完成邮件提醒。

请求示例

JavaScript 示例可在本站已登录的浏览器中运行。cURL 和 Python 示例读取你本机的 cookies.txt Cookie 文件。请将会话 Cookie 视为私密凭据。

cURL
curl -i -X PATCH 'https://social2api.com/api/settings' \
  --cookie ./cookies.txt \
  -H 'Content-Type: application/json' \
  -H 'Origin: https://social2api.com' \
  --data-binary '{
  "dailyLimit": 1000
}'
Python
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",
    method="PATCH",
    headers={
        "Content-Type": "application/json",
        "Origin": "https://social2api.com",
    },
    data="{\"dailyLimit\":1000}".encode("utf-8"),
)
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", {
  method: "PATCH",
  credentials: "same-origin",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "dailyLimit": 1000
  }),
});
console.log(response.status, await response.text());

响应

200 · 示例响应
{
  "preferences": {
    "locale": "zh",
    "dailyLimit": 1000,
    "lowBalance": false,
    "lowBalanceThreshold": 1000,
    "runFailed": false
  },
  "usage": {
    "day": "2026-01-15",
    "used": 0,
    "remaining": 1000
  },
  "mailEnabled": false
}
错误示例
{
  "error": "请先登录。"
}
字段类型说明
preferences.localezh | en设置与提醒使用的语言偏好。
preferences.dailyLimitinteger | null账号每日上游调用上限。
preferences.lowBalanceboolean是否为低额度发送邮件。
preferences.lowBalanceThresholdinteger低额度提醒阈值,单位为调用次数。
preferences.runFailedboolean是否为失败或部分完成的任务发送邮件。
preferencesobject还可包含账号保存的其它偏好。
usage.dayYYYY-MM-DD当前 UTC 日期。
usage.usedinteger当日已尝试的上游调用数。
usage.remaininginteger | null当日剩余调用次数。不限额时为 null。
mailEnabledboolean部署是否配置邮件传输。邮件提醒还需验证邮箱。

错误状态

HTTP原因与处理
400请求格式或字段无效。
403浏览器来源校验未通过。
401控制台会话缺失、过期或无效。
405请求方法不受支持。
503此部署未配置该控制台服务。

使用细节

  • 写请求须包含与站点完全相同的 Origin。
  • JSON 请求体最多 4,096 字节。仅允许文档列出的偏好字段。