# Proxies

## Get Proxy Availability

<mark style="color:green;">`GET`</mark>  `/access/availability/static-residential`

Returns a list of countries with available proxies count.

{% hint style="warning" %}
To use this feature, the admin must enable it. This feature requires a minimum total spend of $10000.
{% endhint %}

**Example request:**

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

```
curl -X GET "https://apid.iproyal.com/v1/reseller/access/availability/static-residential" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$api_token = '<your_access_token>';

$url = "https://apid.iproyal.com/v1/reseller/access/availability/static-residential";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_token = '<your_access_token>'
url = 'https://apid.iproyal.com/v1/reseller/access/availability/static-residential'

headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require('https');

const api_token = '<your_access_token>';

const options = {
  hostname: 'apid.iproyal.com',
  path: '/v1/reseller/access/availability/static-residential',
  method: 'GET',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

req.on('error', (error) => {
  console.error('Error:', error.message);
});

req.end();
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ApiRequest {
    public static void main(String[] args) {
        String apiToken = "<your_access_token>";
        String urlString = "https://apid.iproyal.com/v1/reseller/access/availability/static-residential";

        try {
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("X-Access-Token", apiToken);
            connection.setRequestProperty("Content-Type", "application/json");

            int responseCode = connection.getResponseCode();
            System.out.println("Response Code: " + responseCode);

            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder content = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }
                in.close();

                System.out.println("Response Body: " + content.toString());
            } else {
                System.out.println("GET request failed. Response Code: " + responseCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
)

const (
	apiToken = "<your_access_token>"
	url      = "https://apid.iproyal.com/v1/reseller/access/availability/static-residential"
)

func main() {
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("X-Access-Token", apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	fmt.Println("Status Code:", resp.StatusCode)

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}

	var jsonResponse map[string]interface{}
	err = json.Unmarshal(responseBody, &jsonResponse)
	if err != nil {
		log.Fatal("Error unmarshaling JSON:", err)
	}

	fmt.Printf("%+v\n", jsonResponse)
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        string url = "https://apid.iproyal.com/v1/reseller/access/availability/static-residential";

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            HttpResponseMessage response = await client.GetAsync(url);

            Console.WriteLine((int)response.StatusCode);

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Example response:**

```json
{
    "data": [
        {
            "country_code": "DE",
            "country_name": "Germany",
            "available_ips": 2887
        },
        {
            "country_code": "GB",
            "country_name": "United Kingdom",
            "available_ips": 2351
        },
        {
            "country_code": "US",
            "country_name": "United States",
            "available_ips": 1112
        },
        {
            "country_code": "NL",
            "country_name": "Netherlands",
            "available_ips": 1293
        },
        {
            "country_code": "IT",
            "country_name": "Italy",
            "available_ips": 1812
        },
        ...
    ]
}
```

## Change Credentials

<mark style="color:blue;">`POST`</mark>  `/orders/proxies/change-credentials`

**Body Parameters**

<table><thead><tr><th width="257">Name</th><th width="114">Type</th><th>Description</th></tr></thead><tbody><tr><td>order_id</td><td>Integer</td><td>Order id</td></tr><tr><td>proxies</td><td>Array</td><td>List of proxies</td></tr><tr><td>username</td><td>String</td><td>Proxy connection username</td></tr><tr><td>password</td><td>String</td><td>Proxy connection password</td></tr><tr><td>random_password</td><td>Boolean</td><td>Should we assign a random password</td></tr><tr><td>is_reset</td><td>Boolean</td><td>Should we assign a random username and password</td></tr></tbody></table>

**Example request:**

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

```bash
curl -X POST "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json" \
     -d '{
           "order_id": 12345,
           "username": "new_username",
           "password": "new_password",
           "random_password": false,
           "is_reset": true,
           "proxies": ["proxy1", "proxy2"]
         }'
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$api_token = '<your_access_token>';
$order_id = 12345;
$proxies = ['proxy1', 'proxy2'];
$username = 'new_username';
$password = 'new_password';
$random_password = false;
$is_reset = true;

$url = "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ],
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode([
        'proxies' => $proxies,
        'order_id' => $order_id,
        'username' => $username,
        'password' => $password,
        'random_password' => $random_password,
        'is_reset' => $is_reset,
    ])
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_token = '<your_access_token>'
order_id = 12345
proxies = ['proxy1', 'proxy2']
username = 'new_username'
password = 'new_username'
random_password = False
is_reset = True

url = 'https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials'

headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

payload = {
    'order_id': order_id,
    'proxies': proxies,
    'username': username,
    'password': password,
    'random_password': random_password,
    'is_reset': is_reset
}

response = requests.post(url, json=payload, headers=headers)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require('https');

const api_token = '<your_access_token>';
const order_id = 12345;
const proxies = ['proxy1', 'proxy2'];
const username = 'new_username';
const password = 'new_password';
const random_password = false;
const is_reset = true;

const data = JSON.stringify({
    order_id: order_id,
    proxies: proxies,
    username: username,
    password: password,
    random_password: random_password,
    is_reset: is_reset
});

const options = {
    hostname: 'apid.iproyal.com',
    path: '/v1/reseller/orders/proxies/change-credentials',
    method: 'POST',
    headers: {
        'X-Access-Token': api_token,
        'Content-Type': 'application/json',
    }
};

const req = https.request(options, (res) => {
    let responseData = '';

    res.on('data', (chunk) => {
        responseData += chunk;
    });

    res.on('end', () => {
        console.log(responseData);
    });
});

req.on('error', (error) => {
    console.error('Error:', error.message);
});

req.write(data);
req.end();
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String accessToken = "<your_access_token>";
        String url = "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials";

        String requestBody = """
            {
                "order_id": 12345,
                "username": "new_username",
                "password": "new_password",
                "random_password": false,
                "is_reset": true,
                "proxies": ["proxy1", "proxy2"]
            }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("X-Access-Token", accessToken)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println("Response Code: " + response.statusCode());
        System.out.println("Response Body: " + response.body());
    }
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
)

const (
	apiToken = "<your_access_token>"
)

func main() {
	proxies := []string{"proxy1", "proxy2"}
	orderID := 12345
	username := "new_username"
	password := "new_password"
	randomPassword := false
	isReset := true

	requestBody := map[string]interface{}{
		"order_id":        orderID,
		"username":        username,
		"password":        password,
		"random_password": randomPassword,
		"is_reset":        isReset,
		"proxies":         proxies,
	}

	jsonData, err := json.Marshal(requestBody)
	if err != nil {
		log.Fatal("Error marshaling JSON:", err)
	}

	url := "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials"
	req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("X-Access-Token", apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	fmt.Println("Status Code:", resp.StatusCode)

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}

	var jsonResponse map[string]interface{}
	err = json.Unmarshal(responseBody, &jsonResponse)
	if err != nil {
		log.Fatal("Error unmarshaling JSON:", err)
	}

	fmt.Printf("%+v\n", jsonResponse)
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        
        var requestBody = new
        {
            order_id = 12345,
            username = "new_username",
            password = "new_password",
            random_password = false,
            is_reset = true,
            proxies = new string[] { "proxy1", "proxy2" }
        };

        string url = "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials";

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);
            
            var jsonData = JsonSerializer.Serialize(requestBody);
            var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await client.PostAsync(url, content);

            Console.WriteLine((int)response.StatusCode);

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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://docs.iproyal.com/proxies/isp/api/proxies.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.
