Code Integration Examples
Ready-to-use code examples for connecting BytesFlows static residential proxies with Python, Node.js, and Playwright using per-instance credentials.
BytesFlows static residential proxies support HTTP, HTTPS, and SOCKS5 protocols via per-instance username/password credentials (ip:port:username:password). Replace the RFC 5737 documentation placeholder 203.0.113.45:12345 below with the exact IP, port, username, and password from Dashboard → Static Residential Proxies → Management.
1. Python Examples
Requests Library
import requests
# Replace with your assigned instance IP, port, username, and password
PROXY_HOST = "203.0.113.45"
PROXY_PORT = 12345
PROXY_USER = "bf_user_99a8b1"
PROXY_PASS = "kX89aLmQ21_"
# Use "http://" for HTTP/HTTPS or "socks5h://" (with PySocks) for SOCKS5
proxy_url = f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
proxies = {
"http": proxy_url,
"https": proxy_url,
}
try:
response = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=15)
print("Status:", response.status_code)
print("Egress Info:", response.json())
except Exception as e:
print("Proxy request failed:", e)
Playwright (Python)
from playwright.sync_api import sync_playwright
PROXY_HOST = "203.0.113.45"
PROXY_PORT = 12345 # Replace with your assigned instance port
PROXY_USER = "bf_user_99a8b1"
PROXY_PASS = "kX89aLmQ21_"
with sync_playwright() as p:
browser = p.chromium.launch(
headless=False,
proxy={
"server": f"http://{PROXY_HOST}:{PROXY_PORT}", # or f"socks5://{PROXY_HOST}:{PROXY_PORT}"
"username": PROXY_USER,
"password": PROXY_PASS,
}
)
context = browser.new_context(locale="en-US", timezone_id="America/Los_Angeles")
page = context.new_page()
page.goto("https://ipinfo.io/json")
print(page.inner_text("body"))
browser.close()
2. Node.js / TypeScript Examples
Axios with https-proxy-agent
import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';
// Replace with your assigned instance IP, port, username, and password
const PROXY_HOST = '203.0.113.45';
const PROXY_PORT = 12345;
const PROXY_USER = 'bf_user_99a8b1';
const PROXY_PASS = 'kX89aLmQ21_';
const proxyUrl = `http://${PROXY_USER}:${PROXY_PASS}@${PROXY_HOST}:${PROXY_PORT}`;
const httpsAgent = new HttpsProxyAgent(proxyUrl);
async function testStaticProxy() {
const res = await axios.get('https://ipinfo.io/json', { httpsAgent, timeout: 15000 });
console.log('Egress details:', res.data);
}
testStaticProxy();
Playwright (Node.js)
import { chromium } from 'playwright';
const PROXY_HOST = '203.0.113.45';
const PROXY_PORT = 12345; // Replace with your assigned instance port
const PROXY_USER = 'bf_user_99a8b1';
const PROXY_PASS = 'kX89aLmQ21_';
async function run() {
const browser = await chromium.launch({
proxy: {
server: `http://${PROXY_HOST}:${PROXY_PORT}`, // or `socks5://${PROXY_HOST}:${PROXY_PORT}`
username: PROXY_USER,
password: PROXY_PASS,
},
});
const context = await browser.newContext({
locale: 'en-US',
timezoneId: 'America/Los_Angeles',
});
const page = await context.newPage();
await page.goto('https://ipinfo.io/json');
console.log(await page.innerText('body'));
await browser.close();
}
run();