API
简介
通过Undetectable的API v1.5,您可以获取配置文件列表、创建、启动、更新和关闭配置文件。此外,通过从Chromium内核的配置文件中获取的信息,您可以连接各种自动化工具,如Puppeteer、Playwright等。
您可以在以下位置下载用于与Selenium一起使用的Chromedriver:
Windows
MacOS M series
MacOS Intel
要使用API,程序必须在运行状态。
默认情况下,本地服务器在端口25325上运行,如果该端口已被占用,则会在其他端口上运行。您可以在程序设置中查看端口并将其更改为所需的端口。
要访问本地服务器,请使用IP 127.0.0.1、localhost或您网络内的本地IP以及设置中的端口和要执行的路径,例如 http://localhost:25325/status
。
所有API的响应如下所示:
{"code": `<状态码>`,"status": `<状态>`,"data": `<返回对象>`,}
其中<状态码>
和<状态>
反映了状态:
<状态码> | <状态> | 描述 |
---|---|---|
0 | ”success” | 成功 |
1 | ”error” | 错误, <返回对象> = {“error”:“错误描述”} |
<返回对象>
- API发送的各种数据,例如配置文件列表。
错误的格式如下:
{ "code":1, "status":"error", "data": {"error": "错误描述"},}
请求
状态
- 路径:
/status
- 方法:GET
描述:返回本地服务器的状态,它是否正在运行
{ "code":0, "status":"success", "data":{},}
配置文件列表
- 路径:
/list
- 方法:GET
描述:返回程序中可用的Chromium浏览器上的配置文件列表
{ "code": 0, "status": "success", "data" { "profile_id1": { "name": "Profile1" // 程序中的配置文件名称 "status": "Available", // 配置文件状态,可能的值为:"Started","Locked", "Available" "debug_port": "xxxx", // 浏览器的调试端口,用于自动化(如果配置文件未启动,则为空)。仅适用于Chromium浏览器 "websocket_link": "ws://127.0.0.1:xxxx/devtools/browser/xxxxxx", // 浏览器链接,用于自动化(如果配置文件未启动,则为空)。仅适用于Chromium浏览器 "folder": "Name", // 配置文件文件夹名称 "tags": ["tag1", "tag2", "tag3"], // 配置文件标签 "cloud_id": "", // 云配置文件ID "creation_date": 123456789, // 创建日期的Unix时间戳 "modify_date": 123456789, // 修改日期的Unix时间戳 }, "profile_id2": { …}, … },}
创建配置文件
- 路径:
/profile/create
- 方法:POST
描述:使用选择的参数创建配置文件。所有参数都是可选的,可以省略。命令的浏览器列表:Chrome、Edge、FireFox、IE、Opera、Safari、Yandex。命令的操作系统列表:Windows、Windows 7、Windows 8、Windows 8.1、Windows 10、Android、iPhone、iPad、Linux、Mac。如果没有与所选操作系统或浏览器匹配的配置,则会使用随机的操作系统或浏览器类型
格式:JSON
{ "name": "具有随机设置的配置文件", // 程序中的配置文件名称 "os": "Windows", // 要使用的操作系统配置 "browser": "Chrome", // 要使用的浏览器配置 "cpu": 8, // 核心数量,可选值:32、24、20、16、12、10、8、7、6、5、4、3、2、1、0 "memory": 8, // 内存大小,可选值:8、4、2、1、0 "tags": ["标签1", "标签2"], // 在配置文件上设置标签 "geolocation": "12.44, 13.524", // 设置地理位置,如果输入为空或不正确的值,则使用默认设置 "resolution": "1024x768", // 屏幕分辨率,可选值:"800x600", "960x540", "1024x768", "1152x864", "1280x720", "1280x768", "1280x800", "1280x1024", "1366x768", "1408x792", "1440x900", "1400x1050", "1440x1080", "1536x864", "1600x900", "1600x1024", "1600x1200", "1680x1050", "1920x1080", "1920x1200", "2048x1152", "2560x1080", "2560x1440", "3440x1440", "3840x2160", "5120x1440" "proxy": "socks5://127.0.0.1:5555:login:pass", // 更改配置文件中的代理(代理可以是http、https、socks5,可以有用户名/密码或没有用户名/密码) "notes": "文本", // 更改配置文件中的备注 "folder": "testFolder", // 配置文件所在的文件夹 "language": "ru-RU, en-US", // 可以设置两种语言 "cookies": [{}], // 将cookie导入配置文件 "type": "cloud", // 配置文件类型:cloud、local "group": "group_example", // 如果没有输入组,则从默认设置中获取,如果存在但不正确,则显示错误 "configid": "id", // 配置ID,如果输入,则忽略OS和Browser参数,其他参数尽可能生效,例如,如果配置是Android,则不会更改屏幕分辨率 "accounts": [ // 将来自不同网站的帐户导入配置文件 {"website": "facebook.com", "username": "test@gmail.com", "password": "123456"}, {"website": "mail.com","username": "test@gmail.com","password": "123456"} ], "timezone": "Pacific/Niue" ("Auto", "System") // set timezone or timezone mode}
{ "code": 0, "status": "success", "data": { "profile_id": "xxxxxxxx...", // 配置文件的唯一ID "name": "具有随机设置的配置文件" // 程序中的配置文件名称 }}
启动配置文件
- 路径:
/profile/start/<profileID>
- 方法:GET
描述:启动具有选择的<profileID>
的配置文件。您可以在链接参数中添加以下参数:
- chrome_flags 并传递任何您想要的启动标志,只需将其编码为URL编码,例如:?chrome_flags=—blink-settings%3DimagesEnabled%3Dfalse%20—disable-webgl2
- start-pages 并指定起始页面,只需将其编码为URL编码,例如:?start-pages=https%3A%2F%2Fgoogle.com%2Chttps%3A%2F%2Fya.ru
{ "code":0, "status":"success", "data":{ "name": "Profile1" // 程序中的配置文件名称 "websocket_link":"ws://127.0.0.1:xxxx/devtools/browser/xxxxxx", // 浏览器链接,用于自动化(如果配置文件未启动,则为空)。仅适用于Chromium浏览器 "debug_port": "xxxx", // Chromium浏览器的调试端口,用于自动化(如果配置文件未启动,则为空)。仅适用于Chromium浏览器 "folder": "Name", // 配置文件的文件夹名称 "tags": ["标签1", "标签2", "标签3"] // 配置文件的标签 },}
关闭配置文件
- 路径:
/profile/stop/<profileID>
- 方法:GET
描述:停止具有选择的<profileID>
的配置文件。
{ "code": 0, "status": "success", "data": {}}
更新配置文件
- 路径:
/profile/update/<profileID>
- 方法: POST
描述: 更新具有指定 <profileID>
的配置文件中的信息。所有参数都是可选的,可以没有它们。
格式: JSON
{ "proxy": "socks5://127.0.0.1:5555:login:pass", // 更改配置文件中的代理(代理可以是http、https、socks5,可以有用户名/密码或没有用户名/密码) "notes": "Text", // 更改配置文件中的备注 "name": "Profile Name", // 更改配置文件中的名称 "folder":"TestFolder", // 更改配置文件中的文件夹 "tags": ["tag1", "tag2"], // 在配置文件上设置标签,如果数组为空,则删除配置文件上的所有标签 "geolocation": "12.44, 13.524", // 设置地理位置,如果输入为空或无效值,则使用默认设置 "cookies":[{}], // 将cookie导入配置文件 "type": "cloud", // 配置文件类型:cloud, local "group": "group_example", // 如果未输入组,则从默认设置中获取,如果存在但不正确,则显示错误 "accounts": [ // 将来自不同网站的帐户导入配置文件 {"website": "facebook.com", "username": "test@gmail.com", "password": "123456"}, {"website": "mail.com","username": "test@gmail.com","password": "123456"} ], "timezone": "Pacific/Niue" ("Auto", "System") // set timezone or timezone mode}
{ "code": 0, "status": "success", "data": {}}
删除配置文件
- 路径:
/profile/delete/<profileID>
- 方法: GET
描述: 删除具有选择的 <profileID>
的配置文件
{ "code": 0, "status": "success", "data": {}}
清除配置文件数据
- 路径:
/profile/cleardata/<profileID>
- 方法: GET
描述: 清除具有选择的 <profileID>
的配置文件中的所有数据(cookie、历史记录、备注、缓存等)
{ "code": 0, "status": "success", "data": {}}
Clear profile cookies
- Path:
/profile/clearcookies/<profileID>
- Method: GET
Description: Clear only cookies from profile with selected <profileID>
{ "code": 0, "status": "success", "data": {}}
配置文件的Cookie
- 路径:
/profile/cookies/<profileID>
- 方法: GET
描述: 请求具有选择的 <profileID>
的配置文件的cookie
{ "code": 0, "status": "success", "data": {}}
发送到云端
- 路径:
/profile/tocloud
- 方法: POST
描述: 将选择的配置文件发送到云端
格式: JSON
{ "profiles": ["9b24cd2604d1b8260123242ab1f30c", "f4cbe3c89618bfc9647ba8a47c13f6"], "group": "test"}
{ "code": 0, "status": "success", "data": {}}
设为本地
- 路径:
/profile/tolocal
- 方法: POST
描述: 将选择的配置文件设为本地
格式: JSON
{ "profiles": ["9b24cd2604d1b8260123242ab1f30c", "f4cbe3c89618bfc9647ba8a47c13f6"]}
{ "code": 0, "status": "success", "data": {}}
更新浏览器版本
- 路径:
/profile/updatebrowser/<profileID>
- 方法: GET
描述: 更新具有选择的 <profileID>
的配置文件中的浏览器版本
格式: JSON
{ "code": 0, "status": "success", "data": {}}
配置列表
- 路径:
/configslist
- 方法: GET
描述: 返回活动配置的列表
格式: JSON
{ "code":0, "status":"success", "data": { "config_id1": { "os": "Windows 10" // 操作系统 "browser":"Chrome 115", // 浏览器类型和版本 "useragent": "xxxx", // 配置中的UserAgent "webgl": "Apple GPU", // 配置中的WebGL "screen": "1024x768", // 屏幕分辨率 }, "config_id2": { … }, … },
}
分组列表
- 路径:
/groupslist
- 方法:GET
描述:返回分组列表
格式:JSON
{ "code":0, "status": "success", "data": {["group1", "group2"]},}
个人资料信息
- 路径:
/profile/getinfo/<profileID>
- 方法:GET
描述:请求具有所选<profileID>
的个人资料信息
格式:JSON
{ "code":0, "status": "success", "data": { "name": "Profile1" // 程序中的个人资料名称 "status": "Available", // 个人资料状态,可能是:"Started","Locked", "Available" "debug_port": "xxxx", // 浏览器的调试端口,用于自动化(如果个人资料未启动,则为空) "websocket_link": "ws://127.0.0.1:xxxx/devtools/browser/xxxxxx", // 浏览器链接,用于自动化(如果个人资料未启动,则为空) "configid": "id" // 配置ID "cloud_id": "" "type": "cloud" // 个人资料类型:cloud, local "proxy": "socks5://127.0.0.1:5555:login:pass", // 个人资料的代理 "folder": "Name", // 个人资料文件夹名称 "tags": ["tag1", "tag2", "tag3"], // 个人资料标签 "notes": "Text", // 个人资料备注 "useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.43", // 个人资料的UserAgent "browser": "Edge 114.0.1823.43", // 个人资料的浏览器 "os": "Windows 10", // 个人资料的操作系统 "screen": "1366x768", // 个人资料的屏幕分辨率 "language": "en-US,en;q=0.9,ak-GH;q=0.8,ak;q=0.7", // 个人资料的语言 "cpu": 8, // 核心数量 "memory": 4, // 内存数量 "creation_date": 123456789, // 创建日期的Unix时间戳 "modify_date": 123456789, // 修改日期的Unix时间戳 },}
Check IP
- Path:
/profile/checkconnection/<profileID>
- Method: GET
Description: Checks the connection in the profile with the selected
Format: JSON
{ "code":0, "status": "success", "data": { "ip": "127.0.0.1" // Returns the IP address in this profile }}
Get timezones list
- Path:
/timezoneslist
- Method: GET
Description: Returning timezones list
Format: JSON
{ "code":0, "status": "success", "data": { "Pacific/Niue": "GMT-11:00", "America/Cambridge_Bay": "GMT-7:00", ... },}
Get proxies list
- Path:
/proxies/list
- Method: GET
Description: Returning proxies list
Format: JSON
{ "code":0, "status": "success", "data": { "proxy_id1": { "name": "Proxy1" "type": "http", "host": "127.0.0.1", "port": "2222", "login": "12345", "password": "12345", "ipchangelink": "", } "proxy_id2": { … }, … }}
Add proxy
- Path:
/proxies/add
- Method: POST
Description: Add a proxy to the proxy manager, the parameters login, password, ipchangelink are optional, the rest are required
Format: JSON
{ "name": "Proxy1", "type": "http", "host": "127.0.0.1", "port": "2222", "login": "12345", "password": "12345", "ipchangelink": ""}
{ "code": 0, "status": "success", "data": { "proxy_id": "12345" }}
Delete proxy
- Path:
/proxies/delete/<ProxyID>
- Method: GET
Description: Removes a proxy with the selected ID. Proxy will be deleted for all profiles with that proxy, the same as during normal deletion from the manager
Format: JSON
{ "code":0, "status":"success", "data": { },}
Update proxy
- Path:
/proxies/update/<ProxyID>
- Method: POST
Description: Updates the proxy with the selected ID, all parameters are optional
Format: JSON
{ "name": "Proxy1", "type": "http", "host": "127.0.0.1", "port": "2222", "login": "12345", "password": "12345", "ipchangelink": ""}
{ "code": 0, "status": "success", "data": { }}
示例
Puppeteer(Node.js)
Node.js Puppeteer 使用特定名称启动个人资料并在该个人资料中打开undetectable.io页面:
const puppeteer = require('puppeteer');const axios = require('axios');
const port = 25325; // 端口const ip = '127.0.0.1'; // 本地IPconst profileName = ‘TestProfile’; // 个人资料名称
const sleep = (ms) => { return new Promise((resolve) => setTimeout(resolve, ms));};
axios.get('http://' + ip + ':' + port + '/status').then(response => { if (response.data.code == 0) { axios.get('http://' + ip + ':' + port + '/list').then(async response => {
for (var profile in response.data.data) { ///// 启动特定个人资料并转到页面 if (response.data.data[profile].name == profileName ) { axios.get('http://' + ip + ':' + port + '/profile/start/' + profile).then(async response => { try { const browser = await puppeteer.connect({ browserWSEndpoint: response.data.data.websocket_link, defaultViewport: null }); const page = await browser.newPage(); await sleep(1000); await page.goto('https://undetectable.io'); } catch (e) { console.log(e); } }) .catch(error => { console.log(error); }); } } }) .catch(error => { console.log(error); }); }}).catch(error => { console.log(error);});
Selenium(Python)
Python + Selenium 启动位于特定文件夹中的个人资料并打开多个网站:
from time import sleepimport requestsfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.chrome.service import Service
address = "127.0.0.1" # 本地 API IP 地址(如果您在同一网络中的另一台计算机上工作,或者在路由器设置中打开了端口,则可以远程访问本地 API,并且需要更改此地址)port_from_settings_browser = '25325' # 本地 API 端口(可以在程序设置中找到)chrome_driver_path = "chromedriver.exe" # v110 的 chromedriver 路径ser = Service(chrome_driver_path)chrome_options = Options()list_response = requests.get(f'http://{address}:{port_from_settings_browser}/list').json()['data'] # 向本地 API 发送请求以获取配置文件列表profile_id = ''
for key, value in list_response.items(): # 遍历配置文件列表并逐个启动 if value['folder'] == 'test': # 在此处可以添加条件以仅启动所需的配置文件(在此示例中,我们启动位于“test”文件夹中的配置文件) profile_id = key if value['status'] == 'Available': # 如果配置文件未启动,则启动配置文件并获取 debug_port start_profile_response = requests.get(f'http://{address}:{port_from_settings_browser}/profile/start/{profile_id}', timeout=5).json()['data'] debug_port = start_profile_response['debug_port'] if value['status'] == 'Started': # 如果配置文件已启动,则直接从可用数据中获取 debug_port debug_port = value['debug_port'] if value['status'] == 'Locked': # 如果配置文件被锁定,则跳过 continue if debug_port: # 检查浏览器是否具有连接端口(WebEngine 配置文件没有端口,因此我们直接关闭它们) chrome_options.debugger_address = f'{address}:{debug_port}' driver = webdriver.Chrome(service=ser, options=chrome_options) driver.get("https://whoer.net/") # 在活动选项卡中打开 whoer.net driver.switch_to.new_window('tab') # 创建新标签页并切换到该标签页 driver.get(url='https://browserleaks.com/js') # 在活动选项卡中打开 browserleaks.com/js # 在此处可以添加任何其他操作 sleep(5) # 等待 5 秒 requests.get(f'http://{address}:{port_from_settings_browser}/profile/stop/{profile_id}') # 停止配置文件