Browser Automation API
The Browser Automation API enables developers to programmatically launch and control isolated browser workspaces for testing, quality assurance, web application development, repetitive workflow automation, and enterprise integrations.
Starts an isolated browser workspace and returns a WebSocket endpoint compatible with Puppeteer and Playwright for browser automation and testing.
Getting Started
Univex-Space provides a local HTTP server that runs on port 49559 while the Launcher is open.
Endpoints
Lists all local browser workspaces.
Authorization: Bearer univex_live_...Starts a workspace and returns the WebSocket endpoint for Puppeteer/Playwright.
{
"success": true,
"data": {
"success": true,
"pid": 14202,
"profile_dir": "C:\\UnivexSpace\\profiles\\my_profile",
"message": "Browser launched...",
"ws_endpoint": "ws://127.0.0.1:49211/devtools/browser/..."
}
}Stops the running browser instance.
{ "pid": 14202 }Browser Automation Scripts
Below are complete examples of how to connect to the Univex Launcher programmatically. The PowerShell script acts as an interactive launcher, which then spawns individual Node.js/Playwright instances for each profile.
How to Use
- Install Node.js: Ensure you have Node.js installed on your machine.
- Get the Files: Save the two files below into a folder. (Tip: These files are automatically downloadable from the Univex Launcher desktop app by clicking "Download Scripts"!)
- Install Dependencies: Run this command in your terminal to install the required libraries:
npm install playwright node-fetch@2 - Run the Interactive Menu: Open PowerShell in that folder and execute the script:
.\automation.ps1 - Enter your Token: Generate API Token from Web Dashboard and Paste your Univex API Token when prompted. The script will remember it for future runs!
- Select Profiles: You'll see a list of your local profiles and their assigned proxies. Enter the numbers you want to launch (e.g.
1,1,3,4, orall) and hit Enter.
const { chromium } = require('playwright');
const fetch = require('node-fetch');
async function runUnivexAutomation() {
const arg = process.argv[2];
const tokenArg = process.argv[3];
const token = tokenArg || 'YOUR_API_TOKEN';
let headers = { 'Authorization': `Bearer ${token}` };
// 1. Fetch available profiles
const profilesRes = await fetch('http://127.0.0.1:49559/api/v1/profiles', { headers });
if (!profilesRes.ok) {
console.error("Failed to fetch profiles:", await profilesRes.text());
return;
}
const profilesData = await profilesRes.json();
if (!profilesData.profiles || profilesData.profiles.length === 0) {
console.error("No profiles found on this machine!");
return;
}
// Find profile by ID or Name
let targetProfile = profilesData.profiles.find(p => p.file_id === arg);
if (!targetProfile) {
targetProfile = profilesData.profiles.find(p => {
try {
const payload = JSON.parse(p.payload_json);
const name = payload.profile ? payload.profile.name : payload.name;
return name.toLowerCase() === arg.toLowerCase();
} catch (e) { return false; }
});
}
if (!targetProfile) {
console.error(`Could not find a profile matching "${arg}"`);
return;
}
const targetProfileId = targetProfile.file_id;
console.log(`Starting Profile ID: ${targetProfileId}`);
// 2. Ask the Univex Desktop App to securely launch the profile
const res = await fetch(`http://127.0.0.1:49559/api/v1/profiles/${targetProfileId}/start`, {
method: 'POST',
headers
});
const data = await res.json();
if (!res.ok) {
console.error("Failed to start profile:", data.error || data);
return;
}
console.log("WebSocket Endpoint:", data.data.ws_endpoint);
// 3. Playwright connects to the securely launched browser
const browser = await chromium.connectOverCDP(data.data.ws_endpoint);
const contexts = browser.contexts();
let page;
if (contexts.length > 0 && contexts[0].pages().length > 0) {
page = contexts[0].pages()[0];
} else {
page = await browser.newPage();
}
console.log("Checking IP address...");
try {
await page.goto('https://api.ipify.org?format=json', { timeout: 15000 });
const ipText = await page.textContent('body');
const ipData = JSON.parse(ipText);
console.log(`Exit IP: ${ipData.ip}`);
} catch (e) {
console.log(`Exit IP: (could not determine - ${e.message})`);
}
console.log("Navigating to whoer...");
await page.goto('https://browserscan.net');
}
runUnivexAutomation();$ErrorActionPreference = "Stop"
$jsFile = "automation.js"
$jsContent = Get-Content $jsFile -Raw
$savedToken = ""
if ($jsContent -match "const token = tokenArg \|\| '([^']+)';") {
$savedToken = $matches[1]
}
if (-not [string]::IsNullOrWhiteSpace($savedToken) -and $savedToken -ne 'YOUR_API_TOKEN') {
Write-Host "API Token present in automation.js." -ForegroundColor Green
$token = $savedToken
} else {
$token = Read-Host "Please enter your Univex API Token"
if ([string]::IsNullOrWhiteSpace($token)) {
Write-Host "API Token is required." -ForegroundColor Red
exit
}
$newJsContent = $jsContent -replace "const token = tokenArg \|\| '[^']*';", "const token = tokenArg || '$token';"
Set-Content -Path $jsFile -Value $newJsContent -NoNewline
}
$headers = @{ "Authorization" = "Bearer $token" }
Write-Host "Fetching available profiles from Univex Launcher..." -ForegroundColor Cyan
$response = Invoke-RestMethod -Uri "http://127.0.0.1:49559/api/v1/profiles" -Method Get -Headers $headers
Write-Host "Available Profiles:"
$profiles = @($response.profiles)
for ($i = 0; $i -lt $profiles.Count; $i++) {
$p = $profiles[$i]
$payload = $p.payload_json | ConvertFrom-Json
$prof = if ($null -ne $payload.profile) { $payload.profile } else { $payload }
Write-Host " [$($i + 1)] $($prof.name) (ID: $($p.file_id))"
}
$selection = Read-Host "Enter the number(s) to launch (e.g., '1', '1,3', or 'all')"
# ... Selection parsing logic here ...
foreach ($id in $selectedIds) {
Start-Process node -ArgumentList "automation.js", $id, $token
}The Browser Automation API is intended for legitimate software testing, browser automation, workflow automation, and enterprise integrations. Customers are responsible for ensuring their use complies with applicable laws and the terms of the websites and services they access.