# Bright Data

{% 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, user_id, username, password) {
  proxy = [];
  for (var i = 0; i < parseInt(amount); i++) {
    proxy.push(
      `pmgr-customer-hl_e65c4ff1.brd.superproxy.io:user_id:${user_id}:${username}-country-${country.toLowerCase()}-session-${string(
        15,
      )}:${password}\n`,
    );
  }
  return proxy.join('');
}



```

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

```javascript
function proxyGenerationRotating(amount, country, username, password) {
  proxy = [];
  for (var i = 0; i < parseInt(amount); i++) {
    proxy.push(
      `pmgr-customer-hl_e65c4ff1.brd.superproxy.io:user_id:${user_id}:${username}-country-${country.toLowerCase()}:${password}\n`,
  }
  return proxy.join('');
}



```

### **Supported countries:**

```javascript
Countries: [
    { name: 'GB', display: 'United Kingdom' },
    { name: 'SI', display: 'Slovenia' },
    { name: 'IT', display: 'Italy' },
    { name: 'FR', display: 'France' },
    { name: 'LV', display: 'Latvia' },
    { name: 'CZ', display: 'Czechia' },
    { name: 'PH', display: 'Philippines' },
    { name: 'MA', display: 'Morocco' },
    { name: 'UG', display: 'Uganda' },
    { name: 'RU', display: 'Russian Federation' },
    { name: 'TR', display: 'Turkey' },
    { name: 'TH', display: 'Thailand' },
    { name: 'BD', display: 'Bangladesh' },
    { name: 'ES', display: 'Spain' },
    { name: 'MT', display: 'Malta' },
    { name: 'GR', display: 'Greece' },
    { name: 'VN', display: 'Viet Nam' },
    { name: 'BF', display: 'Burkina Faso' },
    { name: 'US', display: 'United States' },
    { name: 'AL', display: 'Albania' },
    { name: 'DZ', display: 'Algeria' },
    { name: 'JP', display: 'Japan' },
    { name: 'KE', display: 'Kenya' },
    { name: 'HU', display: 'Hungary' },
    { name: 'RO', display: 'Romania' },
    { name: 'ID', display: 'Indonesia' },
    { name: 'NG', display: 'Nigeria' },
    { name: 'IN', display: 'India' },
    { name: 'AF', display: 'Afghanistan' },
    { name: 'CN', display: 'China' },
    { name: 'LK', display: 'Sri Lanka' },
    { name: 'CO', display: 'Colombia' },
    { name: 'MX', display: 'Mexico' },
    { name: 'RS', display: 'Serbia' },
    { name: 'DO', display: 'Dominican Republic' },
    { name: 'IE', display: 'Ireland' },
    { name: 'IR', display: 'Iran, Islamic Republic of' },
    { name: 'BR', display: 'Brazil' },
    { name: 'EG', display: 'Egypt' },
    { name: 'MV', display: 'Maldives' },
    { name: 'UA', display: 'Ukraine' },
    { name: 'CH', display: 'Switzerland' },
    { name: 'MH', display: 'Marshall Islands' },
    { name: 'PE', display: 'Peru' },
    { name: 'TZ', display: 'Tanzania, United Republic of' },
    { name: 'VE', display: 'Venezuela, Bolivarian Republic of' },
    { name: 'AR', display: 'Argentina' },
    { name: 'LY', display: 'Libya' },
    { name: 'TW', display: 'Taiwan, Province of China' },
    { name: 'HR', display: 'Croatia' },
    { name: 'SE', display: 'Sweden' },
    { name: 'BT', display: 'Bhutan' },
    { name: 'NO', display: 'Norway' },
    { name: 'PG', display: 'Papua New Guinea' },
    { name: 'PT', display: 'Portugal' },
    { name: 'YE', display: 'Yemen' },
    { name: 'FI', display: 'Finland' },
    { name: 'NP', display: 'Nepal' },
    { name: 'NZ', display: 'New Zealand' },
    { name: 'UY', display: 'Uruguay' },
    { name: 'AO', display: 'Angola' },
    { name: 'HN', display: 'Honduras' },
    { name: 'IQ', display: 'Iraq' },
    { name: 'NL', display: 'Netherlands' },
    { name: 'PY', display: 'Paraguay' },
    { name: 'SO', display: 'Somalia' },
    { name: 'CF', display: 'Central African Republic' },
    { name: 'SD', display: 'Sudan' },
    { name: 'BI', display: 'Burundi' },
    { name: 'DE', display: 'Germany' },
    { name: 'KR', display: 'Korea, Republic of' },
    { name: 'KZ', display: 'Kazakhstan' },
    { name: 'MY', display: 'Malaysia' },
    { name: 'PL', display: 'Poland' },
    { name: 'PS', display: 'Palestine, State of' },
    { name: 'CL', display: 'Chile' },
    { name: 'CU', display: 'Cuba' },
    { name: 'EE', display: 'Estonia' },
    { name: 'SN', display: 'Senegal' },
    { name: 'SV', display: 'El Salvador' },
    { name: 'SY', display: 'Syrian Arab Republic' },
    { name: 'UZ', display: 'Uzbekistan' },
    { name: 'BE', display: 'Belgium' },
    { name: 'CA', display: 'Canada' },
    { name: 'NA', display: 'Namibia' },
    { name: 'SA', display: 'Saudi Arabia' },
    { name: 'BJ', display: 'Benin' },
    { name: 'GE', display: 'Georgia' },
    { name: 'JO', display: 'Jordan' },
    { name: 'PA', display: 'Panama' },
    { name: 'AM', display: 'Armenia' },
    { name: 'BB', display: 'Barbados' },
    { name: 'CG', display: 'Congo' },
    { name: 'ET', display: 'Ethiopia' },
    { name: 'KP', display: "Korea, Democratic People's Republic of" },
    { name: 'MZ', display: 'Mozambique' },
    { name: 'WS', display: 'Samoa' },
    { name: 'DM', display: 'Dominica' },
    { name: 'LT', display: 'Lithuania' },
    { name: 'SB', display: 'Solomon Islands' },
    { name: 'SR', display: 'Suriname' },
    { name: 'SS', display: 'South Sudan' },
    { name: 'ZW', display: 'Zimbabwe' },
    { name: 'AT', display: 'Austria' },
    { name: 'BW', display: 'Botswana' },
    { name: 'GA', display: 'Gabon' },
    { name: 'IS', display: 'Iceland' },
    { name: 'OM', display: 'Oman' },
    { name: 'SM', display: 'San Marino' },
    { name: 'ZA', display: 'South Africa' },
    { name: 'ZM', display: 'Zambia' },
    { name: 'AG', display: 'Antigua and Barbuda' },
    { name: 'AU', display: 'Australia' },
    { name: 'KG', display: 'Kyrgyzstan' },
    { name: 'LB', display: 'Lebanon' },
    { name: 'PK', display: 'Pakistan' },
    { name: 'SK', display: 'Slovakia' },
    { name: 'AE', display: 'United Arab Emirates' },
    { name: 'BY', display: 'Belarus' },
    { name: 'CR', display: 'Costa Rica' },
    { name: 'QA', display: 'Qatar' },
    { name: 'BZ', display: 'Belize' },
    { name: 'CY', display: 'Cyprus' },
    { name: 'IL', display: 'Israel' },
    { name: 'KW', display: 'Kuwait' },
    { name: 'MG', display: 'Madagascar' },
    { name: 'TM', display: 'Turkmenistan' },
    { name: 'BH', display: 'Bahrain' },
    { name: 'DK', display: 'Denmark' },
    { name: 'FJ', display: 'Fiji' },
    { name: 'SG', display: 'Singapore' },
    { name: 'TG', display: 'Togo' },
    { name: 'TO', display: 'Tonga' },
    { name: 'BN', display: 'Brunei Darussalam' },
    { name: 'GL', display: 'Greenland' },
    { name: 'SL', display: 'Sierra Leone' },
    { name: 'SZ', display: 'Eswatini' },
    { name: 'KI', display: 'Kiribati' },
    { name: 'KM', display: 'Comoros' },
    { name: 'LU', display: 'Luxembourg' },
    { name: 'TJ', display: 'Tajikistan' },
    { name: 'HK', display: 'Hong Kong' },
  ]
```

### Other Optional Features: <a href="#other-optional-features" id="other-optional-features"></a>

**Cloud Proxy Manager**\
Initial setup\
Hosting the Proxy Manager on our Cloud servers with remote server access lets Bright Data\
host the servers for you.

* Read more about the Proxy Manager on our [FAQ](https://help.brightdata.com/hc/en-us/sections/4413157736849).
* Check the available endpoints on our Proxy manager [API documentation](https://help.brightdata.com/hc/en-us/categories/4419564135825-API-documentation#lpm_endpoints).
* Read more about the Cloud Proxy Manager on our [FAQ](https://help.brightdata.com/hc/en-us).

The Cloud Proxy Manager should be already added automatically to your [CP](https://brightdata.com/cp/lpm), If you don’t have\
any servers installed - you should contact your account manager.

<figure><img src="https://633083225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsxMhtMHGoOKgipGL3q34%2Fuploads%2FYNHawT6VAj0fOM5YJVyO%2F3.png?alt=media&#x26;token=9563dc6c-4cc7-4fe7-b476-fa698b9cc0d0" alt=""><figcaption></figcaption></figure>

Before doing any action in Cloud Proxy Manager, you should add your IP to the admin's whitelist

* Open the [cp/lpm](https://brightdata.com/cp/lpm) page
* Click the open button on the Cloud Proxy Manager row
* Click on the General settings button
* In the General settings page, add your IP to the Admin whitelisted IPs
  * You can check your IP [here](http://whatismyippro.com/)

<figure><img src="https://633083225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsxMhtMHGoOKgipGL3q34%2Fuploads%2Fa8O5eWvKLC73RcXRsq5d%2F4.png?alt=media&#x26;token=a544ef21-c703-4175-b708-37246dd9c542" alt=""><figcaption></figcaption></figure>

### **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.
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 PacketStream 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="https://633083225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsxMhtMHGoOKgipGL3q34%2Fuploads%2FMDDLb8TXCpO1uei9kTDb%2F5.png?alt=media&#x26;token=d7babcea-061e-47e5-9788-296e12ca112a" alt=""><figcaption></figcaption></figure>

### FAQ

**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: `"Authorization: Bearer <your API token>"`

* 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://brightdata.proxiesapi.xyz/proxy_api/v1/brightdata/users/update>' \\
         --data-raw '{
							"user_id": 24293,
					    "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://brightdata.proxiesapi.xyz/proxy_api/v1/brightdata/users/24293?includeUsage=true' \
         -H "Authorization: Bearer <your api token>"
```
