Amazon Search API

This endpoint will retrieve products for a specified search term from Amazon search page and transform it into usable JSON.

try {
String apiKey = "APIKEY";
String query = "QUERY";
String country = "COUNTRY";
String tld = "TLD";
String url = "https://api.scraperapi.com/structured/amazon/search?api_key=" + apiKey + "&query=" + QUERY + "&country=" + country + "&tld=" + tld;
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
int responseCode = conection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}

As you can see in the code abode, you can use several parameters with this method as well:

ParameterDetails

API_KEY

User's normal API Key

query

Amazon Search query string

COUNTRY

Where an amazon domain needs to be scraped from another country (e.g. scraping amazon.com from Canada to get Canadian shipping information), specify the TLD as well as the COUNTRY parameters. Valid values are valid TLDs (e.g. “.com.au”, “.es”, etc.). Valid values include: us: 'amazon.com', uk: 'amazon.co.uk', ca: 'amazon.ca', de: 'amazon.de', es: 'amazon.es', fr: 'amazon.fr', it: 'amazon.it', jp: 'amazon.co.jp', in: 'amazon.in', cn: 'amazon.cn', sg: 'amazon.com.sg', mx: 'amazon.com.mx', ae: 'amazon.ae', br: 'amazon.com.br', nl: 'amazon.nl', au: 'amazon.com.au', tr: 'amazon.com.tr', sa: 'amazon.sa', se: 'amazon.se', pl: 'amazon.pl'

TLD

Country of Amazon domain to scrape. This is an optional argument and defaults to “us” (amazon.com).


Last updated