GET
Rotate proxies to get new IP addresses
Rotates the specified proxies to assign them new IP addresses.
Unlike other operations, rotating a proxy doesn't involve calling a specific API endpoint. Instead, you initiate a rotation by making any HTTP request through the proxy you wish to rotate, using a special username format.
To rotate a proxy, set the proxy username to rotate=must
and send any request through
the proxy. The proxy server will intercept this request, perform the rotation, and return the
response body if successful.
We use api.ipify.org
as an example because it returns the IP address of the requestor,
allowing you to verify that the rotation was successful and immediately see the new IP address.
Example using cURL:
curl -x http://rotate=must:PROXY_PASSWORD@PROXY_REGION.globalbyte.io:10000 any_url
Examples:
curl --proxy http://rotate=must:PROXY_PASSWORD@PROXY_REGION.globalbyte.io:10000 http://api.ipify.org
const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');
const proxyUser = 'rotate=must';
const proxyPass = 'PROXY_PASSWORD';
const proxyHost = 'PROXY_REGION.globalbyte.io';
const proxyPort = '10000';
const targetUrl = 'http://api.ipify.org';
const proxyUrl = `http://${proxyUser}:${proxyPass}@${proxyHost}:${proxyPort}`;
const agent = new HttpsProxyAgent(proxyUrl);
axios.get(targetUrl, {
httpsAgent: agent,
})
.then(response => {
console.log(`Status Code: ${response.status}`);
console.log(`New IP: ${response.data}`);
})
.catch(error => {
if (error.response) {
console.error(`Proxy Error: ${error.response.status}`);
console.error(error.response.data);
} else {
console.error(`Error: ${error.message}`);
}
});
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import kong.unirest.UnirestException;
public class RotateProxy {
public static void main(String[] args) {
String proxyUser = "rotate=must";
String proxyPass = "PROXY_PASSWORD";
String proxyHost = "PROXY_REGION.globalbyte.io";
int proxyPort = 10000;
String targetUrl = "http://api.ipify.org";
Unirest.config().proxy(proxyHost, proxyPort, proxyUser, proxyPass);
try {
HttpResponse<String> response = Unirest.get(targetUrl).asString();
System.out.println("Status Code: " + response.getStatus());
System.out.println("New IP: " + response.getBody());
} catch (UnirestException e) {
System.err.println("Error: " + e.getMessage());
} finally {
Unirest.shutDown();
}
}
}
import requests
proxy_user = "rotate=must"
proxy_pass = "PROXY_PASSWORD"
proxy_host = "PROXY_REGION.globalbyte.io"
proxy_port = "10000"
target_url = "http://api.ipify.org"
proxy_url = f"http://{proxy_user}:{proxy_pass}@{proxy_host}:{proxy_port}"
proxies = {
"http": proxy_url,
"https": proxy_url,
}
try:
response = requests.get(target_url, proxies=proxies)
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
<?php
$proxyUser = 'rotate=must';
$proxyPass = 'PROXY_PASSWORD';
$proxyHost = 'PROXY_REGION.globalbyte.io';
$proxyPort = 10000;
$targetUrl = 'http://api.ipify.org';
$proxyUrl = "http://{$proxyHost}:{$proxyPort}";
$proxyAuth = "{$proxyUser}:{$proxyPass}";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $targetUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_PROXY => $proxyUrl,
CURLOPT_PROXYUSERPWD => $proxyAuth,
]);
$response = curl_exec($curl);
$err = curl_error($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo "Status Code: " . $httpCode . "\n";
echo "Response Body: " . $response;
}
Replace PROXY_PASSWORD
with the actual password of the proxy you whish to
rotate, PROXY_REGION
with the proxy region (the first part of the proxy host), and any_url
with any valid URL.
Responses
Code: 200
Description: Successfully rotated the proxy. Returns the requested URL.
Content Type: text/plain
Code: 429
Description: Rotation request was made too recently. Proxies can only be rotated once every 3 minutes.
Content Type: text/plain
Code: 500
Description: An internal server error occurred during the rotation process.
Content Type: text/plain
Code: 401
Description: Unauthorized. The provided proxy password is invalid.
Content Type: text/plain
172.59.208.148
Rotation requested too fast; allowed at most every 3 minutes
Internal Server Error
Unauthorized