跳转到内容
EN

创建登录态

POST/browser/v1/contexts● 支持

请求参数

  • projectIdstring可选

    兼容项目字段;传入值被忽略,创建结果的 projectId 固定为 default。

  • namestring可选

    登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。

  • labelsobject可选

    自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。

  • proxyobject可选

    给登录态绑定一个固定的外部代理(如住宅 IP),使用这个登录态的会话没有写 proxies 时都经它出网,让同一账号始终从同一个出口地址出去。只存保管库引用(password_secret),不存密码;会话自己写了 proxies 时以会话的为准。需要组织已开通容器后端,否则返回 501 PROVIDER_UNSUPPORTED。

    展开子字段 (4)
    • typestring必填

      固定为 external:经一个你自己的外部 HTTP 代理出网。

    • serverstring必填

      代理地址,host:port 或 http://host:port;只支持 HTTP 代理,不接受 socks5:// 等协议,也不接受 localhost 和内网、链路本地地址。

    • usernamestring可选

      代理用户名;有密码时才能填,填了就必须同时给出密码。

    • password_secretobject可选

      必须用这种形式:引用保管库里的代理密码,只在连接这个代理的主机时兑换,不会交给网页。登录态里只存引用,传明文 password 返回 400 INVALID_PARAMS。

      展开子字段 (2)
      • vault_idstring必填

        保存代理密码的保管库 ID,以 vlt_ 开头。

      • secretstring必填

        保管库中该密码的密钥 ID(不是密码本身)。

返回

201

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

请求示例

curl
curl -X POST "https://api.deepraxis.com/browser/v1/contexts" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"work-login"}'
Python
import os, requests

response = requests.request("POST", f"https://api.deepraxis.com/browser/v1/contexts",
    headers={"Authorization": "Bearer " + os.environ["PRAXIS_API_KEY"]},
    json={"name":"work-login"}
)
print(response.status_code, response.text)
TypeScript
const response = await fetch(`https://api.deepraxis.com/browser/v1/contexts`, {
  method: "POST",
  headers: { "Authorization": `Bearer ${process.env.PRAXIS_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({"name":"work-login"}),
});
console.log(response.status, await response.text());

连接与使用指南

响应

HTTP 201

请求成功。

application/json

名称 类型 说明
id string 登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
projectId string 兼容项目标识,当前账户的登录态固定返回 default。
createdAt string 登录态创建时刻,UTC ISO 8601 时间。
updatedAt string 登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
name string 登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
labels object 自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
sites array<string> 已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
cookieCount integer 登录态中已保存的 cookie 条目数量;新登录态为 0。
bytes integer 登录态加密后保存内容的大小,单位为 UTF-8 字节。
lockedBy string 当前登录态写入租约的持有者标识;无有效租约时省略。
lastUsedAt string UTC timestamp when a session last started with this context; absent if it has never been used.
proxy object 登录态绑定的固定外部代理(只含保管库引用,不含密码);没有绑定时省略。
proxy.type string 固定为 external:经一个你自己的外部 HTTP 代理出网。
proxy.server string 代理地址,host:port 或 http://host:port;只支持 HTTP 代理,不接受 socks5:// 等协议,也不接受 localhost 和内网、链路本地地址。
proxy.username string 代理用户名;有密码时才能填,填了就必须同时给出密码。
proxy.password_secret object 必须用这种形式:引用保管库里的代理密码,只在连接这个代理的主机时兑换,不会交给网页。登录态里只存引用,传明文 password 返回 400 INVALID_PARAMS。
publicKey string Empty compatibility field; context encryption keys are held by the server.
cipherAlgorithm string Compatibility encryption algorithm name; creation returns AES-256-CBC.
initializationVectorSize integer Compatibility initialization-vector size in bytes; creation returns 16.