# Making Requests

#### **Basic query**

Basic query only requires passing `username` and `password`. No other parameters are needed. Such a query will result in the request being made from a random IP address (proxy). Every new request will use a different proxy.

#### Code examples

In this example, a query to `ip.oxylabs.io/location` is performed from a random IP:

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$proxy = 'pr.oxylabs.io:7777';
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "customer-$username:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
entry = ('http://customer-%s:%s@pr.oxylabs.io:7777' %
    (username, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
```

{% endtab %}

{% tab title="Java" %}

```java
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.oxylabs.io", 7777);
        String query = Executor.newInstance()
            .auth(entry, "customer-USERNAME", "PASS")
            .execute(Request.Get("http://ip.oxylabs.io/location").viaProxy(entry))
            .returnContent().asString();
        System.out.println(query);
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var client = new WebClient();
        client.Proxy = new WebProxy("pr.oxylabs.io:7777");
        client.Proxy.Credentials = new NetworkCredential("customer-USERNAME", "PASSWORD");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
c
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'

uri = URI.parse('https://ip.oxylabs.io/location')
proxy = Net::HTTP::Proxy('pr.oxylabs.io', 7777, 'customer-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
```

{% endtab %}
{% endtabs %}

A single backconnect proxy (`pr.oxylabs.io:7777)`enables you to choose a specific country or city proxy via additional parameters in the username. This approach also supports session control. Here is a sample of credentials:

`customer-USERNAME-cc-US-city-CITY-sessid-abcde12345:PASSWORD`

`customer-USERNAME-cc-US-city-CITY-sessid-abcde12345-sesstime-5:PASSWORD`

Below is a breakdown of the structure:

<figure><img src="https://63892162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FVQLieFQN8pPNeUfWMjhU%2FCode%20explained%20for%20Resi%20documentation%20(upd%202024-03).png?alt=media&#x26;token=5b48bede-2e1c-4676-9ba9-37bb0cbf3fc4" alt=""><figcaption></figcaption></figure>

#### Query parameters

| Parameter                                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <mark style="background-color:green;">**`customer`**</mark> | Username                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `cc`                                                        | Case insensitive country code in 2-letter [**3166-1 alpha-2 format**](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). For example, `DE` for Germany, `GB` for the United Kingdom, `TH` for Thailand. You can find more details on how to use country-specific proxies [**here**](https://developers.oxylabs.io/proxies/residential-proxies/broken-reference).                                                                                                                              |
| `city`                                                      | Case insensitive city name in English. This parameter must be accompanied by `cc` for better accuracy, for example, `cc-GB-city-london` for London, United Kingdom; `cc-DE-city-berlin` for Berlin, Germany. For a city with more than two words, replace space with `_`, for example, `city-st_petersburg` or `city-rio_de_janeiro`. Click [**here**](https://developers.oxylabs.io/proxies/residential-proxies/location-settings/select-city) for more information on city-level targeting. |
| `st`                                                        | Case insensitive US state name with us\_ in the beginning, for example, `us_california`, `us_illinois`. [**Click here** ](https://developers.oxylabs.io/proxies/residential-proxies/location-settings/select-state)for more information on state-level targeting.                                                                                                                                                                                                                             |
| `sessid`                                                    | 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.                                                                                                                                                                                                                                                                                   |
| `sesstime`                                                  | The session time parameter keeps the same IP for a certain period. The maximum session time is 30 minutes.                                                                                                                                                                                                                                                                                                                                                                                    |
| <mark style="background-color:green;">**`password`**</mark> | Password                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

&#x20;   \- required parameter


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/proxies/residential-proxies/making-requests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
