# Amazon ZIP Code Targeting

{% hint style="warning" %}
Our current support is **limited to US** ZIP Codes exclusively
{% endhint %}

Use the `zip` parameter to target specific US ZIP Codes when scraping Amazon product listings, offers, search queries and more. This allows you to gather insights for market research, competitor analysis and pricing optimization.

Here are some supported ZIP Codes:

| ZIP Code      |                  |              |                 |
| ------------- | ---------------- | ------------ | --------------- |
| 33837         | 62864            | 92223        | 92392           |
| Davenport, FL | Mount Vernon, VA | Beaumont, TX | Victorville, CA |

Setting `zip=92223` for example, will instruct the API to return results specific to **Beaumont, TX**.

* **API REQUEST**

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

```bash
curl --request GET \
--url 'https://api.scraperapi.com?api_key=API_KEY&zip=92223&url=https://www.amazon.com/dp/B00939I7EK'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

target_url = 'https://www.amazon.com/dp/B00939I7EK'
# Replace the value for api_key with your actual API Key.
api_key = 'API_KEY'
zip_code = '92223'

request_url = f'https://api.scraperapi.com?api_key={api_key}&zip={zip_code}&url={target_url}'
response = requests.get(request_url)

print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import request from 'node-fetch';

//Replace the value for api_key with your actual API Key.
const url = 'http://api.scraperapi.com/?api_key=API_KEY&zip=92223&url=https://www.amazon.com/dp/B00939I7EK';

request(url)
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

//Replace the value for api_key with your actual API Key.
$url = "http://api.scraperapi.com?api_key=API_KEY&zip=92223&url=https://www.amazon.com/dp/B00939I7EK";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

$response = curl_exec($ch);

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

curl_close($ch);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'

params = {
  #Replace the value for api_key with your actual API Key.
  api_key: "API_KEY",
  url: "https://www.amazon.com/dp/B00939I7EK",
  zip: '92223'
}

uri = URI('https://api.scraperapi.com/')
uri.query = URI.encode_www_form(params)

website_content = Net::HTTP.get(uri)
puts website_content
```

{% 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 {
        //Replace the value for api_key with your actual API Key.
        String apiKey = "API_KEY";
        String targetUrl = "https://www.amazon.com/dp/B00939I7EK";
        String zip_code = "92223";

        String scraperApiUrl = "https://api.scraperapi.com?api_key=" + apiKey + "&zip=" + zip_code + "&url=" + targetUrl;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(scraperApiUrl))
                .GET()
                .build();

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

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

{% endtab %}
{% endtabs %}

* **PROXY MODE**

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

```bash
curl --proxy 'http://scraperapi.zip=92223:API_KEY@proxy-server.scraperapi.com:8001' \
  -k \
  'https://www.amazon.com/dp/B00939I7EK'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

#Replace the value for api_key with your actual API Key.
proxies = {
"http": "http://scraperapi.zip=92223:API_KEY@proxy-server.scraperapi.com:8001"
}

r = requests.get('https://www.amazon.com/dp/B00939I7EK', proxies=proxies, verify=False)
print(r.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import axios from 'axios';

axios.get('https://www.amazon.com/dp/B00939I7EK', {
  method: 'GET',
  proxy: {
    host: 'proxy-server.scraperapi.com',
    port: 8001,
    auth: {
      username: 'scraperapi.zip=92223',
      //Replace the value for password with your actual API Key.
      password: 'API_KEY'  
    },
    protocol: 'http'
  }
})
  .then(response => {
    console.log(response)
  })
  .catch(error => {
    console.log(error)
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$ch = curl_init();  curl_setopt($ch, CURLOPT_URL,
"https://www.amazon.com/dp/B00939I7EK");  curl_setopt($ch, CURLOPT_PROXY,
//Replace the value for api_key with your actual API Key.
"http://scraperapi.zip=92223:API_KEY@proxy-server.scraperapi.com:8001");  

curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch, CURLOPT_HEADER,FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);

$response = curl_exec($ch);  curl_close($ch);  var_dump($response);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'httparty'

HTTParty::Basement.default_options.update(verify: false)

response = HTTParty.get('https://www.amazon.com/dp/B00939I7EK', {
http_proxyaddr: "proxy-server.scraperapi.com",
http_proxyport: "8001",
http_proxyuser: "scraperapi.zip=92223",
#Replace the value for http_proxypass with your actual API Key.
http_proxypass: "API_KEY"
})

results = response.body
puts results 
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class Main {
    public static void main(String[] args) {
        try {
            SSLContext sc = SSLContext.getInstance("TLS");
            sc.init(null, new TrustManager[]{(X509TrustManager) new X509TrustManager() {
                public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }
                public void checkClientTrusted(java.security.cert.X509Certificate[] c, String a) {}
                public void checkServerTrusted(java.security.cert.X509Certificate[] c, String a) {}
            }}, new java.security.SecureRandom());
            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
            HttpsURLConnection.setDefaultHostnameVerifier((h, s) -> true);

            String apiKey = "API_KEY"; //Replace the value for api_key with your actual API Key.
            Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("scraperapi.zip=92223", apiKey.toCharArray());
                }
            });

            System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
            System.setProperty("https.proxyHost", "proxy-server.scraperapi.com");
            System.setProperty("https.proxyPort", "8001");

            BufferedReader in = new BufferedReader(new InputStreamReader(
                new URL("https://www.amazon.com/dp/B00939I7EK").openConnection().getInputStream()
            ));
            StringBuilder resp = new StringBuilder();
            for (String line; (line = in.readLine()) != null; ) resp.append(line).append("\n");
            in.close();
            System.out.println(resp);
        } catch (Exception e) { e.printStackTrace(); }
    }
}

```

{% endtab %}
{% endtabs %}

* **SDE METHOD**

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

```bash
curl --request GET \
--url 'https://api.scraperapi.com/structured/amazon/product?api_key=API_KEY&zip=92223&asin=B00939I7EK'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

#Amazon ASIN
ASIN = 'B00939I7EK'
# ScraperAPI API Key
api_key = 'API_KEY'
zip_code = '92223'

request_url = f'https://api.scraperapi.com/structured/amazon/product?api_key={api_key}&zip={zip_code}&asin={ASIN}'
response = requests.get(request_url)

print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import request from 'request-promise';

//Replace the value for api_key with your actual API Key
const url = 'https://api.scraperapi.com/structured/amazon/product?api_key=API_KEY&zip=92223&asin=B00939I7EK';

request(url)
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

//Replace the value for api_key with your actual API Key
$url = "https://api.scraperapi.com/structured/amazon/product?api_key=API_KEY&zip=92223&asin=B00939I7EK";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

$response = curl_exec($ch);

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

curl_close($ch);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'

#Replace the value for api_key with your actual API Key
params = {
  api_key: "API_KEY",
  asin: "B00939I7EK",
  zip: "92223"
}

uri = URI('https://api.scraperapi.com/structured/amazon/product')
uri.query = URI.encode_www_form(params)

website_content = Net::HTTP.get(uri)
puts website_content
```

{% 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 {
        //Replace the value for api_key with your actual API Key
        String apiKey = "API_KEY";
        String ASIN = "B00939I7EK";
        String zip_code = "92223";

        String scraperApiUrl = "https://api.scraperapi.com/structured/amazon/product?api_key=" + apiKey + "&zip=" + zip_code + "&asin=" + ASIN;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(scraperApiUrl))
                .GET()
                .build();

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

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

{% endtab %}
{% endtabs %}

We encourage you to explore the ZIP code targeting feature to see how it can enhance your data collection. Try various ZIP codes to get a feel for how the targeted information changes and tailor your requests to suit your needs. If certain ZIP codes are not working or are not accepted during your testing, please contact [our support team](https://dashboard.scraperapi.com/contact-support) for assistance.
