Create a browser session
/browser/v1/sessions● SupportedRequest parameters
projectIdstringoptional可省略;账户使用 default 项目。
visibilitystringoptional谁能看到这个新会话:默认 private 只有创建者;organization 允许同组织其他成员只读观看画面。自带浏览器(source.type 为 byob)的会话一律是 organization,传 private 也会被改成 organization,不报错。
keepAlivebooleanoptionalfalse 时最后一个客户端断开且无人观看后结束会话;true 时保留至关闭或超时。两种情况都仍受健康检查约束:浏览器连续 2 次健康检查失败时结束会话(closeReason=watchdog)。
timeoutnumberoptional从创建时刻起算的会话最长寿命,单位为秒;可含小数。
browserSettingsobjectoptional创建浏览器时的登录态、视口及兼容选项;省略时不加载已保存的登录态。
Expand sub-fields (13)
contextobjectoptional新会话使用的已保存登录态;必须属于当前账户;persist 为 true 时同一登录态只能有一个写入会话。
Expand sub-fields (2)
idstringrequired登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
persistbooleanoptional关闭会话时合并保存 cookie 和 localStorage;false 只读取登录态;不保存 IndexedDB。
viewportobjectoptional浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。
Expand sub-fields (2)
widthintegerrequired浏览器视口宽度,单位为像素,必须为正整数。
heightintegerrequired浏览器视口高度,单位为像素,必须为正整数。
blockAdsbooleanoptional◐ Partially supportedAccepted but ignored; does not enable this capability.
solveCaptchasbooleanoptional◐ Partially supportedAccepted but ignored; does not enable this capability.
recordSessionbooleanoptional◐ Partially supportedAccepted but ignored; does not enable this capability.
logSessionbooleanoptional◐ Partially supportedAccepted but ignored; does not enable this capability.
extensionIdstringoptional○ UnsupportedThis configuration is unavailable.
verifiedbooleanoptional○ UnsupportedThis configuration is unavailable.
advancedStealthbooleanoptional○ UnsupportedThis configuration is unavailable.
osstringoptional○ UnsupportedThis configuration is unavailable.
fingerprintobjectoptional○ UnsupportedThis configuration is unavailable.
allowedDomainsarrayoptional○ UnsupportedThis configuration is unavailable.
ignoreCertificateErrorsbooleanoptional○ UnsupportedThis configuration is unavailable.
proxiesunionoptional◐ Partially supportedOmission, false or [{type: 'none'}] uses the default exit. One {type: 'external', server, username?, password? | password_secret?} exits through your HTTP proxy and needs the capability opened for your organization (otherwise 501 PROVIDER_UNSUPPORTED). Other types, socks5 or several entries return 501; missing fields, internal addresses and use with BYOB return 400 INVALID_PARAMS. See /developers/browser/proxies.
sourceunionoptionalChooses the backend: {type: 'cloud'} is Browser Run (no proxy); {type: 'container'} is our own Chrome container (a proxy is optional; needs the capability opened for your organization, otherwise 501 PROVIDER_UNSUPPORTED); {type: 'byob', browser: 'byb_…'} is the user's own browser (short form {byob: 'byb_…'}; not allowed with proxies or a login state). When omitted, a session with proxies runs in the container and any other on Browser Run. cloud with a proxy and an unknown type return 400 INVALID_PARAMS. See /developers/browser/backend.
regionstringoptional◐ Partially supportedAccepted but ignored; does not enable this capability.
extensionIdstringoptional○ UnsupportedThis configuration is unavailable.
userMetadataobjectoptional自定义 JSON 元数据;序列化后的长度最多为 512 个 UTF-16 代码单元。
More parameters (2)
namestringoptional会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。
labelsobjectoptional自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
Returns
200
Errors contain statusCode, error and message; the native API adds code. The request ID is in X-Request-Id. Errors
Request example
curl
curl -X POST "https://api.deepraxis.com/browser/v1/sessions" \
-H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timeout":300}'Python
import os, requests
response = requests.request("POST", f"https://api.deepraxis.com/browser/v1/sessions",
headers={"Authorization": "Bearer " + os.environ["PRAXIS_API_KEY"]},
json={"timeout":300}
)
print(response.status_code, response.text)TypeScript
const response = await fetch(`https://api.deepraxis.com/browser/v1/sessions`, {
method: "POST",
headers: { "Authorization": `Bearer ${process.env.PRAXIS_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({"timeout":300}),
});
console.log(response.status, await response.text());Response
HTTP 200
请求成功。
application/json
| Name | Type | Description |
|---|---|---|
| id | string | 浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。 |
| projectId | string | 兼容项目标识,当前账户的会话固定返回 default。 |
| status | string | 会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。 |
| keepAlive | boolean | API 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。健康检查失败(closeReason=watchdog)时无论 keepAlive 为何都会结束。 |
| region | string | 兼容字段,不代表可选择部署区域。 |
| proxyBytes | integer | 会话经代理链转发的流量字节数(上行与下行之和),容器后端的会话按它计费;Browser Run 和自带浏览器固定为 0,运行中每几分钟更新一次。 |
| createdAt | string | 会话创建时刻,UTC ISO 8601 时间。 |
| updatedAt | string | 会话状态最近一次更新的时刻,UTC ISO 8601 时间。 |
| startedAt | string | 浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。 |
| expiresAt | string | 会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。 |
| endedAt | string | 浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。 |
| contextId | string | 登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。 |
| userMetadata | object | 创建会话时传入的自定义 JSON 元数据;未设置时为空对象。 |
| name | string | 会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。 |
| labels | object | 自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。 |
| origin | string | 会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。 |
| source | object | 会话实际使用的浏览器后端:cloud 是云浏览器(Browser Run),container 是我们自己的 Chrome 容器,byob 是用户自己配对的浏览器(browser 为它的 ID)。type 与 kind 同值,type 是公开名称,kind 为兼容旧读者保留。 |
| source.type | string | 云浏览器会话,固定为 cloud。 / 自家 Chrome 容器会话,固定为 container。 / 用户自己配对的浏览器会话,固定为 byob。 |
| source.kind | string | 与 type 同值。 |
| source.browser | string | 自带浏览器 ID,以 byb_ 开头。 |
| createdBy | string | 创建这个会话的用户或智能体标识;通过能力 URL 创建、或在引入创建者之前创建的会话省略此字段。 |
| visibility | string | 谁能看到这个会话:private 只有创建者,organization 同组织成员可只读观看画面。 |
| closeReason | string | 会话释放原因;未开始释放时省略。 |
| viewport | object | 浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。 |
| viewport.width | integer | 浏览器视口宽度,单位为像素,必须为正整数。 |
| viewport.height | integer | 浏览器视口高度,单位为像素,必须为正整数。 |
| billedSeconds | number | 会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。 |
| currentUrl | string | 最近观察到的页面导航地址;尚未观察到导航时省略。 |
| clients | integer | 当前连接的 CDP 客户端数量;不包含仅观看页面的用户。 |
| handoff | object | null | 待完成的人工接管请求;没有请求、已完成或已过期时为 null。 |
| handoff.message | string | 请求人工接管时提供给操作者的说明文字。 |
| handoff.requestedAt | string | 人工接管请求的发起时刻,UTC ISO 8601 时间。 |
| handoff.expiresAt | string | 人工接管请求的失效时刻,UTC ISO 8601 时间。 |
| connectUrl | string | 自带凭证的 CDP WebSocket 地址,有效期覆盖会话寿命;连接无需额外 API Key。真指针事件(触摸、拖拽、按坐标点击)的 CDP 命令从这里发送。 |
| signingKey | string | connectUrl 内的连接凭证,请勿公开。 |
| seleniumRemoteUrl | string | 该地址返回 501;不支持 Selenium。 |
| reused | boolean | true 表示本次按 name 复用了已在运行的同名会话(HTTP 200),没有新开会话;false 表示新开了会话(HTTP 201)。 |
HTTP 201
请求成功。
application/json
| Name | Type | Description |
|---|---|---|
| id | string | 浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。 |
| projectId | string | 兼容项目标识,当前账户的会话固定返回 default。 |
| status | string | 会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。 |
| keepAlive | boolean | API 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。健康检查失败(closeReason=watchdog)时无论 keepAlive 为何都会结束。 |
| region | string | 兼容字段,不代表可选择部署区域。 |
| proxyBytes | integer | 会话经代理链转发的流量字节数(上行与下行之和),容器后端的会话按它计费;Browser Run 和自带浏览器固定为 0,运行中每几分钟更新一次。 |
| createdAt | string | 会话创建时刻,UTC ISO 8601 时间。 |
| updatedAt | string | 会话状态最近一次更新的时刻,UTC ISO 8601 时间。 |
| startedAt | string | 浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。 |
| expiresAt | string | 会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。 |
| endedAt | string | 浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。 |
| contextId | string | 登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。 |
| userMetadata | object | 创建会话时传入的自定义 JSON 元数据;未设置时为空对象。 |
| name | string | 会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。 |
| labels | object | 自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。 |
| origin | string | 会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。 |
| source | object | 会话实际使用的浏览器后端:cloud 是云浏览器(Browser Run),container 是我们自己的 Chrome 容器,byob 是用户自己配对的浏览器(browser 为它的 ID)。type 与 kind 同值,type 是公开名称,kind 为兼容旧读者保留。 |
| source.type | string | 云浏览器会话,固定为 cloud。 / 自家 Chrome 容器会话,固定为 container。 / 用户自己配对的浏览器会话,固定为 byob。 |
| source.kind | string | 与 type 同值。 |
| source.browser | string | 自带浏览器 ID,以 byb_ 开头。 |
| createdBy | string | 创建这个会话的用户或智能体标识;通过能力 URL 创建、或在引入创建者之前创建的会话省略此字段。 |
| visibility | string | 谁能看到这个会话:private 只有创建者,organization 同组织成员可只读观看画面。 |
| closeReason | string | 会话释放原因;未开始释放时省略。 |
| viewport | object | 浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。 |
| viewport.width | integer | 浏览器视口宽度,单位为像素,必须为正整数。 |
| viewport.height | integer | 浏览器视口高度,单位为像素,必须为正整数。 |
| billedSeconds | number | 会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。 |
| currentUrl | string | 最近观察到的页面导航地址;尚未观察到导航时省略。 |
| clients | integer | 当前连接的 CDP 客户端数量;不包含仅观看页面的用户。 |
| handoff | object | null | 待完成的人工接管请求;没有请求、已完成或已过期时为 null。 |
| handoff.message | string | 请求人工接管时提供给操作者的说明文字。 |
| handoff.requestedAt | string | 人工接管请求的发起时刻,UTC ISO 8601 时间。 |
| handoff.expiresAt | string | 人工接管请求的失效时刻,UTC ISO 8601 时间。 |
| connectUrl | string | 自带凭证的 CDP WebSocket 地址,有效期覆盖会话寿命;连接无需额外 API Key。真指针事件(触摸、拖拽、按坐标点击)的 CDP 命令从这里发送。 |
| signingKey | string | connectUrl 内的连接凭证,请勿公开。 |
| seleniumRemoteUrl | string | 该地址返回 501;不支持 Selenium。 |
| reused | boolean | true 表示本次按 name 复用了已在运行的同名会话(HTTP 200),没有新开会话;false 表示新开了会话(HTTP 201)。 |