Skip to content
API documentation
Run browser

Connecting to the browser

Before connecting to the browser you should get the profile ID, then launch the browser by this ID. At startup the browser will open devtools_port to which you can access connection via Selenium library.

This script will do all these steps in an automated way.

Code

import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import requests
import json
 
def get_profiles_by_tag(local_api_token, local_api_port, tag):
url = f'http://localhost:{local_api_port}/profile?tag={tag}'
headers = {
'x-api-key': local_api_token
}
 
    response = requests.get(url, headers=headers)
 
    if response.status_code == 200:
        return response.json()
    else:
        return {'error': 'Unable to fetch data', 'status_code': response.status_code}
 
def start_browser(local_api_token, local_api_port, profile_id):
url = f'http://localhost:{local_api_port}/profile/{profile_id}/start'
headers = {
'x-api-key': local_api_token
} # geolocationMode = One of ["allow", "block", "user"] # allow - browser automatically give a Geolocation info # block - browser automatically block Geolocation request # user - browser automatically show Geolocation request to user
body = {
"geolocationMode": "allow"
}
 
    response = requests.post(url, headers=headers, json=body)
 
    if response.status_code == 200:
        return response.json()
    else:
        return {'error': 'Unable to fetch data', 'status_code': response.status_code}
 
# We copy this from 0Detect dashboard - Options
 
chrome_driver = "C:\\Users\\Black Power\\AppData\\Roaming\\0detect browser\\Zorro\\chromedriver.exe"
local_api_token = 'FA70fE'
local_api_port = 56789
 
tag = "Test"
 
chrome_options = Options()
 
profiles = get*profiles_by_tag(local_api_token, local_api_port, tag)
print("Profiles")
print("-" * 20)
print(json.dumps(profiles, indent=3))
print("=" \_ 20)
 
for profile in profiles['list']:
current_browser = start_browser(local_api_token, local_api_port, profile['_id'])
print("Start Browser:", profile['name'])
print("-" \* 20)
print(json.dumps(current_browser, indent=3))
 
    devtools_port = current_browser['devToolsActivePort']
 
    chrome_options.add_experimental_option("debuggerAddress", f"127.0.0.1:{devtools_port}")
    service = Service(chrome_driver)
    driver = webdriver.Chrome(service=service, options=chrome_options)
    driver.get('https://2ip.io')
    time.sleep(10)
    driver.close()
 
    print("=" * 20)
 

Example of an answer

Profiles
--------------------
{
   "list": [
      {
         "_id": "6881f8618d96bb51aa5a323c",
         "name": "Ashlie",
         "tags": [
            {
               "_id": "68825667c91381c0fa0fb3b9",
               "team": "64ba428610851441857c6fc0",
               "user": "661fb21a4af4057ec42317b2",
               "isActive": true,
               "title": "Test",
               "color": "#EBAD36",
               "createdAt": "2025-07-24T15:51:03.323Z",
               "__v": 0
            }
         ],
         "status": 0
      },
      {
         "_id": "6881f7bb8d96bb51aa5a273e",
         "name": "Brody",
         "tags": [
            {
               "_id": "68825667c91381c0fa0fb3b9",
               "team": "64ba428610851441857c6fc0",
               "user": "661fb21a4af4057ec42317b2",
               "isActive": true,
               "title": "Test",
               "color": "#EBAD36",
               "createdAt": "2025-07-24T15:51:03.323Z",
               "__v": 0
            }
         ],
         "status": 0
      },
      {
         "_id": "6881f753e2020e781e38c3a6",
         "name": "Marilyn",
         "tags": [
            {
               "_id": "68825667c91381c0fa0fb3b9",
               "team": "64ba428610851441857c6fc0",
               "user": "661fb21a4af4057ec42317b2",
               "isActive": true,
               "title": "Test",
               "color": "#EBAD36",
               "createdAt": "2025-07-24T15:51:03.323Z",
               "__v": 0
            }
         ],
         "status": 0
      }
   ],
   "pagination": {
      "totalCount": 3,
      "skip": 0,
      "limit": 10
   }
}
====================
Start Browser: Ashlie
--------------------
{
   "success": true,
   "devToolsActivePort": 24385,
   "status": "started"
}
====================
Start Browser: Brody
--------------------
{
   "success": true,
   "devToolsActivePort": 24419,
   "status": "started"
}
====================
Start Browser: Marilyn
--------------------
{
   "success": true,
   "devToolsActivePort": 24544,
   "status": "started"
}
====================