> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anchorbrowser.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Proxy

Anchor provides proxy configurations to access websites from different geographic locations, configurable down to the **city level.** Use custom proxies or Anchor's built-in proxy for localization.

<Warning>
  Anchor Browser infrastructure is fully hosted in the US. For GDPR compliance, upgrade to the [Growth tier](https://app.anchorbrowser.io/billing) or [contact support](https://mail.google.com/mail/?view=cm\&fs=1\&to=support@anchorbrowser.io\&su=Full%20GDPR%20Compatibility%20Request).
</Warning>

#### Quick Start Example

Here's a simple example of how to use Anchor's built-in proxy:

<CodeGroup>
  ```javascript node.js theme={null}
  import AnchorBrowser from 'anchorbrowser';

  const anchor_client = new AnchorBrowser({apiKey: process.env.ANCHOR_API_KEY});

  const session = await anchor_client.sessions.create({
      session: {
        proxy: {
          active: true,
          country_code: 'gb',
        }
      }
  });

  console.log("Session created:", session.data);
  ```

  ```python python theme={null}
  import os
  from anchorbrowser import Anchorbrowser

  anchor_client = Anchorbrowser(api_key=os.getenv("ANCHOR_API_KEY"))

  session = anchor_client.sessions.create(
    session={
      'proxy': {
          'active': True,
          'country_code': 'gb',
      }
    }
  )
  print("Session created:", session.data)
  ```
</CodeGroup>

This creates a browser session using Anchor's US proxy. You can change `country_code` to any supported country (e.g., 'gb', 'de', 'jp').

To experiment with different proxy configurations, visit our [Interactive API Reference](/api-reference/browser-sessions/start-browser-session)

## Custom Proxy

Anchor Browser allows you to use your own proxy servers, giving you complete control over your proxy infrastructure. This is particularly useful when you have existing proxy solutions or need to comply with specific network policies.

### Custom Proxy Configuration

To use a custom proxy, you need to provide the following information:

* **`active`**: Set to `true` to enable the proxy
* **`type`**: Set to `"custom"` to indicate you're using your own proxy
* **`server`**: The full proxy URL in the format `protocol://hostname:port`
* **`username`**: Your proxy authentication username (if required)
* **`password`**: Your proxy authentication password (if required)

### Supported Proxy Protocols

Anchor Browser supports the following proxy protocols:

* **HTTP Proxy**: Standard HTTP proxy with optional authentication (e.g., `http://proxy.example.com:8080`)
* **HTTPS Proxy**: Secure HTTPS proxy connections (e.g., `https://proxy.example.com:443`)
* **SOCKS5 Proxy**: SOCKS5 proxy for enhanced privacy and flexibility (e.g., `socks5://proxy.example.com:1080`)

### Example Configurations

<CodeGroup>
  ```javascript node.js theme={null}
  import AnchorBrowser from 'anchorbrowser';

  const anchorClient = new AnchorBrowser({apiKey: process.env.ANCHOR_API_KEY});

  const response = await anchorClient.sessions.create({
    session: {
      proxy: {
        active: true,
        type: 'custom',
        server: 'https://proxy.example.com:443',  // Supported protocols: http, https, socks5
        username: 'myUser',
        password: 'myPassword',
      }
    }
  });
    
  console.log('Session created:', response.data);
  ```

  ```python python theme={null}
  import os
  import json
  from anchorbrowser import Anchorbrowser

  anchor_client = Anchorbrowser(api_key=os.getenv('ANCHOR_API_KEY'))

  response = anchor_client.sessions.create(
    session={
      'proxy': {
          'active': True,
          'type': 'custom',
          'server': 'https://proxy.example.com:443',  # Supported protocols: http, https, socks5
          'username': 'myUser',
          'password': 'myPassword',
      }
    }
  )

  print('Session created:')
  print(response.data)
  ```
</CodeGroup>

## Localization

You can specify a country code for your proxy to route traffic through a specific geographic location. This is useful for accessing region-specific content or testing localized experiences.

The `country_code` parameter accepts country codes in lowercase. See the [complete list of supported countries](#supported-countries-with-their-country-codes) below for all available options.

### Region and City-Based Targeting

For even more precise geographic targeting, you can specify both `region` and `city` parameters. This is only supported for the default proxy type (`anchor_proxy`).

**Important Notes:**

* The `city` parameter can only be used when `region` is also provided
* If you specify a city without a region, the city parameter will be ignored
* City names: use English, case-insensitive. Both "Los Angeles" and "los-angeles" work.

<CodeGroup>
  ```javascript node.js theme={null}
  import AnchorBrowser from 'anchorbrowser';

  const anchorClient = new AnchorBrowser({apiKey: process.env.ANCHOR_API_KEY});

  const response = await anchorClient.sessions.create({
    session: {
      proxy: {
        active: true,
        country_code: 'us',
        region: 'ca',
        city: 'los-angeles'
      }
    }
  });
    
  console.log('Session created:', response.data);
  ```

  ```python python theme={null}
  import os
  import json
  from anchorbrowser import Anchorbrowser

  anchor_client = Anchorbrowser(api_key=os.getenv('ANCHOR_API_KEY'))

  response = anchor_client.sessions.create(
      session={
          'proxy': {
              'active': True,
              'country_code': 'us',
              'region': 'ca',
              'city': 'los-angeles'
          }
      }
  )

  print('Session created:')
  print(response.data)
  ```
</CodeGroup>

### Supported Countries with their Country Codes

<Tabs>
  <Tab title="Anchor Proxy">
    |                        |    |                  |    |                          |    |
    | ---------------------- | -- | ---------------- | -- | ------------------------ | -- |
    | Afghanistan            | af | France           | fr | Netherlands              | nl |
    | Albania                | al | French Guiana    | gf | New Zealand              | nz |
    | Algeria                | dz | French Polynesia | pf | Nicaragua                | ni |
    | Andorra                | ad | Gabon            | ga | Nigeria                  | ng |
    | Angola                 | ao | Gambia           | gm | Norway                   | no |
    | American Samoa         | as | Georgia          | ge | Pakistan                 | pk |
    | Antigua and Barbuda    | ag | Germany          | de | Panama                   | pa |
    | Argentina              | ar | Ghana            | gh | Paraguay                 | py |
    | Armenia                | am | Gibraltar        | gi | Peru                     | pe |
    | Aruba                  | aw | Greece           | gr | Philippines              | ph |
    | Australia              | au | Grenada          | gd | Poland                   | pl |
    | Austria                | at | Guadeloupe       | gp | Portugal                 | pt |
    | Azerbaijan             | az | Guatemala        | gt | Puerto Rico              | pr |
    | Bahamas                | bs | Guernsey         | gg | Qatar                    | qa |
    | Bahrain                | bh | Guinea           | gn | Romania                  | ro |
    | Barbados               | bb | Guinea-Bissau    | gw | Saint Lucia              | lc |
    | Belarus                | by | Guyana           | gy | San Marino               | sm |
    | Belgium                | be | Haiti            | ht | Saudi Arabia             | sa |
    | Belize                 | bz | Honduras         | hn | Senegal                  | sn |
    | Benin                  | bj | Hungary          | hu | Serbia                   | rs |
    | Bermuda                | bm | Iceland          | is | Seychelles               | sc |
    | Bolivia                | bo | India            | in | Sierra Leone             | sl |
    | Bosnia and Herzegovina | ba | Iran             | ir | Slovakia                 | sk |
    | Brazil                 | br | Iraq             | iq | Slovenia                 | si |
    | Bulgaria               | bg | Ireland          | ie | Somalia                  | so |
    | Burkina Faso           | bf | Israel           | il | South Africa             | za |
    | Cameroon               | cm | Italy            | it | South Korea              | kr |
    | Canada                 | ca | Jamaica          | jm | Spain                    | es |
    | Cape Verde             | cv | Japan            | jp | Suriname                 | sr |
    | Chad                   | td | Jordan           | jo | Sweden                   | se |
    | Chile                  | cl | Kazakhstan       | kz | Switzerland              | ch |
    | Colombia               | co | Kuwait           | kw | Syria                    | sy |
    | Congo                  | cg | Kyrgyzstan       | kg | São Tomé and Príncipe    | st |
    | Costa Rica             | cr | Latvia           | lv | Taiwan                   | tw |
    | Côte d’Ivoire          | ci | Lebanon          | lb | Tajikistan               | tj |
    | Croatia                | hr | Libya            | ly | Togo                     | tg |
    | Cuba                   | cu | Liechtenstein    | li | Trinidad and Tobago      | tt |
    | Cyprus                 | cy | Lithuania        | lt | Tunisia                  | tn |
    | Czech Republic         | cz | Luxembourg       | lu | Turkey                   | tr |
    | Denmark                | dk | Macedonia        | mk | Turks and Caicos Islands | tc |
    | Dominica               | dm | Mali             | ml | Ukraine                  | ua |
    | Dominican Republic     | do | Malta            | mt | United Arab Emirates     | ae |
    | Ecuador                | ec | Martinique       | mq | United Kingdom           | gb |
    | Egypt                  | eg | Mauritania       | mr | United States            | us |
    | El Salvador            | sv | Mexico           | mx | Uruguay                  | uy |
    | Estonia                | ee | Moldova          | md | Uzbekistan               | uz |
    | Ethiopia               | et | Monaco           | mc | Venezuela                | ve |
    | Faroe Islands          | fo | Montenegro       | me | Yemen                    | ye |
    | Finland                | fi | Morocco          | ma |                          |    |
  </Tab>
</Tabs>
