Making Requests

Basic Query
A basic query is simple and straightforward. All you need to provide are your username and password. No additional parameters are necessary. When you execute this query, the request will be routed through a random IP address (proxy). Each subsequent request will automatically rotate and use a different proxy for a fresh connection.
In this example, a query to ip.homeip.io is performed from a random IP:
cURL
PHP
Python
Java
C#
Ruby
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME:PASSWORD" http://ip.homeip.io
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$proxy = 'pr.homeip.io:7777';
$query = curl_init('http://ip.homeip.io');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "username=$username:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
entry = ('http://username=%s:%[email protected]:7777' %
(username, password))
query = urllib.request.ProxyHandler({
'http': entry,
'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('http://ip.homeip.io').read())
package example;
import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;
public class Example {
public static void main(String[] args) throws Exception {
HttpHost entry = new HttpHost("pr.homeip.io", 7777);
String query = Executor.newInstance()
.auth(entry, "username=USERNAME", "PASS")
.execute(Request.Get("http://ip.homeip.io").viaProxy(entry))
.returnContent().asString();
System.out.println(query);
}
}
using System;
using System.Net;
class Example
{
static void Main()
{
var client = new WebClient();
client.Proxy = new WebProxy("pr.homeip.io:7777");
client.Proxy.Credentials = new NetworkCredential("username=USERNAME", "PASSWORD");
Console.WriteLine(client.DownloadString("http://ip.homeip.io"));
}
c
require 'uri'
require 'net/http'
uri = URI.parse('http://ip.homeip.io')
proxy = Net::HTTP::Proxy('pr.homeip.io', 7777, 'username=USERNAME', 'PASSWORD')
req = Net::HTTP::Get.new(uri.path)
result = proxy.start(uri.host,uri.port) do |http|
http.request(req)
end
puts result.body
Replace USERNAME and PASSWORD with your actual proxy user credentials.
Utilizing the Backconnect Proxy for Geo-specific Requests
With HomeIP's backconnect proxy (pr.homeip.io:7777), you have the flexibility to tailor your requests based on geographic location, down to the specific country or city. This is achieved by simply adding specific parameters to your username. Additionally, this method seamlessly integrates session control to maintain the same proxy for multiple requests.
Sample Credentials
To illustrate, here's how you'd structure your credentials:
1. Basic Connection
username=USERNAME:PASSWORD
2. Targeting a Specific Country (e.g., France)
username=USERNAME+country=fr:PASSWORD
3. Targeting a Specific City (e.g., London, UK)
username=USERNAME+country=uk+state=england+city=london:PASSWORD
4. Implementing Session Control
username=USERNAME+session=YourUniqueSessionID:PASSWORD
Replace 'YourUniqueSessionID' with a unique identifier for session consistency.

Query parameters

Parameter
Description
username
Username
country
Case insensitive country code in 2-letter 3166-1 alpha-2 format. For example, DE for Germany, GB for the United Kingdom, TH for Thailand.
city
Case insensitive city name in English. This parameter must be accompanied bycountry and state for better accuracy, for example, country=uk+state=england+city=london for London, United Kingdom.
state
Case insensitive US state name with us_ in the beginning, for example, country=us+state=texas.
rotation
Session ID to keep the same IP with upcoming queries. The session expires in 10 minutes. After that, a new IP address is assigned to that session ID. Random string, 0-9, and A-Z characters are supported.
session
The session time parameter keeps the same IP for a certain period. The maximum session time is 30 minutes.
password
Password