How to Use AdsPower with Python: Automation Guide
Take a Quick Look
Learn how to use AdsPower with Python via the Local API, Selenium, and Playwright. Step-by-step setup, code examples, and multi-account automation tips.
🔥 Limited-Time Offer! Save extra 10% off on your first monthly plan with code: Anitdetect10
Sign upHow to Use AdsPower with Python: Automation Guide
AdsPower is an anti-detect browser that creates isolated browser profiles with unique fingerprints, so each session looks like a separate real device. Python is a general-purpose programming language with a rich ecosystem for HTTP requests and browser automation. Together, they let you drive dozens or hundreds of isolated profiles programmatically — no manual clicking required.
This guide explains how the two products work together, how to set up the connection, and how to write practical Python scripts using Selenium and Playwright. It also covers the problems this combination solves and the pitfalls to avoid.
Why combine AdsPower with Python?
Managing multiple accounts manually is slow and error-prone. AdsPower solves the identity problem: each profile has its own Canvas, WebGL, User Agent, and IP configuration, so accounts do not get linked. Python solves the scale problem: it can start profiles, attach automation drivers, perform tasks, and close profiles in a loop.
The combination is useful for:
- E-commerce operations — bulk listing updates, price checks, and order monitoring across seller accounts.
- Social media marketing — scheduled posting and engagement across many profiles.
- Affiliate marketing — running CPA campaigns without triggering platform bans.
- Web scraping — collecting data from sites that block repeated requests from a single fingerprint.
- QA and testing — verifying how a site behaves under different device fingerprints.
How AdsPower and Python connect
AdsPower runs a Local API on your machine. By default it listens on http://local.adspower.net:50325 (or http://127.0.0.1:50325). Python scripts send HTTP requests to this API to start and stop browser profiles. When a profile starts, the API returns connection details — a WebDriver path and a debugger address for Selenium, or a WebSocket endpoint for Playwright and Puppeteer.
Your Python script then attaches an automation driver to that already-running browser. This is the key difference from launching a normal browser: you are not creating a new browser instance, you are connecting to the one AdsPower opened with the correct fingerprint and proxy.
Prerequisites

How to Use AdsPower with Python: Automation Guide - Prerequisites.
Before writing code, make sure you have:
- AdsPower installed and running on the same machine as your Python script (or reachable over the network).
- Local API enabled in AdsPower settings.
- An API key if your Local API installation requires one. You can find it in the API section of the AdsPower client.
- A profile created in AdsPower. Note its
user_id(also calledprofile_idin newer API versions). - Python 3.10 or newer installed.
- Required packages installed:
pip install requests selenium
# or for Playwright
pip install requests playwright
playwright install chromium
If you prefer a typed SDK, there is also a community-maintained adspower package on PyPI that wraps the Local API with synchronous and asynchronous clients. It is not required, but it can reduce boilerplate for profile and proxy management.
Step-by-step: AdsPower with Python Selenium
The most common setup uses requests to call the Local API and selenium to control the browser.
1. Start a profile via the Local API
import requests
ads_id = "your_profile_id"
api_key = "your_api_key"
open_url = f"http://local.adspower.net:50325/api/v1/browser/start?user_id={ads_id}"
headers = {"Authorization": f"Bearer {api_key}"}
resp = requests.get(open_url, headers=headers).json()
if resp["code"] != 0:
raise RuntimeError(f"Failed to start profile: {resp['msg']}")
print("Profile started")
2. Attach Selenium to the running browser
The API response contains data.webdriver (the ChromeDriver path) and data.ws.selenium (the debugger address). For Selenium 4, use the Service class:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
chrome_driver = resp["data"]["webdriver"]
debugger_address = resp["data"]["ws"]["selenium"]
service = Service(executable_path=chrome_driver)
options = Options()
options.add_experimental_option("debuggerAddress", debugger_address)
driver = webdriver.Chrome(service=service, options=options)
driver.get("https://www.browserscan.net/")
print(driver.title)
3. Close the profile
Always stop the profile when you are done, otherwise it stays open and consumes resources:
driver.quit()
close_url = f"http://local.adspower.net:50325/api/v1/browser/stop?user_id={ads_id}"
requests.get(close_url, headers=headers)
Step-by-step: AdsPower with Python Playwright
Playwright uses a WebSocket endpoint instead of a debugger address. The flow is similar, but you connect over CDP.
import requests
from playwright.sync_api import sync_playwright
ads_id = "your_profile_id"
api_key = "your_api_key"
open_url = f"http://local.adspower.net:50325/api/v1/browser/start?user_id={ads_id}"
headers = {"Authorization": f"Bearer {api_key}"}
resp = requests.get(open_url, headers=headers).json()
ws_endpoint = resp["data"]["ws"]["puppeteer"]
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(ws_endpoint)
context = browser.contexts[0]
page = context.pages[0] if context.pages else context.new_page()
page.goto("https://example.com")
print(page.title())
browser.close()
requests.get(f"http://local.adspower.net:50325/api/v1/browser/stop?user_id={ads_id}", headers=headers)
Note that the WebSocket key is named puppeteer even when you use Playwright. This is because AdsPower exposes a Chrome DevTools Protocol endpoint that both tools can consume.
Practical example: rotating profiles for scraping
A common pattern is to loop through a list of profile IDs, scrape one page per profile, and close each profile before moving on. This keeps resource usage predictable and avoids fingerprint mixing.
import requests, time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
API = "http://local.adspower.net:50325"
API_KEY = "your_api_key"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
PROFILES = ["profile_1", "profile_2", "profile_3"]
def scrape(profile_id, url):
start = requests.get(f"{API}/api/v1/browser/start?user_id={profile_id}", headers=HEADERS).json()
if start["code"] != 0:
print(f"Skip {profile_id}: {start['msg']}")
return None
service = Service(executable_path=start["data"]["webdriver"])
options = Options()
options.add_experimental_option("debuggerAddress", start["data"]["ws"]["selenium"])
driver = webdriver.Chrome(service=service, options=options)
try:
driver.get(url)
time.sleep(2)
return driver.title
finally:
driver.quit()
requests.get(f"{API}/api/v1/browser/stop?user_id={profile_id}", headers=HEADERS)
for pid in PROFILES:
title = scrape(pid, "https://example.com")
print(pid, title)
For larger jobs, you can run several profiles in parallel using threads or asyncio with Playwright. Keep an eye on CPU and memory, and respect the Local API rate limits (AdsPower documents a global limit and stricter limits on certain endpoints like profile listings).
Common pitfalls and how to avoid them
- Forgetting to stop profiles. If your script crashes, profiles may remain open. Wrap browser work in
try/finallyand always call the stop endpoint. - Using the wrong API version. AdsPower has v1 and v2 endpoints. The v1 start/stop endpoints are widely used and stable, but newer SDKs use v2. Check the official Local API documentation for your version.
- Hardcoding API keys. Store keys in environment variables or a secrets manager, especially if scripts run on shared machines.
- Ignoring rate limits. Sending too many requests to the Local API can cause errors. Add small delays or use a rate-aware client.
- Mixing profiles in one browser session. Each profile should have its own driver instance. Do not reuse a driver across profiles.
- Assuming the browser is headless. AdsPower profiles open in normal mode by default. If you need headless operation, configure it in the profile settings or the start request.
When to use AdsPower with Python vs. other tools
If your main goal is simple data collection from sites without strict anti-bot measures, a standard scraping library may be enough. AdsPower with Python becomes valuable when you need fingerprint isolation, proxy rotation, and account persistence at the same time.
For a broader look at data collection methods, see Automated Data Collection: Tools, Methods & Best Practices. If you are comparing anti-detect browsers before committing, the AdsPower vs Undetectable vs Genlogin comparison covers fingerprint quality, automation support, and pricing.
Related reading
- Facebook Login: How to Sign In, Fix Problems, and Stay Secure - Learn how Facebook login works, how to sign in on any device, fix common login problems, recover your account, and keep multiple sessions secure.
- How to Use AdsPower with SMSPool for Multi-Account Verification - Step-by-step guide to pairing AdsPower anti-detect profiles with SMSPool phone verification: setup, API automation, practical examples, and pitfalls.
- AdsPower vs Indigo vs Incogniton: Antidetect Browser Comparison - Compare AdsPower, Indigo, and Incogniton: fingerprints, engines, automation, teamwork, and pricing. Find out which antidetect browser to choose.
Sources and further reading
- Code Samples - Code samples to automate AdsPower with Python, Javascript and Java.Chrome code samplesPython Selenium The demo passed the test in selenium version 3.141.0 import requests,time from selenium import webdriver fro
- adspower - Typed synchronous and asynchronous Python SDK for the AdsPower Local API.
- Proxy-Seller × AdsPower: Web Scraping Tutorial - Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
FAQ
Do I need an API key to use AdsPower with Python?
It depends on your Local API configuration. Some installations allow unauthenticated local requests, while others require a Bearer token. If your requests return an authorization error, add the Authorization: Bearer <api_key> header.
Can I use AdsPower with Python on a remote server?
Yes, but the Local API must be reachable from the server. By default it binds to localhost. For remote setups, you may need to expose the API securely or use a tunneling solution. Some SDKs offer an endpoint rewrite option for Docker or remote topologies.
Which Python automation library works best with AdsPower?
Selenium and Playwright are both officially supported. Selenium is more common in existing scripts; Playwright offers faster execution and built-in async support. Choose based on your team's familiarity and whether you need parallel execution.
How many profiles can I run at once?
The limit depends on your machine's CPU, RAM, and the number of proxies you have. A typical desktop can handle 5–20 concurrent profiles for light tasks. For heavier workloads, distribute across multiple machines or use a cloud-based setup.
Does AdsPower provide a Python SDK?
AdsPower provides code samples and a Local API. A community-maintained typed SDK exists on PyPI, but it is not an official AdsPower product. You can always call the API directly with requests.
Conclusion
AdsPower and Python are a practical pair for anyone managing multiple online identities. AdsPower handles fingerprint isolation and proxy assignment; Python handles orchestration, data processing, and scale. Start with a single profile and a simple Selenium script, then expand to parallel Playwright workers as your needs grow. Keep your API keys secure, always close profiles, and respect rate limits — and you will have a reliable automation pipeline for e-commerce, marketing, scraping, and testing.
