LogoLogo
OverviewRelease NotesDataPipelineFAQs
Java
Java
  • Make Requests with ScraperAPI in Java
    • Use ScraperAPI Endpoint in Java
    • Use ScraperAPI Proxy Port in Java
    • Use ScraperAPI SDK in Java
    • Make Async Requests with ScraperAPI in Java
      • How to Use ScraperAPI Async Web Scraping in Java
      • Use Async ScraperAPI Callbacks in Java
      • Configure ScraperAPI Parameters in Java
      • Request Async Batch Scraping with ScraperAPI in Java
      • Decode Base64 Async Responses in Java
    • ScraperAPI Structured Data Collection in Java
      • Amazon Product Page API: Structured Data in Java
      • Amazon Search API: Structured Data in Java
      • Amazon Offers API: Structured Data in Java
      • Amazon Reviews API: Structured Data in Java
      • Ebay Product Page API: Structured Data in Java
      • Ebay Search API: Structured Data in Java
      • Google SERP API: Structured Data in Java
      • Google News API: Structured Data in Java
      • Google Jobs API: Structured Data in Java
      • Google Shopping API: Structured Data in Java
      • Google Maps Search API: Structured Data in Java
      • Redfin Agent Details API: Structured Data in Java
      • Redfin 'For Rent' Listings API: Structured Data in Java
      • Redfin 'For Sale' Listings API: Structured Data in Java
      • Redfin Listing Search API: Structured Data in Java
      • Walmart Search API: Structured Data in Java
      • Walmart Category API: Structured Data in Java
      • Walmart Product API: Structured Data in Java
      • Walmart Reviews API: Structured Data in Java
    • ScraperAPI Async Structured Data Collection in Java
      • Amazon Product Page API: Async Structured Data in Java
      • Amazon Search API: Async Structured Data in Java
      • Amazon Offers API: Async Structured Data in Java
      • Amazon Reviews API: Async Structured Data in Java
      • Ebay Product Page API: Async Structured Data in Java
      • Ebay Search API: Async Structured Data in Java
      • Google SERP API: Async Structured Data in Java
      • Google News API: Async Structured Data in Java
      • Google Jobs API: Async Structured Data in Java
      • Google Shopping API: Async Structured Data in Java
      • Google Maps Search API: Async Structured Data in Java
      • Redfin Agent Details API: Async Structured Data in Java
      • Redfin 'For Rent' Listings API: Async Structured Data in Java
      • Redfin 'For Sale' Listings API: Async Structured Data in Java
      • Redfin Listing Search API: Async Structured Data in Java
      • Walmart Search API: Async Structured Data in Java
      • Walmart Category API: Async Structured Data in Java
      • Walmart Product API: Async Structured Data in Java
      • Walmart Reviews API: Async Structured Data in Java
    • Making POST/PUT Requests with ScraperAPI in Java
    • Customizing ScraperAPI Requests in Java
      • Customize Amazon Requests by ZIP Code via ScraperAPI in Java
      • Customize Cached Results via ScraperAPI in Java
      • Customize Control Costs with ScraperAPI Parameter in Java
      • Send Custom Headers with ScraperAPI in Java
      • Customize Device Type with ScraperAPI in Java
      • Customize Geotargeted Content Scrape via ScraperAPI in Java
      • Customize Premium Geotargeted Scrape via ScraperAPI in Java
      • Customize Header Parameter with ScraperAPI in Java
      • Customize Premium Residential/Mobile Proxies in Java
      • Customize JavaScript-Rendered Pages via ScraperAPI in Java
        • Use Render Instruction Set to Scrape Dynamic Pages in Java
        • Customize Taking a Website Screenshots via ScraperAPI in Java
      • Customize Scrape Session-Based Proxies via ScraperAPI in Java
  • Handle and Process Responses via ScraperAPI in Java
    • Use API Status Codes to Retry Failed Requests in Java
    • Customize Output Formats via ScraperAPI Parameters in Java
      • Request JSON Response via Autoparse Parameter in Java
      • Request LLM Output Formats with ScraperAPI in Java
    • Request Response Encoding and Content-Type via ScraperAPI in Java
  • Dashboard & Billing
    • API Key
    • Credit Usage
    • Delete Account
    • Invoice History
    • Billing Email
    • Billing Address
    • VAT Number
    • Payment Method
    • Cancel Subscription
  • Credits and Requests
  • Monitor Your ScraperAPI Account Information in Java
  • Documentation Overview
Powered by GitBook

Quick links

  • Homepage
  • Dashboard
  • Pricing
  • Contact Sales

Resources

  • Developer Guides
  • Blog
  • Contact Support
  • Learning Hub
On this page

Was this helpful?

  1. Make Requests with ScraperAPI in Java
  2. ScraperAPI Async Structured Data Collection in Java

Amazon Offers API: Async Structured Data in Java

Scrape Amazon product offers into structured data JSON/CSV with ScraperAPI async in Java. Track competing sellers, prices, and fulfillment methods by ASIN.

This endpoint will retrieve offers for a specified product from an Amazon offers page and transform it into usable JSON.

Single ASIN Request:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "APIKEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"asin\": \"ASIN\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"CALLBACK\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/amazon/offers");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }
            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

Multiple ASIN Request:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "APIKEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"asins\": [\"ASIN1\", \"ASIN2\", \"ASIN3\"], "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"CALLBACK\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/amazon/offers");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }
            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

Multiple parameters can be used with this method:

REQUIRED

APIKEY

User account’s normal API key.

ASIN

Amazon product ASIN.

OPTIONAL

TLD

Valid values include:

com (amazon.com)

co.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)

COUNTRY

Valid values are two letter country codes for which we offer Geo Targeting (e.g. “au”, “es”, “it”, etc.).

Where an amazon domain needs to be scraped from another country (e.g. scraping amazon.com from Canada to get Canadian shipping information), both TLD and COUNTRY parameters must be specified.

F_NEW

Boolean parameter with a possible value of true or false indicating the condition of the listed items

F_USEDGOOD

Boolean parameter with a possible value of true or false indicating the condition of the listed items

F_USEDLIKENEW

Boolean parameter with a possible value of true or false indicating the condition of the listed items

F_USEDVERYGOOD

Boolean parameter with a possible value of true or false indicating the condition of the listed items

F_USEDACCEPTABLE

Boolean parameter with a possible value of true or false indicating the condition of the listed items

Sample Response

Single ASIN Request:

{
	"id": "f9c41146-ecd3-415c-ae0a-461de670e2e8",
	"status": "running",
	"statusUrl": "http://async.scraperapi.com/structured/amazon/offers/f9c41146-ecd3-415c-ae0a-461de670e2e8",
	"asin": "B079BLHH67"
}

Multiple ASIN Request:

[
	{
		"id": "5b0c838a-d0eb-46c3-ad9a-e82e398d56a5",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/amazon/offers/5b0c838a-d0eb-46c3-ad9a-e82e398d56a5",
		"asin": "B079BLHH67"
	},
	{
		"id": "df83b9e1-be25-40de-8702-4e934f057867",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/amazon/offers/df83b9e1-be25-40de-8702-4e934f057867",
		"asin": "B07G98GG51"
	}
]

After the job(s) finish, you will find the result under the response key in the response JSON object. The structure is the same as in the corresponding SYNC data endpoint.

PreviousAmazon Search API: Async Structured Data in JavaNextAmazon Reviews API: Async Structured Data in Java

Last updated 7 months ago

Was this helpful?