创建浏览器会话
/browserbase/v1/sessions● 支持请求参数
projectIdstring可选The Project ID. Can be found in Settings. Optional - if not provided, the project will be inferred from the API key.
extensionIdstring可选○ 未支持不支持此配置。
browserSettingsobject可选展开子字段 (14)
contextobject可选展开子字段 (2)
idstring必填The Context ID.
persistboolean可选Whether or not to persist the context after browsing. Defaults to
false.
extensionIdstring可选○ 未支持不支持此配置。
viewportobject可选展开子字段 (2)
widthinteger可选The width of the browser.
heightinteger可选The height of the browser.
blockAdsboolean可选◐ 部分支持接受但忽略;不会启用此能力。
solveCaptchasboolean可选◐ 部分支持接受但忽略;不会启用此能力。
recordSessionboolean可选◐ 部分支持接受但忽略;不会启用此能力。
logSessionboolean可选◐ 部分支持接受但忽略;不会启用此能力。
advancedStealthboolean可选○ 未支持不支持此配置。
verifiedboolean可选○ 未支持不支持此配置。
captchaImageSelectorstring可选Custom selector for captcha image. See Custom Captcha Solving
captchaInputSelectorstring可选Custom selector for captcha input. See Custom Captcha Solving
osstring可选○ 未支持不支持此配置。
allowedDomainsarray可选○ 未支持不支持此配置。
ignoreCertificateErrorsboolean可选○ 未支持不支持此配置。
timeoutinteger可选Duration in seconds after which the session will automatically end. Defaults to the Project's
defaultTimeout. Minimum 60 seconds, maximum 21600 seconds (6 hours).keepAliveboolean可选Set to true to keep the session alive even after disconnections. Available on the Hobby Plan and above.
proxiesunion可选◐ 部分支持省略、false 或 [{type: 'none'}] 走默认出口;一个 {type: 'external', server, username?, password? | password_secret?} 经你的 HTTP 代理出口,需组织已开放此能力,未开放返回 501 PROVIDER_UNSUPPORTED;其它类型、socks5 或多个条目返回 501,缺字段、内网地址、与 BYOB 同用返回 400 INVALID_PARAMS。详见 /developers/browser/proxies。
proxySettingsobject可选Supplementary proxy settings. Optional.
展开子字段 (1)
caCertificatesarray可选The TLS certificate IDs to trust. Optional.
regionstring可选◐ 部分支持接受但忽略;不会启用此能力。
userMetadataobject可选Arbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.
返回
201
仅支持服务指南列出的能力;部分官方请求参数不可用。
错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误
请求示例
curl
curl -X POST "https://api.deepraxis.com/browserbase/v1/sessions" \
-H "X-BB-API-Key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timeout":300}'Python
import os, requests
response = requests.request("POST", f"https://api.deepraxis.com/browserbase/v1/sessions",
headers={"X-BB-API-Key": os.environ["PRAXIS_API_KEY"]},
json={"timeout":300}
)
print(response.status_code, response.text)TypeScript
const response = await fetch(`https://api.deepraxis.com/browserbase/v1/sessions`, {
method: "POST",
headers: { "X-BB-API-Key": `${process.env.PRAXIS_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({"timeout":300}),
});
console.log(response.status, await response.text());反检测、扩展和 Selenium 不可用;代理只接受 external 类型且需组织开放。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。
响应
HTTP 201
The request has succeeded and a new resource has been created as a result.
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | |
| createdAt | string | |
| updatedAt | string | |
| projectId | string | The Project ID linked to the Session. |
| startedAt | string | |
| endedAt | string | |
| expiresAt | string | |
| status | string | |
| proxyBytes | integer | Bytes used via the Proxy |
| keepAlive | boolean | Indicates if the Session was created to be kept alive upon disconnections |
| contextId | string | Optional. The Context linked to the Session. |
| region | string | The region where the Session is running. |
| userMetadata | object | Arbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata. |
| connectUrl | string | WebSocket URL to connect to the Session. |
| seleniumRemoteUrl | string | HTTP URL to connect to the Session. |
| signingKey | string | Signing key to use when connecting to the Session via HTTP. |