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

# Proxy Country (Geolocation)

> Route web scraping requests through residential IPs in 190+ countries to access geo-restricted content and localized data with ZenRows.

Proxy Country allows you to specify the geographic location from which your scraping requests originate. This feature enables access to geo-restricted content, region-specific pricing, and localized search results by routing your requests through residential IP addresses in your chosen country.

Many websites serve different content based on the visitor's location. Proxy Country addresses this challenge by allowing your requests to appear to originate from any of 190+ supported countries, thereby providing access to region-specific data that would otherwise be unavailable.

## How Proxy Country works

When you specify a country code with the `proxy_country` parameter, ZenRows routes your request through a residential IP address located in that country. The target website recognizes your request as coming from a real user in the specified location, enabling you to access geo-restricted content and view localized results.

Proxy Country requires Premium Proxy to be enabled, as only residential IP addresses can provide accurate geolocation. Datacenter proxies cannot reliably represent specific geographic locations.

## Basic usage

Enable Proxy Country by adding both `premium_proxy=true` and `proxy_country` parameters to your request:

<CodeGroup>
  ```python Python theme={null}
  # pip install requests
  import requests

  url = 'https://httpbin.io/anything'
  apikey = 'YOUR_ZENROWS_API_KEY'
  params = {
      'url': url,
      'apikey': apikey,
      'premium_proxy': 'true',
      'proxy_country': 'es',
  }
  response = requests.get('https://api.zenrows.com/v1/', params=params)
  print(response.text)
  ```

  ```javascript Node.js theme={null}
  // npm install axios
  const axios = require('axios');

  const url = 'https://httpbin.io/anything';
  const apikey = 'YOUR_ZENROWS_API_KEY';
  axios({
      url: 'https://api.zenrows.com/v1/',
      method: 'GET',
      params: {
          'url': url,
          'apikey': apikey,
          'premium_proxy': 'true',
          'proxy_country': 'es',
      },
  })
      .then(response => console.log(response.data))
      .catch(error => console.log(error));
  ```

  ```java Java theme={null}
  import org.apache.hc.client5.http.fluent.Request;

  public class APIRequest {
      public static void main(final String... args) throws Exception {
          String apiUrl = "https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=https%3A%2F%2Fhttpbin.io%2Fanything&premium_proxy=true&proxy_country=es";
          String response = Request.get(apiUrl)
                  .execute().returnContent().asString();

          System.out.println(response);
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=https%3A%2F%2Fhttpbin.io%2Fanything&premium_proxy=true&proxy_country=es');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  echo $response . PHP_EOL;
  curl_close($ch);
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "io"
      "log"
      "net/http"
  )

  func main() {
      client := &http.Client{}
      req, err := http.NewRequest("GET", "https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=https%3A%2F%2Fhttpbin.io%2Fanything&premium_proxy=true&proxy_country=es", nil)
      if err != nil {
          log.Fatalln(err)
      }
      resp, err := client.Do(req)
      if err != nil {
          log.Fatalln(err)
      }
      defer resp.Body.Close()

      body, err := io.ReadAll(resp.Body)
      if err != nil {
          log.Fatalln(err)
      }

      log.Println(string(body))
  }
  ```

  ```ruby Ruby theme={null}
  # gem install faraday
  require 'faraday'

  url = URI.parse('https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=https%3A%2F%2Fhttpbin.io%2Fanything&premium_proxy=true&proxy_country=es')
  conn = Faraday.new()
  conn.options.timeout = 180
  res = conn.get(url, nil, nil)
  print(res.body)
  ```

  ```bash cURL theme={null}
  curl "https://api.zenrows.com/v1/?apikey=YOUR_ZENROWS_API_KEY&url=https%3A%2F%2Fhttpbin.io%2Fanything&premium_proxy=true&proxy_country=es"
  ```
</CodeGroup>

## Common use cases

### E-commerce price monitoring

Monitor pricing across different regions:

```python Python theme={null}
countries = ['us', 'gb', 'de', 'fr', 'jp']
product_url = 'https://example-store.com/product/123'

for country in countries:
    response = requests.get('https://api.zenrows.com/v1/', params={
        'url': product_url,
        'apikey': 'YOUR_ZENROWS_API_KEY',
        'premium_proxy': 'true',
        'proxy_country': country,
    })
    
    # Extract and compare prices for each region
    print(f"Price in {country}: {extract_price(response.text)}")
```

### Search engine localization

Get search results as they appear in different countries:

```python Python theme={null}
search_query = 'best restaurants'
search_url = f'https://www.google.com/search?q={search_query}'

# Get US results
us_response = requests.get('https://api.zenrows.com/v1/', params={
    'url': search_url,
    'apikey': 'YOUR_ZENROWS_API_KEY',
    'premium_proxy': 'true',
    'proxy_country': 'us',
})

# Get ES results  
uk_response = requests.get('https://api.zenrows.com/v1/', params={
    'url': search_url,
    'apikey': 'YOUR_ZENROWS_API_KEY',
    'premium_proxy': 'true',
    'proxy_country': 'es',
})
```

### Content availability testing

Check if content is accessible from different regions:

```python Python theme={null}
def test_content_availability(url, countries):
    results = {}
    
    for country in countries:
        response = requests.get('https://api.zenrows.com/v1/', params={
            'url': url,
            'apikey': 'YOUR_ZENROWS_API_KEY',
            'premium_proxy': 'true',
            'proxy_country': country,
        })
        
        results[country] = {
            'accessible': response.status_code == 200,
            'status_code': response.status_code,
        }
    
    return results

# Test video availability across regions
video_url = 'https://streaming-service.com/video/123'
availability = test_content_availability(video_url, ['us', 'ca', 'gb', 'au'])
```

## Best practices

### Choose appropriate countries

Select countries based on your specific needs:

* US (`us`) - For American content
* GB (`gb`) - For UK-specific results
* DE (`de`) - For German/EU content
* JP (`jp`) - For Japanese content data
* CA (`ca`) - For Canadian content

<Tip>See our complete list of countries [here](/first-steps/faq#what-is-geolocation-and-what-are-all-the-premium-proxy-countries)!</Tip>

### Handle region-specific layouts

Some websites serve different HTML structures by region:

```python Python theme={null}
def extract_data_by_region(html_content, country):
    if country in ['us', 'ca']:
        # North American layout
        return extract_with_us_selectors(html_content)
    elif country in ['gb', 'de', 'fr']:
        # European layout
        return extract_with_eu_selectors(html_content)
    else:
        # Default extraction
        return extract_with_default_selectors(html_content)
```

### Implement country fallbacks

If a specific country doesn't work, try alternatives:

```python Python theme={null}
def scrape_with_fallback(url, preferred_countries):
    for country in preferred_countries:
        try:
            response = requests.get('https://api.zenrows.com/v1/', params={
                'url': url,
                'apikey': 'YOUR_ZENROWS_API_KEY',
                'premium_proxy': 'true',
                'proxy_country': country,
            })
            
            if response.status_code == 200:
                return response, country
                
        except Exception as e:
            print(f"Failed with {country}: {e}")
            continue
    
    return None, None

# Try US first, then Canada, then UK
response, used_country = scrape_with_fallback(
    'https://example.com', 
    ['us', 'ca', 'gb']
)
```

## Troubleshooting

### Common issues and solutions

| Issue                          | Cause                            | Solution                                          |
| ------------------------------ | -------------------------------- | ------------------------------------------------- |
| Content still geo-blocked      | Website blocks entire regions    | Try neighboring countries or different continents |
| Different layout than expected | Region-specific website versions | Update CSS selectors for each region              |
| Slower response times          | Distance from target servers     | Choose countries closer to the website's servers  |
| Inconsistent results           | Regional content variations      | Implement region-specific data extraction logic   |

### Debugging geo-restrictions

When content remains blocked despite using Proxy Country:

<Steps>
  <Step title="Try multiple countries in the same region">
    ```python Python theme={null}
    eu_countries = ['de', 'fr', 'it', 'es', 'nl']
    for country in eu_countries:
        # Test each country
    ```
  </Step>

  <Step title="Check if the entire region is blocked">
    ```python Python theme={null}
    test_countries = ['us', 'gb', 'de', 'jp', 'au', 'br']
    # Test diverse geographic locations
    ```
  </Step>

  <Step title="Combine with additional features">
    * [js\_render](/universal-scraper-api/features/js-rendering): Makes the request act like a headles browser
    * [wait\_for](/universal-scraper-api/features/wait-for): Waits for a specific CSS element on the target url
    * [custom\_headers](/universal-scraper-api/features/headers): Enable using custom headers on the request

    ```python Python theme={null}
    params = {
        'premium_proxy': 'true',
        'proxy_country': 'us',
        'js_render': 'true', # For JavaScript-heavy sites
        'wait_for': '.content',  # Wait for specific elements
        'custom_headers': 'true', # Enable using custom headers on the request
    }
    headers = {
        'referer': 'https://www.google.com'
    }
    ```
  </Step>
</Steps>

## Pricing

Proxy Country doesn't increase the request cost. You pay the Premium Proxy (10 times the standard price) regardless of the country you choose.

<Tip>
  You can monitor your ZenRows usage in multiple ways to stay informed about your account activity and prevent unexpected overages.

  **Dashboard monitoring**: View real-time usage statistics, remaining requests, success rates, and request history on your [Analytics Page](https://app.zenrows.com/analytics/scraper-api). You can also set up usage alerts in your [notification settings](https://app.zenrows.com/account/notifications) to receive notifications when you approach your limits.

  **Programmatic monitoring**: For automated monitoring in your applications, call the `/v1/subscriptions/self/details` endpoint with your API key in the `X-API-Key` header. This returns real-time usage data that you can integrate into your monitoring systems. [Learn more about the usage endpoint](https://docs.zenrows.com/universal-scraper-api/features/other#plan-usage).

  **Response header monitoring**: Track your concurrency usage through response headers included with each request:

  * `Concurrency-Limit`: Your maximum concurrent requests
  * `Concurrency-Remaining`: Available concurrent request slots
  * `X-Request-Cost`: Cost of the current request
</Tip>

## Frequently Asked Questions (FAQ)

<Accordion title="Can I use Proxy Country without Premium Proxy?">
  No, Proxy Country requires Premium Proxy to be enabled. Only residential IP addresses can provide accurate geolocation, and Premium Proxy is necessary to access residential IPs.
</Accordion>

<Accordion title="How accurate is the geolocation?">
  ZenRows utilizes genuine residential IP addresses from ISPs in each country, ensuring highly accurate geolocation that websites recognize as legitimate traffic from those specific regions.
</Accordion>

<Accordion title="Can I specify a city or state within a country?">
  Currently, ZenRows supports country-level geolocation only. You cannot specify specific cities or states within a country.
</Accordion>

<Accordion title="What happens if a country is unavailable?">
  If no residential IPs are available for your specified country, the request will fail. Implement fallback logic to try alternative countries in such cases.
</Accordion>

<Accordion title="Do different countries have different success rates?">
  Yes, success rates can vary by country depending on the target website's blocking policies and the quality of residential IP pools in each region. Monitor your success rates and adjust accordingly.
</Accordion>

<Accordion title="Can I use the same country for all requests in a session?">
  Yes, you can use the same country consistently. However, some websites may still detect patterns, so consider rotating between countries in the same region if needed.
</Accordion>
