# IPRoyal

{% hint style="info" %}
API documentation: <https://torchlabs.readme.io/>
{% endhint %}

### **How to generate sticky proxies:**

```javascript
const string = (length) => {
  let result = '';
  const characters = 'abcdefghijklmnopqrstuvwxyz1234567890';
  const charactersLength = characters.length;
  for (let i = 0; i < length; i++) {
    result += characters.charAt(Math.floor(Math.random() * charactersLength));
  }
  return result;
};

function proxyGenerationSticky(amount, country, username, password) {
  proxy = [];
  for (var i = 0; i < parseInt(amount); i++) {
    proxy.push(
      `iproyal.x.proxiess.com:12321:${username}:${password}-country-${country.toLowerCase()}_session-${string(8,
      )}_lifetime-1h\n`,
    );
  }
  return proxy.join('');
}
```

* **Session** ( add this under sticky proxy generation )

The \_session- key instructs our routing system to either create or resolve a unique session for the connection. The value assigned to this key must be a random alphanumeric string, precisely **8 characters** in length. This ensures the uniqueness and integrity of the session.

* **Lifetime** ( add this under sticky proxy generation )

The \_lifetime- key directs the router regarding the duration for which the session remains valid. The minimum duration is set at **1 second**, and the maximum extends to **7 days**. It is crucial to note the format here: only one unit of time can be specified. This parameter plays a pivotal role in defining the operational span of a sticky session, balancing between session stability and security needs.

Examples:

```
iproyal.x.proxiess.com:12321:<username>:<password>-country-<country code>_session-<session id>_lifetime-10m
iproyal.x.proxiess.com:12321:<username>:<password>-country-<country code>_session-<session id>_lifetime-1h
iproyal.x.proxiess.com:12321:<username>:<password>-country-<country code>_session-<session id>_lifetime-48h
```

### **How to generate IPRoyal EU sticky proxies:**

```
iproyaleu.x.proxiess.com:12323:<username>:<password>-country-<country code>_session-<session id>_lifetime-1h
```

### **How to generate IPRoyal Asia sticky proxies:**

```
iproyalasia.x.proxiess.com:12322:<username>:<password>-country-<country code>_session-<session id>_lifetime-1h
```

### **How to generate rotating proxies:**

```javascript
function proxyGenerationRotating(amount, country, username, password) {
  proxy = [];
  for (var i = 0; i < parseInt(amount); i++) {
    proxy.push(
      `iproyal.x.proxiess.com:12321:${username}:${password}-country-${country.toLowerCase()}\n`,
    );
  }
  return proxy.join('');
}
```

### **How to generate IPRoyal EU rotating proxies:**

```
iproyaleu.x.proxiess.com:12323:<username>:<password>-country-<country code>
```

### **How to generate IPRoyal Asia rotating proxies:**

```
iproyalasia.x.proxiess.com:12322:<username>:<password>-country-<country code>
```

* **High-End Pool**

When activated, the 'High-End Pool' option grants you access to the swiftest and most reliable proxies in our selection. Please be aware, however, that the trade-off for this enhanced quality is a smaller pool of available proxies than what is typically accessible.

To enable this feature, you will need to add the \_streaming- key with value **1**.

Example:

```
iproyal.x.proxiess.com:12321:<username>:<password>-country-<country code>_session-<session id>_lifetime-1h_streaming-1
```

* **City**

\_city- is the key to target a city. The value should be the name of the city.

Additionally, it's essential to specify the country when targeting a specific city, as multiple countries may have cities with the same name.

Example:

```
iproyaleu.x.proxiess.com:12323:<username>:<password>-country-de_city-berlin_session-<session id>_lifetime-1h
```

* **State**

\_city- is the key to target a city. The value should be the name of the city.

Additionally, it's essential to specify the country when targeting a specific city, as multiple countries may have cities with the same name.

Example:

```
iproyal.x.proxiess.com:12321:<username>:<password>-_country-us_state-iowa_session-<session id>_lifetime-1h
```

### **Supported countries:**

```javascript
    US: "USA",
    CA: "Canada",
    GB: "GB",
    DE: "Germany",
    FR: "France",
    ES: "Spain",
    IT: "Italy",
    SE: "Sweden",
    GR: "Greece",
    PT: "Portugal",
    NL: "Netherlands",
    BE: "Belgium",
    RU: "Russia",
    UA: "Ukraine",
    PL: "Poland",
    IL: "Israel",
    TR: "Turkey",
    AU: "Australia",
    MY: "Malaysia",
    TH: "Thailand",
    KR: "South Korea",
    JP: "Japan",
    PH: "Philippines",
    SG: "Singapore",
    CN: "China",
    HK: "Hong Kong",
    TW: "Taiwan",
    IN: "India",
    PK: "Pakistan",
    IR: "Iran",
    ID: "Indonesia",
    AZ: "Azerbaijan",
    KZ: "Kazakhstan",
    AE: "UAE",
    MX: "Mexico",
    BR: "Brazil",
    AR: "Argentina",
    CL: "Chile",
    PE: "Peru",
    EC: "Ecuador",
    CO: "Colombia",
    ZA: "South Africa",
    EG: "Egypt",
    AO: "Angola",
    CM: "Cameroon",
    CF: "Central African Republic",
    TD: "Chad",
    BJ: "Benin",
    ET: "Ethiopia",
    DJ: "Djibouti",
    GM: "Gambia",
    GH: "Ghana",
    CI: "Côte d'Ivoire",
    KE: "Kenya",
    LR: "Liberia",
    MG: "Madagascar",
    ML: "Mali",
    MR: "Mauritania",
    MU: "Mauritius",
    MA: "Morocco",
    MZ: "Mozambique",
    NG: "Nigeria",
    SN: "Senegal",
    SC: "Seychelles",
    ZW: "Zimbabwe",
    SS: "South Sudan",
    SD: "Sudan",
    TG: "Togo",
    TN: "Tunisia",
    UG: "Uganda",
    ZM: "Zambia",
    AF: "Afghanistan",
    BH: "Bahrain",
    BD: "Bangladesh",
    AM: "Armenia",
    BT: "Bhutan",
    MM: "Myanmar",
    KH: "Cambodia",
    GE: "Georgia",
    IQ: "Iraq",
    JO: "Jordan",
    LB: "Lebanon",
    MV: "Maldives",
    MN: "Mongolia",
    OM: "Oman",
    QA: "Qatar",
    SA: "Saudi Arabia",
    VN: "Vietnam",
    TM: "Turkmenistan",
    UZ: "Uzbekistan",
    YE: "Yemen",
    AL: "Albania",
    AD: "Andorra",
    AT: "Austria",
    BA: "Bosnia and Herzegovina",
    BG: "Bulgaria",
    BY: "Belarus",
    HR: "Croatia",
    CY: "Cyprus",
    CZ: "Czech Republic",
    DK: "Denmark",
    EE: "Estonia",
    FI: "Finland",
    HU: "Hungary",
    IS: "Iceland",
    IE: "Ireland",
    LV: "Latvia",
    LI: "Liechtenstein",
    LT: "Lithuania",
    LU: "Luxembourg",
    MT: "Malta",
    MC: "Monaco",
    MD: "Moldova",
    ME: "Montenegro",
    NO: "Norway",
    RO: "Romania",
    RS: "Serbia",
    SK: "Slovakia",
    SI: "Slovenia",
    CH: "Switzerland",
    MK: "Macedonia",
    BS: "Bahamas",
    BZ: "Belize",
    VG: "British Virgin Islands",
    CR: "Costa Rica",
    CU: "Cuba",
    DM: "Dominica",
    HT: "Haiti",
    HN: "Honduras",
    JM: "Jamaica",
    AW: "Aruba",
    PA: "Panama",
    PR: "Puerto Rico",
    TT: "Trinidad and Tobago",
    FJ: "Fiji",
    NZ: "New Zealand",
    BO: "Bolivia",
    PY: "Paraguay",
    UY: "Uruguay",
    VE: "Venezuela",
  }
```

### **Other Optional Features:**

**Generate proxy list using endpoint**

{% embed url="<https://documenter.getpostman.com/view/10917935/TzRYcQ6t#3248b3d0-5f6b-40a4-8708-1b6e34d85c3d>" %}

### **White labeling:**

Use this method to brand your proxies with your own domain/company name

To brand the proxies under your domain follow these steps:

1. Open the DNS configuration for your domain.
2. Create a C Name Record pointing to the domain.

| IPRoyal (Default) | CNAME | [iproyal.x.proxiess.com](http://iproyal.x.proxiess.com/)         | 12321 |
| ----------------- | ----- | ---------------------------------------------------------------- | ----- |
| IPRoyalasia       | CNAME | [iproyalasia.x.proxiess.com](http://iproyalasia.x.proxiess.com/) | 12322 |
| IPRoyalEU         | CNAME | [iproyaleu.x.proxiess.com](http://iproyaleu.x.proxiess.com/)     | 12323 |

3. Whatever you enter in the name/host will decide the domain which points to our API IP.
4. Thus if your domain is [API.com](http://api.com/) and you enter the host premium or whatever you want to call it pointing to the IPRoyal domain, your proxies will be formatted [premium.yourdomain.com](http://premium.yourdomain.com/):port:user:pass
5. An example on Godaddy is linked below:

<figure><img src="/files/1t4Kx0XwkB9aD4zDJbPH" alt=""><figcaption></figcaption></figure>

### FAQ <a href="#faq" id="faq"></a>

**What is Authorization?**

This is a header value you provide with every request. We are using the Bearer token so send in the header like this: <mark style="color:red;">`"Authorization: Bearer <your API token>"`</mark>

* Im getting this error: <mark style="color:red;">`{"message":"username cannot be null or undefined.","timestamp":1634146255996}`</mark> how do I fix it?

Make sure you have this <mark style="color:red;">`"Content-Type": "application/json"`</mark> header present in your requests.

#### Headers <a href="#headers" id="headers"></a>

Please check on how to send requests with headers in whichever languages you are using.

POST Request:

```javascript
{
	"Authorization": "Bearer <your api token>",
	"Content-Type": "application/json"
} 

```

```javascript
# Sample curl request
curl --location --request POST '<https://iproyal.proxiesapi.xyz/proxy_api/v1/iproyal/users/add_balance>' \\
         --data-raw '{
							"user_id": 21788,
					    "data_gb": 1
     }' -H "Authorization: Bearer <your api token>" -H "Content-Type: application/json"

```

GET Request:

```javascript
{
	"Authorization": "Bearer <your api token>",
}
```

```javascript
# Sample curl request
curl --location --request GET 'https://iproyal.proxiesapi.xyz/proxy_api/v1/iproyal/users/21788' \
         -H "Authorization: Bearer <your api token>"
```


---

# 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://reseller.torchlabs.xyz/reseller-apis/iproyal.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.
