NAVNavbar
Logo
cURL php NodeJS Python cSharp

Get Google Shopping Products Results by id

Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-dashboard

<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-dashboard
$client = new RestClient($api_url, null, 'login', 'password');

try {
   $result = array();
   // #1 - using this method you can get a list of completed tasks
   // GET /v3/merchant/google/products/tasks_ready
   $tasks_ready = $client->get('/v3/merchant/google/products/tasks_ready');
   // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors
   if (isset($tasks_ready['status_code']) AND $tasks_ready['status_code'] === 20000) {
      foreach ($tasks_ready['tasks'] as $task) {
         if (isset($task['result'])) {
            foreach ($task['result'] as $task_ready) {
               // #2 - using this method you can get results of each completed task
               // GET /v3/merchant/google/products/task_get/advanced/$id
               if (isset($task_ready['endpoint_advanced'])) {
                  $result[] = $client->get($task_ready['endpoint_advanced']);
               }
               // #3 - another way to get the task results by id
               // GET /v3/merchant/google/products/task_get/advanced/$id
               /*
               if (isset($task_ready['id'])) {
                  $result[] = $client->get('/v3/merchant/google/products/task_get/advanced/' . $task_ready['id']);
               }
               */
            }
         }
      }
   }
   print_r($result);
   // do something with result
} catch (RestClientException $e) {
   echo "\n";
   print "HTTP code: {$e->getHttpCode()}\n";
   print "Error code: {$e->getCode()}\n";
   print "Message: {$e->getMessage()}\n";
   print  $e->getTraceAsString();
   echo "\n";
}
$client = null;
?>

The above command returns JSON structured like this:

{
  "version": "0.1.20210617",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.1346 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "06181608-2806-0179-0000-aff47b17cd54",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.0367 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "merchant",
        "google",
        "products",
        "task_get",
        "advanced",
        "06181608-2806-0179-0000-aff47b17cd54"
      ],
      "data": {
        "se_type": "shopping",
        "se": "google",
        "api": "merchant",
        "function": "products",
        "language_code": "en",
        "location_code": 2840,
        "keyword": "buy iphone",
        "price_min": "5",
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "keyword": "buy iphone",
          "type": "shopping",
          "se_domain": "google.com",
          "location_code": 2840,
          "language_code": "en",
          "check_url": "https://www.google.com/search?q=buy%20iphone&num=100&tbm=shop&ie=UTF-8&oe=UTF-8&tbs=vw%3A1%2Cmr%3A1%2Cprice%3A1%2Cppr_min%3A5&hl=en&gl=US&gws_rd=cr&uule=w+CAIQIFISCQs2MuSEtepUEUK33kOSuTsc",
          "datetime": "2021-06-18 13:08:24 +00:00",
          "spell": null,
          "item_types": [
            "google_shopping_serp",
            "google_shopping_sponsored_carousel",
            "google_shopping_paid"
          ],
          "items_count": 160,
          "items": [
            {
              "type": "google_shopping_sponsored_carousel",
              "rank_group": 1,
              "rank_absolute": 1,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]",
              "title": "See iphone 12",
              "items": [
                {
                  "type": "google_shopping_sponsored_carousel_element",
                  "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[1]",
                  "title": "Apple iPhone 12 - 128GB - Purple - AT&T",
                  "tags": null,
                  "seller": "36",
                  "price": 36,
                  "currency": "USD",
                  "product_rating": {
                    "type": "rating_element",
                    "position": "left",
                    "rating_type": "Max5",
                    "value": "4.5",
                    "votes_count": 10921,
                    "rating_max": "5"
                  },
                  "product_images": null,
                  "shop_ad_aclk": "DChcSEwiBrvj3yoDyAhUCrsgKHXYgCu8YABAGGgJxdQ",
                  "delivery_info": null
                },
                {
                  "type": "google_shopping_sponsored_carousel_element",
                  "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[2]",
                  "title": "Apple iPhone 12 mini 256 GB in (PRODUCT)RED with installment",
                  "tags": null,
                  "seller": "24",
                  "price": 24,
                  "currency": "USD",
                  "product_rating": {
                    "type": "rating_element",
                    "position": "left",
                    "rating_type": "Max5",
                    "value": "4.5",
                    "votes_count": 4867,
                    "rating_max": "5"
                  },
                  "product_images": [
                    "https://encrypted-tbn1.gstatic.com/shopping?q=tbn:ANd9GcTRqvBQrPopEaAn3sChYmVcUtrB9RpHTumiB_DIcm8v39Yn-ZcvtMsOnBIYBw&usqp=CAE"
                  ],
                  "shop_ad_aclk": "DChcSEwiBrvj3yoDyAhUCrsgKHXYgCu8YABAOGgJxdQ",
                  "delivery_info": null
                },
                {
                  "type": "google_shopping_sponsored_carousel_element",
                  "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[3]",
                  "title": "iPhone 12 - 128GB Blue - Unlocked & SIM free - Apple",
                  "tags": [
                    "Free shipping"
                  ],
                  "seller": "Apple",
                  "price": 879,
                  "currency": "USD",
                  "product_rating": null,
                  "product_images": [
                    "https://encrypted-tbn1.gstatic.com/shopping?q=tbn:ANd9GcT8OSIrOxU_JQj6BmOD7hxyqn8ZrEiH_HYYuT5jxpGQ3tsumiLUEEVig4AC7XFAVnB8Jqh-kLoF&usqp=CAE"
                  ],
                  "shop_ad_aclk": "DChcSEwiBrvj3yoDyAhUCrsgKHXYgCu8YABAWGgJxdQ",
                  "delivery_info": null
                },
                {
                  "type": "google_shopping_sponsored_carousel_element",
                  "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[4]",
                  "title": "Apple iPhone 12 - Purple - 64GB (with 24 monthly payments)",
                  "tags": [
                    "Free shipping"
                  ],
                  "seller": "24",
                  "price": 24,
                  "currency": "USD",
                  "product_rating": null,
                  "product_images": [
                    "https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcRydW9tf2yFSSmYr1ahHZnVAWHMcwJ1hZw85lmEdrAlpSOShPo_n_kU1Z4ITmmT3DlM7MqA71jn&usqp=CAE"
                  ],
                  "shop_ad_aclk": "DChcSEwiBrvj3yoDyAhUCrsgKHXYgCu8YABAHGgJxdQ",
                  "delivery_info": null
                },
                {
                  "type": "google_shopping_sponsored_carousel_element",
                  "xpath": "/html[1]/body[1]/div[6]/div[1]/div[3]/div[2]/div[1]/div[3]/div[2]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[5]",
                  "title": "Apple iPhone 12 mini 128 GB in Blue with installment",
                  "tags": null,
                  "seller": "24",
                  "price": 24,
                  "currency": "USD",
                  "product_rating": {
                    "type": "rating_element",
                    "position": "left",
                    "rating_type": "Max5",
                    "value": "4.5",
                    "votes_count": 4867,
                    "rating_max": "5"
                  },
                  "product_images": [
                    "https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcT9IExU9GAsdBcOoHav2G_chuMBfFgWcE8cLgXwCal3wyVjcQ_P2IMOc4t6ayE&usqp=CAE"
                  ],
                  "shop_ad_aclk": "DChcSEwiBrvj3yoDyAhUCrsgKHXYgCu8YABAQGgJxdQ",
                  "delivery_info": null
                }
              ]
            },
            {
              "type": "google_shopping_serp",
              "rank_group": 1,
              "rank_absolute": 2,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[1]/div[8]/div[4]/div[1]/div[2]/div[2]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]",
              "domain": null,
              "title": "Apple iPhone 12 - 128 GB  - Black - Unlocked",
              "description": "5G to download movies on the fly and stream high-quality video. Beautifully bright 6.1-inch Super Retina XDR display. Ceramic Shield with 4x better drop performance. Incredible ...",
              "url": null,
              "shopping_url": null,
              "tags": [
                "Apple",
                "iPhone",
                "iPhone 12",
                "iOS",
                "6.1″",
                "Facial Recognition",
                "12 MP rear camera",
                "Smartphone",
                "With Wireless Charging",
                "Unlocked"
              ],
              "price": 1099.99,
              "old_price": null,
              "currency": "USD",
              "product_id": "3805205938126402128",
              "data_docid": "9874368152810998595",
              "seller": "Back Market",
              "additional_specifications": null,
              "reviews_count": 9134,
              "is_best_match": false,
              "product_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.53",
                "votes_count": 9134,
                "rating_max": null
              },
              "shop_rating": null,
              "product_images": [
                "https://encrypted-tbn3.gstatic.com/shopping?q=tbn:ANd9GcTyvlWQ7vfbfcOhpPl9JaxmIitkcLvBuA-K3IFheTQWgLD2uUZ_j6GAo8PXWNtqbBo7Xdw4NKo&usqp=CAE",
                "https://encrypted-tbn3.gstatic.com/shopping?q=tbn:ANd9GcQWtZU1MxfoHzY8KNjNkD69mxqXedHzPnfOfzSFL2TWgkDYX8k&usqp=CAE",
                "https://encrypted-tbn3.gstatic.com/shopping?q=tbn:ANd9GcR2y2S5BmNwtg2yaK6eykVZv18SBxs-aOOjuA7mZSLAlElbBgf4qODGR6WsRYVL8iRE9j-LUCo&usqp=CAE",
                "https://encrypted-tbn1.gstatic.com/shopping?q=tbn:ANd9GcTwV5cviDm6KAHpx5rxVmJpK3lz2qlQlby6cX3qzj3rl9T_IuERy44_GPXS4fXEWI1eqQnuw9c&usqp=CAE"
              ],
              "shop_ad_aclk": "DChcSEwikz5aloKHxAhX8R5EFHc8oBzsYABA-GgJscg",
              "delivery_info": {
                "delivery_message": "$124.88 delivery",
                "delivery_price": {
                  "current": 124.88,
                  "regular": null,
                  "max_value": null,
                  "currency": "USD",
                  "is_price_range": false,
                  "displayed_price": "$124.88"
                },
                "stores_count_info": {
                  "count": 5,
                  "displayed_text": "Compare prices from 5+ stores",
                  "count_from_text": false
                }
              }
            },
            {
              "type": "google_shopping_paid",
              "rank_group": 1,
              "rank_absolute": 103,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[1]/div[8]/div[4]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]",
              "domain": "www.visible.com",
              "title": "Visible® $40/mo Phone Service - Up to $150 Prepaid Mastercard",
              "description": "Includes Unlimited Data, Messages & Minutes on Verizon’s 4G LTE Network. Switch to Visible. Get up to $150 Prepaid Mastercard when buying an iPhone & switch to Visible. Terms Apply. Now with 5G. 0% APR Affirm Financing. As low as $25/mo/line.",
              "url": "https://www.visible.com/apple",
              "shop_ad_aclk": null
            }
          ]
        }
      ]
    }
  ]
}

Description of the fields for sending a request:

Field name Type Description
id string task identifier
unique task identifier in our system in the UUID format
you will be able to use it within 30 days to request the results of the task at any time

‌‌‌‌
‌‌As a response of the API server, you will receive JSON-encoded data containing a tasks array with the information specific to the set tasks.

You can also get all available SERP features by making a request to the following Sandbox URL:
https://sandbox.dataforseo.com/v3/merchant/google/products/task_get/advanced/00000000-0000-0000-0000-000000000000
The response will include all available items in the Google Merchant Product Advanced endpoint with the fields containing dummy data.
You won’t be charged for using Sandbox endpoints.

Description of the fields in the results array:

Field name Type Description
version string the current version of the API
status_code integer general status code
you can find the full list of the response codes here
Note: we strongly recommend designing a necessary system for handling related exceptional or error conditions
status_message string general informational message
you can find the full list of general informational messages here
time string execution time, seconds
cost float total tasks cost, USD
tasks_count integer the number of tasks in the tasks array
tasks_error integer the number of tasks in the tasks array that were returned an error
tasks array array of tasks
        id string task identifier
unique task identifier in our system in the UUID format
        status_code integer status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
you can find the full list of the response codes here
        status_message string informational message of the task
you can find the full list of general informational messages here
        time string execution time, seconds
        cost float cost of the task, USD
        result_count integer number of elements in the result array
        path array URL path
        data object contains the same parameters that you specified in the POST request
        result array array of results
            keyword string keyword received in a POST array
keyword is returned with decoded %## (plus symbol ‘+’ will be decoded to a space character)
            type string search engine type in a POST array
            se_domain string search engine domain in a POST array
            location_code integer location code in a POST array
            language_code string language code in a POST array
            check_url string direct URL to Google Shopping results
you can use it to make sure that we provided accurate results
            datetime string date and time when the result was received
in the UTC format: “yyyy-mm-dd hh-mm-ss +00:00”
example:
2019-11-15 12:57:46 +00:00
            spell object autocorrection of the search engine
if the search engine provided results for a keyword that was corrected, we will specify the keyword corrected by the search engine and the type of autocorrection
                keyword string keyword obtained as a result of search engine autocorrection
the results will be provided for the corrected keyword
                type string type of autocorrection
possible values:
did_you_mean, showing_results_for, no_results_found_for, including_results_for
            item_types array types of search results found in Google Shopping SERP
contains types of all search results (items) found in the returned SERP
possible item types:
google_shopping_sponsored_carousel, google_shopping_paid, google_shopping_serp
            items_count integer the number of results returned in the items array
            items array items in SERP
            ‘google_shopping_sponsored_carousel’ element
                type string type of element = ‘google_shopping_sponsored_carousel’
                rank_group integer position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP
absolute position among all the elements found in Google Shopping SERP
                position string alignment of the element in SERP
can take the following values:
left, right
                xpath string XPath of the element
                title string title of the element
                items array additional items present in the element
if there are none, equals null
                    type string type of element = ‘google_shopping_sponsored_carousel_element‘
                    xpath string XPath of the element
                    title string product title
                    tags array tags assigned to the product
                    seller string name of the seller
the name of the company that placed a corresponding product on Google Shopping
                    price float product price
example:
384.99
                    currency string currency in the ISO format
example:
USD
                    product_rating object product rating
the product popularity rate based on product reviews
                        type string type of element = ‘rating_element’
                        position string the alignment of the element in Google Shopping SERP
possible values:
left, right
                        rating_type string the type of rating
here you can find the following elements: Max5, Percents, CustomMax
                        value string value of the rating
                        votes_count integer the amount of feedback
                        rating_max integer the maximum value for a rating_type
                    product_images array URLs to the images of the product
the first URL in the array is the featured image of the product
                    shop_ad_aclk string unique ad click referral parameter
using this parameter you can get a URL of the advertisement in Google Shopping Sellers Ad URL
                    delivery_info object delivery information
delivery information including free and fast delivery date ranges
                        delivery_message string delivery information
message accompanying the delivery information as posted by the seller
                        delivery_price object price for the delivery
price of the delivery based on the location you specified in the POST request;
if free delivery is available, the value is null
                            current float current delivery price
                           regular float regular undiscounted delivery price
                           max_value float maximum undiscounted delivery price
                           currency string currency in the ISO format
                           is_price_range boolean indicates whether the delivery price is a range
                           displayed_price string price line provided as displayed in Google Shopping listing
            ‘google_shopping_paid’ element
                type string type of element = ‘google_shopping_paid’
                rank_group integer position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP
absolute position among all the elements found in Google Shopping SERP
                position string alignment of the element in SERP
can take the following values:
left, right
                xpath string XPath of the element
                domain string domain in SERP
                title string product title
                description string description of the product in Google Shopping SERP
                url string URL to the product page on the seller’s website
                shop_ad_aclk string unique ad click referral parameter
using this parameter you can get a URL of the advertisement in Google Shopping Sellers Ad URL
            ‘google_shopping_serp’ element
                type string type of element = ‘google_shopping_serp’
                rank_group integer position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP
absolute position among all the elements found in Google Shopping SERP
                position string alignment of the element in SERP
can take the following values:
left, right
                xpath string XPath of the element
                domain string domain in SERP
                title string product title
                description string description of the product in Google Shopping SERP
                url string URL to the product page on the seller’s website
                shopping_url string URL to the product page on Google Shopping
                tags array tags assigned to the product
                price float product price
example:
384.99
                old_price float product old price
displayed if the product price has been changed
example:
499
                currency string currency in the ISO format
example:
USD
                product_id string unique product identifier on Google Shopping
note that there is no full list of possible values as the product_id is a dynamic value assigned by Google
if there are no values, you will get null
example:
4485466949985702538
learn more about the parameter in this help center guide
                data_docid string unique identifier of the SERP data element
note that there is no full list of possible values as the data_docid is a dynamic value assigned by Google
example:
17363035694596624076
                seller string name of the seller
the name of the company that placed a corresponding product on Google Shopping
                additional_specifications object object containing additional url parameters
you can get more details about the product by using this object in the POST request to the Google Shopping Product Specification and Google Shopping Sellers endpoint
                reviews_count integer number of product reviews
indicates the number of reviews left by users on Google Shopping
if there are no values, you will get null
                is_best_match boolean “best match” label
if the value is true, the product is marked with the “best match” label
if there are no values, you will get null
                product_rating object product rating
the product popularity rate based on product reviews
                    type string type of element = ‘rating_element’
                    rating_type string the type of rating
here you can find the following elements: Max5, Percents, CustomMax
                    value string the value of the rating
                    votes_count integer the amount of feedback
                    rating_max integer the maximum value for a rating_type
                    position string alignment of the element in Google Shopping SERP
possible values:
left, right
                shop_rating object shop rating
the popularity rate of the seller based on user reviews
                    type string type of element = ‘rating_element’
                    rating_type string the type of rating
here you can find the following elements: Max5, Percents, CustomMax
                    value string value of the rating
                    votes_count integer the amount of feedback
                    rating_max integer the maximum value for a rating_type
                    position string the alignment of the element in Google Shopping SERP
possible values:
left, right
                product_images array URLs to the images of the product
the first URL in the array is the featured image of the product
                shop_ad_aclk string unique ad click referral parameter
using this parameter you can get a URL of the advertisement in Google Shopping Sellers Ad URL
                delivery_info object delivery information
delivery information including free and fast delivery date ranges
                    delivery_message string delivery information
message accompanying the delivery information as posted by the seller
                    delivery_price object price for the delivery
price of the delivery based on the location you specified in the POST request;
if free delivery is available, the value is null
                       current float current delivery price
                       regular float regular undiscounted delivery price
                       max_value float maximum undiscounted delivery price
                       currency string currency in the ISO format
                       is_price_range boolean indicates whether the delivery price is a range
                       displayed_price string price line provided as displayed in Google Shopping listing
                stores_count_info object stores count information
contains information about the number of stores that offer the same product
                       count string number of stores that offer the product
                       displayed_text string text displayed on the Google Shopping page
                       count_from_text boolean whether the number of stores is taken from text
indicates whether the number of stores is taken from displayed_text;
if the API finds the exact number of stores in the HTML code of the Google Shopping page, this parameter is false;
if the API cannot find the number of stores in the HTML code of the page, it takes the number from the displayed_text;
in this case, the parameter is true
            ‘related_searches’ element
                type string type of element = ‘related_searches’
                rank_group integer position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP
absolute position among all the elements found in Google Shopping SERP
                position string alignment of the element in SERP
can take the following values:
left, right
                xpath string XPath of the element
                items array additional items present in the element
contains a list of related keywords;
if there are none, equals null

‌‌