Ebay Product Page API (Async)

This endpoint will retrieve product data from an Ebay product pages (/itm/) and transform it into usable JSON.

Single product 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 + "\", "
                + "\"productId\": \"PRODUCTID\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"YYYY\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/ebay/product");
            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 products 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 + "\", "
                + "\"productIds\": [\"PRODUCTID1\", \"PRODUCTID2\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"YYYY\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/ebay/product");
            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();
        }
    }
}

Sample Response

Single Product Request:

{
    "id": "ad85f5f5-2e47-4d9b-bf6e-ed1e7e8ac53d",
    "attempts": 0,
    "status": "running",
    "statusUrl": "https://async.scraperapi.com/jobs/ad85f5f5-2e47-4d9b-bf6e-ed1e7e8ac53d",
    "productId": "315668246442",
    "country_code": "us",
    "tld": "com",
    "supposedToRunAt": "2024-11-01T08:00:29.732Z"
}

Multiple Products Request:

{
    "id": "44a7bf0f-3dfd-46ac-9fbd-b17905cbfa60",
    "attempts": 0,
    "status": "running",
    "statusUrl": "https://async.scraperapi.com/jobs/44a7bf0f-3dfd-46ac-9fbd-b17905cbfa60",
    "productId": "315668246442",
    "country_code": "us",
    "tld": "com"
},

{
    "id": "5af00d62-70a0-40d3-bfd6-f79fa56887ee",
    "attempts": 0,
    "status": "running",
    "statusUrl": "https://async.scraperapi.com/jobs/5af00d62-70a0-40d3-bfd6-f79fa56887ee",
    "productId": "126718182209",
    "country_code": "us",
    "tld": "com"
}

Last updated