Walmart Category API (Async)
This endpoint will retrieve Walmart product list for a specified product category.
Single query 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 + "\", "
+ "\"category\": \"CATEGORY\", "
+ "\"tld\": \"TLD\", "
+ "\"page\": \"PAGE\", "
+ "\output_format\": \"FORMAT\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"CALLBACK\""
+ "}}";
URL url = new URL("https://async.scraperapi.com/structured/walmart/category");
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 query 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 + "\", "
+ "\"categories\": [\"CATEGORY1\", \"CATEGORY2\"], "
+ "\"tld\": \"TLD\", "
+ "\"page\": \"PAGE\", "
+ "\output_format\": \"FORMAT\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"CALLBACK\""
+ "}}";
URL url = new URL("https://async.scraperapi.com/structured/walmart/category");
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();
}
}
}
REQUIRED | |
---|---|
| User account’s normal API key. |
| Walmart category id. Example: 3944_1089430_37807 |
OPTIONAL | |
---|---|
| Pagination. Example: 3 |
| Top level domain. Valid values are com and ca |
| For structured data methods we offer CSV and JSON output. JSON is default if parameter is not added. Options:
|
Sample Response
For single query requests:
{
"id": "ce93d237-4595-4508-8d81-f94365fc542c",
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/ce93d237-4595-4508-8d81-f94365fc542c",
"category": "3944_1089430_37807",
}
For multiple query requests:
[
{
"id": "ec4a6153-368c-440e-8c02-6c302a661db9",
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/ec4a6153-368c-440e-8c02-6c302a661db9",
"category": "3920"
},
{
"id": "8a024945-f74a-4327-80e3-12f26c737ec6",
"status": "running",
"statusUrl": "https://async.scraperapi.com/jobs/8a024945-f74a-4327-80e3-12f26c737ec6",
"category": "3944_1089430_37807"
}
]
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.
Last updated