Proxy Rotation Workflow
FreshComplete workflow for implementing automated proxy rotation.
Overview
Strategy 1: On-Demand Rotation
Use when you need to rotate IPs manually or triggered by your application.
Implementation
javascript
async function rotateProxy(modemIndex) {
const response = await fetch(
`http://${SERVER_IP}/api/change_ip?index=${modemIndex}`,
{
headers: { 'Authorization': `Token ${API_TOKEN}` }
}
);
if (response.ok) {
console.log(`Modem ${modemIndex} rotated successfully`);
return true;
}
return false;
}
// Rotate modem 1
await rotateProxy(1);Python Implementation
python
import requests
def rotate_proxy(modem_index):
url = f"http://{SERVER_IP}/api/change_ip"
params = {"index": modem_index}
headers = {"Authorization": f"Token {API_TOKEN}"}
response = requests.get(url, params=params, headers=headers)
return response.ok
# Rotate modem 1
rotate_proxy(1)Strategy 2: Scheduled Rotation
Set automatic rotation intervals for hands-off operation.
Configuration Options
| Interval | API Parameter | Example |
|---|---|---|
| Every X days | day=X | day=1 (daily) |
| Every X hours | hour=X | hour=4 (every 4 hours) |
| Every X minutes | min=X | min=30 (every 30 min) |
Setup All Modems to Rotate Every Hour
bash
curl -H "Authorization: Token YOUR_API_TOKEN" \
"http://YOUR_SERVER_IP/api/custom_rot?index=all&hour=1"Setup Specific Modem to Rotate Every 30 Minutes
bash
curl -H "Authorization: Token YOUR_API_TOKEN" \
"http://YOUR_SERVER_IP/api/custom_rot?index=3&min=30"Strategy 3: URL-Based Rotation
Rotate by simply visiting a URL - useful for browser automation.
Dedicated Proxy URL
http://SERVER_IP/api/change_ip?index=1&token=YOUR_API_TOKENShared Proxy URL
http://SERVER_IP/api/sproxy/rotate?proxy_port=35501&proxy_pass=mypasswordSelenium Integration
python
from selenium import webdriver
def rotate_and_refresh(driver, rotation_url, target_url):
# Hit rotation URL
driver.get(rotation_url)
# Wait for rotation
import time
time.sleep(5)
# Navigate to target
driver.get(target_url)Verification
After rotation, verify the new IP:
javascript
async function verifyRotation(modemIndex, previousIP) {
const response = await fetch(
`http://${SERVER_IP}/api/getinfo`,
{
headers: { 'Authorization': `Token ${API_TOKEN}` }
}
);
const data = await response.json();
const modem = data.modems.find(m => m.index === modemIndex);
if (modem.public_ip !== previousIP) {
console.log(`New IP: ${modem.public_ip}`);
return true;
}
console.log('IP unchanged - rotation may have failed');
return false;
}Best Practices
- Wait after rotation - Allow 3-5 seconds for the new IP to propagate
- Verify success - Always check that the IP actually changed
- Handle failures - Implement retry logic for failed rotations
- Monitor usage - Track rotation frequency to avoid carrier issues