CAPTCHA solving is now available in Nstbrowser, with support for 5 CAPTCHA types.

Learn More

πŸš€

Platform Proxy is live in Nstbrowser β€” built-in proxies from$0.4/GB.

Start Now

  • Pricing
  • Documentation
EN
Contact

Β© 2026 NST LABS TECH LTD. ALL RIGHTS RESERVED

Products

Anti-Detect Browser
Nstbrowser RPA
AI Agent Skills
Proxy
Cloudflare Bypass
Web Unblocker

Solutions

Cloud Fingerprint Browser
Multi-Account Management
Web Scraping & Automation
Anti-Bot Solutions
Data Isolation for Enterprise Security
Claude AI IP Checker

Resources

Pricing
Download
RPA Marketplace
Affiliate Program
Partners
Blog
Release Notes

Support

Contact

Documentation

Legal

Terms
Privacy Policy
Cookies Policy

ProductsSolutionsResourcesSupportLegal

ProductsSolutionsResources

SupportLegal

Β© 2026 NST LABS TECH LTD. ALL RIGHTS RESERVED

Back to Blog
Browser Automation API: Profile Management Guide β€” Nstbrowser cover
browser-automationprofile-management

Browser Automation API for Profile Management: A Practical Guide

Build a clear Nstbrowser API v2 lifecycle for saved profiles: prepare, launch, inspect connection details, attach automation, and stop the browser.
Nov 10, 2026Carlos Rivera

TL;DR

  • Profile management and page automation are separate parts of the browser lifecycle.
  • Nstbrowser recommends API v2 for new Client and Docker integrations.
  • Use a real Profile ID and the documented x-api-key header.
  • Validate the HTTP response and application response before reading the debugger URL.
  • Stopping a running browser is different from deleting its saved Profile.
  • The example below requires a running service, a valid key, and an authorized test Profile; live authenticated execution was not available for this guide.

What Does a Browser Automation API Manage?

A browser automation API for profile management controls browser environments and their lifecycle, while an automation framework performs page-level work. Keeping these roles separate makes failures easier to diagnose. Your application should know whether it failed to start an environment, connect to the browser, load a page, or satisfy a business condition.

For example, an authorized catalog QA task might select an existing Profile, launch it, inspect a page title, and stop it. Creating a new Profile for every retry would introduce unnecessary state. Deleting a Profile after each check would be inappropriate when the workflow depends on persistent account data.

Map the Profile Lifecycle Before Writing Code

Represent the lifecycle as explicit states: prepared, launching, running, attached, verified, and stopped. Store the Profile ID as the stable identifier for the task. Keep the environment's saved configuration separate from temporary debugging endpoints returned for a running browser.

Operation Role in the workflow Validation
Create or select Profile Establish the intended environment Confirm ownership, group, and configuration
Launch saved Profile Start a browser for that environment Check response status and returned data
Read connection details Locate the running browser Use the current response, not a cached URL
Attach framework Control pages Check connection and context selection
Stop browser End this execution Confirm the browser is stopped

The API v2 introduction gives the default HTTP base as http://localhost:8848/api/v2. The client or container must be reachable from the process making the request. A container's localhost identifies that container, so deployment topology matters.

Discover Profiles Without Treating Names as IDs

Select a Profile you are authorized to run and record its actual ID. For inventory traversal, the GetProfilesByCursor documentation is the current starting point. Do not invent pagination parameters from another vendor's API, and do not assume the first record returned is the intended environment.

How to Start and Stop a Nstbrowser Profile

Use the documented launch and stop routes with the same Profile ID, and validate both the transport and application result. The following standard-library Python example deliberately demonstrates lifecycle management only. It does not create profiles, collect private data, or claim that a successful launch completes a website task.

Prepare the Service and Test Environment

Start the Nstbrowser client or your configured Docker service, sign in as required, generate an API Key, and choose a non-production Profile. Set NST_API_KEY and NST_PROFILE_ID through your local environment or secret-management workflow. The default base is suitable only when the Python process can reach that same machine's service.

This example has not been authenticated against a live Nstbrowser Profile because a reachable local service and test credentials were unavailable.

Launch, Inspect, and Stop the Saved Profile

The StartBrowser endpoint uses POST on /browsers/{profileId}. Its returned data includes webSocketDebuggerUrl. Stopping uses DELETE on that browser route, as documented by StopBrowser.

python Copy
import json
import os
from urllib.error import HTTPError, URLError
from urllib.parse import quote
from urllib.request import Request, build_opener, ProxyHandler

key = os.environ["NST_API_KEY"]
profile_id = quote(os.environ["NST_PROFILE_ID"], safe="")
base = "http://localhost:8848/api/v2"
opener = build_opener(ProxyHandler({}))  # Local service only.

def call(method, path):
    request = Request(base + path, method=method,
                      headers={"x-api-key": key, "Accept": "application/json"})
    try:
        with opener.open(request, timeout=30) as response:
            result = json.load(response)
    except HTTPError as error:
        raise RuntimeError(f"HTTP failure: {error.code}") from None
    except URLError:
        raise RuntimeError("Local API connection failed") from None
    if not isinstance(result, dict) or result.get("code") != 0:
        raise RuntimeError("API returned an unsuccessful application result")
    return result.get("data")

path = f"/browsers/{profile_id}"
started = False
try:
    data = call("POST", path)
    started = True
    if not isinstance(data, dict) or not data.get("webSocketDebuggerUrl"):
        raise RuntimeError("Launch response did not include a debugger URL")
    # Pass this URL directly to your supported automation framework.
    # Do not publish the URL or assume a website task has completed.
    debugger_url = data["webSocketDebuggerUrl"]
    print("Launch confirmed; debugger URL received")
finally:
    if started:
        call("DELETE", path)
        print("Browser stop confirmed")

This sample closes the browser immediately after checking connection data. Add your framework operation inside the try block when you have validated the lifecycle. If a launch request times out, inspect running browsers before retrying: the server may have started the browser even though your process did not receive a response. The script cannot resolve that ambiguous state automatically.

Attach Page Automation as a Separate Stage

For Chromium workflows, Playwright documents connectOverCDP. It also notes limitations compared with a native Playwright protocol connection. Confirm that the attached context is the intended environment before creating or selecting a page. Use locators based on meaningful page attributes and check a visible result after each important operation.

Treat an HTTP response and a JSON response as separate evidence. HTTP status codes describe request-level outcomes; your application must also validate the API's documented result and expected data.

Why Use Nstbrowser for Profile Lifecycle Automation?

Nstbrowser exposes a documented API for managing saved environments and running browsers. API v2 supports both the client and Docker deployment paths. Returned debugging information provides a handoff from environment management to page automation. That separation helps teams reuse existing environments without rebuilding their complete browser-control layer. It is useful when your workflow needs explicit lifecycle control and a clear place to validate each stage.

  • Defined lifecycle operations: Keep launch and stop behavior visible in the application.
  • Reusable Profile identity: Associate a task with an intentional saved environment.
  • Framework integration: Connect page automation after the environment is running.
Try for Free >

Build Error Handling Around the First Failed Stage

Record operation name, Profile ID, timestamp, request duration, and a redacted error classification. Avoid logging API keys, cookies, or raw debugger URLs. Retry only after checking whether the previous operation changed state. Apply a workload limit based on measured resources and current service allowances instead of launching every available Profile at once.

Begin with a single authorized test environment. Once launch, page inspection, and cleanup are independently verified, add task scheduling and broader inventory handling.

Try for Free >

FAQ

Q: Is a Profile management API the same as an MCP server?

No. An HTTP API does not establish that an MCP server exists. This guide describes the documented API and framework connection path.

Q: Does browser startup prove the target website loaded?

No. Startup, framework attachment, navigation, and the website's final success condition require separate checks.

Q: Does stopping the browser delete its Profile?

No. Stopping a running browser and deleting a saved Profile are separate operations. Choose cleanup behavior according to the intended persistence model.

Q: Was the lifecycle example executed against a real account?

No. A reachable local service and test credentials were unavailable, so authenticated execution and framework attachment remain prerequisites to validate in your environment.

More
How to save and reuse login state in Playwright
playwrightbrowser-automation
How to Save and Reuse Login State in Playwright
Save Playwright login state for fresh test contexts, compare it with persistent contexts, and fix expired sessions, missing tokens, and parallel test conflicts.
Nov 25, 2026Carlos Rivera
Best Agentic Browsers: A Workflow-Based Selection Guide β€” Nstbrowser cover
ai-agentbrowser-automation
Best Agentic Browsers for Web Tasks and Automation
Compare Nstbrowser AI Agent, Browser Use, Stagehand, and Chrome DevTools MCP by session control, execution model, debugging, and evaluation criteria.
Nov 11, 2026Carlos Rivera
Antidetect Browser API Troubleshooting: Common Errors & Fixes β€” Nstbrowser cover
browser-automationprofile-management
Antidetect Browser API Troubleshooting: Common Errors and Fixes
Troubleshoot an antidetect browser API by isolating service, authentication, request, profile startup, and framework attachment failures in order.
Nov 10, 2026Carlos Rivera
Browser Automation API: Profile Management Guide β€” Nstbrowser cover
browser-automationprofile-management
Browser Automation API for Profile Management: A Practical Guide
Build a clear Nstbrowser API v2 lifecycle for saved profiles: prepare, launch, inspect connection details, attach automation, and stop the browser.
Nov 10, 2026Carlos Rivera
Browser Multi-Window Synchronizer: How It Works & When to Use It β€” Nstbrowser cover
browser-automationprofile-management
Browser Multi-Window Synchronizer: How It Works and When to Use It
Understand browser multi-window synchronization, suitable tasks, common alignment problems, and how to evaluate Nstbrowser for coordinated workflows.
Nov 10, 2026Carlos Rivera
Bulk Create Browser Profiles: A Practical Nstbrowser Guide β€” Nstbrowser cover
browser-automationprofile-management
How to Bulk Create Browser Profiles in Nstbrowser
Learn how to bulk create browser profiles in Nstbrowser, assign groups and proxies, validate a pilot batch, and avoid common setup mistakes.
Nov 10, 2026Carlos Rivera
Catalogue