This endpoint will retrieve reviews for a specified product from a Walmart reviews page and transform it into usable JSON.
try {
String apiKey = "APIKEY";
String product = "5253396052";
String url = "https://api.scraperapi.com/structured/walmart/review?api_key=2b47bf207cdd9c147b2bb69a779ec6d3&product_id=1347882796" + apiKey + "&product_id=" + product;
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();
}
{
"product_name": "HOBIBEAR Boys Sneakers Kids Running Lightweight Breathable Sport Tennis Shoes(Toddles/Little Kids/Big Kids)",
"product_url": "https://www.walmart.com/ip/HOBIBEAR-Boys-Sneakers-Kids-Running-Lightweight-Breathable-Sport-Tennis-Shoes-Toddles-Little-Kids-Big-Kids/1347882796",
"rating": 4.0556,
"review_count": 18,
"reviews": [
{
"title": "good",
"text": "design,price and true size overall like.",
"author": "vi",
"date_published": "3/10/2024",
"rating": 4,
"positive_feedback": 0,
"negative_feedback": 0
},
{
"title": "Didn't last long",
"text": "Did not hold up very long to little boy running/ playing/ activities.",
"author": "firefli529",
"date_published": "5/11/2024",
"rating": 3,
"positive_feedback": 0,
"negative_feedback": 0,
"badges": [
"Verified Purchase",
"Incentivized Review"
]
},
...
}