Google Shopping API (Async)

This endpoint will retrieve shopping data from a Google shopping result page and transform it into usable JSON.

Single Query Request:

<?php

$curl = curl_init();

$data = json_encode(array(
    'apiKey' => 'APIKEY',
    'query' => 'QUERY',
    'tld' => 'TLD',
    'uule' => 'UULE',
    'num' => 'NUM',
    'hl' => 'HOSTLANGUAGE',
    'gl' => 'GUESTLANGUAGE',
    'ie' => 'QUERYENCODING',
    'oe' => 'RESULTENCODING',
    'start' => 'START',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'CALLBACK'
    )
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/shopping',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);

?>

Multiple Query Request:

<?php

$curl = curl_init();

$data = json_encode(array(
    'apiKey' => 'APIKEY',
    'queries' => array('QUERY1', 'QUERY2', 'QUERY3'),
    'tld' => 'TLD',
    'uule' => 'UULE',
    'num' => 'NUM',
    'hl' => 'HOSTLANGUAGE',
    'gl' => 'GUESTLANGUAGE',
    'ie' => 'QUERYENCODING',
    'oe' => 'RESULTENCODING',
    'start' => 'START',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'CALLBACK'
    )
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/shopping',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);

?>

Multiple Parameters can be used with this method:

Sample Response

Single Query Request:

{
	"id": "89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"status": "running",
	"statusUrl": "http://async.scraperapi.com/structured/google/shopping/89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"query": "Skateboard"
}

Multiple Query Request:

[
	{
		"id": "2955ad23-c812-475c-bc52-572576815d78",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/shopping/2955ad23-c812-475c-bc52-572576815d78",
		"query": "Skateboard"
	},
	{
		"id": "120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/shopping/120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"query": "Charcoal Grill"
	}
]

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