创建实例
最近更新:2025-04-18 19:06:16
创建实例
const create = async () => {
const res = await sdk.create({
sessionName: "实例名称2",
productId: "test",
expiredType: 1,
expired: 0,
browser: {
system: "Windows 10",
uaVersion: "122",
publicIp: "192.168.0.171",
ipChannel: "ipdata",
kernel: "chrome",
kernelVersion: "122",
},
});
};
只有 role 为 owner 才能创建实例
请求参数
名称 | 类型 | 是否必须 | 字段含义 | 备注 |
orderno | string | 是 | 订单 ID | App 订单标识 |
sessionName | string | 是 | 实例名称 | 实例名称 |
productId | string | 是 | 产品 ID | 产品 ID,决定主机所在的区域 |
expiredType | int | 是 | 到期类型 | 到期类型 1 不过期 2 到期时间 3 剩余时长(单位秒) |
expired | int64 | 是 | 到期时间 | 当 expiredType = 1 时 值为 Unix 时间戳,expiredType = 2 时为时长秒数 |
cookies | array | 否 | cookies | cookies 信息 |
cookies 结构
名称 | 类型 | 是否必须 | 字段含义 | 备注 |
creation_utc | float64 | 是 | Cookie 创建的 UTC 时间戳 | 以浮点数形式表示 |
expires_utc | float64 | 否 | Cookie 过期的 UTC 时间戳 | 以浮点数形式表示,若值为 0 可能表示不过期 |
has_expires | int | 否 | 表示是否有过期时间 | 可以用不同整数值代表不同状态,如 1 表示有过期时间,0 表示无 |
host_key | string | 是 | 关联的主机键 | 用于标识 Cookie 所属的主机 |
is_httponly | int | 否 | 表示是否为 HttpOnly Cookie | 通常用 1 表示是,0 表示否,HttpOnly 的 Cookie 不能通过脚本访问 |
is_persistent | int | 否 | 表示是否为持久化 Cookie | 用不同整数值代表不同状态,如 1 表示持久化,0 表示非持久化 |
is_same_party | int | 否 | 表示是否为 SameParty Cookie | 用于跨站请求相关的安全控制,用不同整数值代表不同状态 |
is_secure | int | 否 | 表示是否为安全 Cookie | 通常用 1 表示是,0 表示否,安全 Cookie 仅在 HTTPS 连接中传输 |
last_access_utc | float64 | 否 | 最后访问的 UTC 时间戳 | 以浮点数形式表示,记录最后一次访问该 Cookie 的时间 |
last_update_utc | float64 | 否 | 最后更新的 UTC 时间戳 | 以浮点数形式表示,记录最后一次更新该 Cookie 的时间 |
name | string | 是 | Cookie 的名称 | 用于标识该 Cookie 的唯一名称 |
path | string | 是 | Cookie 适用的路径 | 表示该 Cookie 在哪些路径下是有效的 |
priority | int | 否 | Cookie 的优先级 | 不同整数值代表不同优先级,如 1 表示低,2 表示中,3 表示高 |
samesite | int | 否 | 表示 SameSite 属性值 | 用于控制跨站请求时 Cookie 的发送,不同整数值代表不同属性值 |
source_port | int | 否 | 源端口号 | 记录创建该 Cookie 的源端口号 |
source_scheme | int | 否 | 源协议方案 | 不同整数值代表不同协议,如 1 表示 HTTP,2 表示 HTTPS |
top_frame_site_key | string | 否 | 顶级框架的站点键 | 用于标识顶级框架的站点信息 |
value | string | 是 | Cookie 的值 | 存储 Cookie 的实际内容 |
browser 结构
名称 | 类型 | 是否必须 | 字段含义 | 备注 |
system | string | 是 | 操作系统 | 目前支持: Windows 7,Windows 8,Windows 8.1,Windows 10,Windows 11 |
uaVersion | string | 否 | ua 大版本号 | 范围 100-124 |
publicIp | string | 是 | 公网 ip | 设置代理取代理里的 IP |
ipChannel | string | 否 | ip 检测渠道 | 可为空,枚举 ip2location,ipdata |
kernel | string | 是 | 内核类型 | 枚举 chrome,firefox |
kernelVersion | string | 是 | 内核版本 | 107,119,122 |
proxy | object | 否 | 代理信息 | |
site_accounts | array | 否 | 账号信息 | 数组,每个元素为一个账号信息,包含 user,pwd,site |
{
"sessionName": "实例名称",
"productId": "产品ID",
"expiredType": 1,
"expired": 0,
"browser": {
"headless": "1",
"system": "",
"uaVersion": "",
"publicIp": "192.168.0.171",
"ipChannel": "",
"kernel": "chrome",
"kernelVersion": "127",
"proxy": {
"protocol": "http",
"host": "192.168.0.171",
"port": 10809,
"userName": "",
"password": ""
},
"site_accounts": [
{
"user": "",
"pwd": "",
"site": ""
}
]
}
}
返回值
{
"reqId": "a0d29fff-1315-44ee-8ad7-7905d6726a4f",
"code": 200,
"msg": "OK",
"data": {
"id": 6,
"appID": "",
"userId": "",
"companyId": "",
"sessionId": "7fe752d6369745e4affb4c645e4faba2",
"sessionName": "local",
"productId": "hztest",
"cloudId": "fcd1d3f39cba4a94b95d255c4e5efd64",
"browserUrl": "",
"apiKey": "7fe752d6369745e4affb4c645e4faba2",
"status": 2,
"healthy": 1,
"expiredType": 1,
"expired": 0,
"totalDuration": 14045,
"duration": 0,
"info": null,
"browser": {
"system": "Windows 11",
"publicIp": "127.0.0.1",
"kernel": "chrome",
"kernelVersion": "127",
"proxy": {
"protocol": "",
"host": "",
"port": 0,
"userName": "",
"password": ""
}
},
"country": "CN",
"city": "CN"
}
}