NAVNavbar
Logo
php python csharp java

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.20200416",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.0899 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "04171054-0696-0179-0000-e56ea58342c5",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.0290 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "merchant",
        "google",
        "products",
        "task_get",
        "advanced",
        "04171054-0696-0179-0000-e56ea58342c5"
      ],
      "data": {
        "se_type": "shopping",
        "api": "merchant",
        "function": "products",
        "se": "google",
        "language_code": "en",
        "location_code": 2840,
        "keyword": "iphone",
        "price_min": "5",
        "priority": 2,
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "keyword": "iphone",
          "type": "shopping",
          "se_domain": "google.com",
          "location_code": 2840,
          "language_code": "en",
          "check_url": "https://www.google.com/search?q=iphone&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": "2020-04-17 07:55:01 +00:00",
          "spell": null,
          "item_types": [
            "google_shopping_serp"
          ],
          "items_count": 100,
          "items": [
            {
              "type": "google_shopping_sponsored_carousel",
              "rank_group": 1,
              "rank_absolute": 1,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[1]",
              "title": "Apple iPhone 7 Plus, 32GB, Rose Gold, Refurbished, Boost Mobile",
              "tags": [
                "Boost Mobile",
                "Free shipping"
              ],
              "price": 299.99,
              "currency": "USD",
              "product_rating": null
            },
            {
              "type": "google_shopping_sponsored_carousel",
              "rank_group": 1,
              "rank_absolute": 1,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[2]",
              "title": "iPhone 7, 128GB, Rose Gold, Pre-Owned, Boost Mobile",
              "tags": [
                "Boost Mobile",
                "Free shipping"
              ],
              "price": 149.99,
              "currency": "USD",
              "product_rating": null
            },
            {
              "type": "google_shopping_sponsored_carousel",
              "rank_group": 1,
              "rank_absolute": 1,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/g-scrolling-carousel[1]/div[1]/div[1]/div[1]/div[3]",
              "title": "iPhone 7, 128GB, Silver, Pre-Owned, Boost Mobile",
              "tags": [
                "Boost Mobile",
                "Free shipping"
              ],
              "price": 149.99,
              "currency": "USD",
              "product_rating": null
            },
            {
              "type": "google_shopping_serp",
              "rank_group": 1,
              "rank_absolute": 2,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]",
              "domain": "www.bestbuy.com",
              "title": "Apple iPhone 11 Pro - 512 GB - Silver - Unlocked - CDMA/GSM",
              "description": "A transformative triple-camera system that adds tons of capability without complexity. An unprecedented leap in battery life. And a mind-blowing chip that doubles down on ...",
              "url": "https://www.bestbuy.com/site/apple-iphone-11-pro-512gb-silver-sprint/6341468.p?skuId=6341468&ref=212&loc=1",
              "shopping_url": "https://www.google.com/shopping/product/2347875553335165275?q=iphone&num=100&ie=UTF-8&oe=UTF-8&hl=en&gl=US&gws_rd=cr&uule=a+cm9sZToxIHByb2R1Y2VyOjEyIHByb3ZlbmFuY2U6NiB0aW1lc3RhbXA6MTU4ODE1MjI0NjAwMDAwMCBsYXRsbmd7IGxhdGl0dWRlX2U3OjQyMzM2NTYyMCBsb25naXR1ZGVfZTc6LTcxMDQ4OTMwMCB9IHJhZGl1czoyMDA%3D&prds=epd:8380458977103570348,prmr:1&sa=X&ved=0ahUKEwj9q6qVqI3pAhVmQt8KHZj4ATYQ8gIIixI",
              "tags": [
                "Apple",
                "iPhone",
                "iPhone 11",
                "iPhone 11 Pro",
                "iOS",
                "5.8″",
                "Facial Recognition",
                "12 MP front camera",
                "12 MP rear camera",
                "4G LTE"
              ],
              "price": 350,
              "currency": "USD",
              "product_id": "2347875553335165275",
              "reviews_count": "3791",
              "is_best_match": false,
              "product_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.7",
                "votes_count": 3791,
                "rating_max": null
              },
              "shop_rating": null
            },
            {
              "type": "google_shopping_serp",
              "rank_group": 2,
              "rank_absolute": 3,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[3]/div[1]/div[1]/div[2]",
              "domain": "www.apple.com",
              "title": "Apple iPhone SE (2020) - 64 GB - (PRODUCT)RED - Unlocked",
              "description": "Brilliant 4.7\" Retina HD display. Speed and security of Touch ID. Water resistant to 1 meter for 30 minutes. All in a slim, light design. A13 Bionic is the fastest chip ever in ...",
              "url": "https://www.apple.com/us/xc/product/MX9Q2",
              "shopping_url": "https://www.google.com/shopping/product/11096977472486545307?q=iphone&num=100&ie=UTF-8&oe=UTF-8&hl=en&gl=US&gws_rd=cr&uule=a+cm9sZToxIHByb2R1Y2VyOjEyIHByb3ZlbmFuY2U6NiB0aW1lc3RhbXA6MTU4ODE1MjI0NjAwMDAwMCBsYXRsbmd7IGxhdGl0dWRlX2U3OjQyMzM2NTYyMCBsb25naXR1ZGVfZTc6LTcxMDQ4OTMwMCB9IHJhZGl1czoyMDA%3D&prds=epd:2983614401392584920,prmr:1&sa=X&ved=0ahUKEwj9q6qVqI3pAhVmQt8KHZj4ATYQ8gIInhI",
              "tags": [
                "Apple",
                "iPhone",
                "iPhone SE",
                "iOS",
                "4.7″",
                "Fingerprint Scanner",
                "7 MP front camera",
                "12 MP rear camera",
                "Straight Talk",
                "Verizon"
              ],
              "price": 399,
              "currency": "USD",
              "product_id": "11096977472486545307",
              "reviews_count": "101",
              "is_best_match": false,
              "product_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.09",
                "votes_count": 101,
                "rating_max": null
              },
              "shop_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Percents",
                "value": "93",
                "votes_count": null,
                "rating_max": null
              }
            },
            {
              "type": "google_shopping_serp",
              "rank_group": 3,
              "rank_absolute": 4,
              "position": "left",
              "xpath": "/html[1]/body[1]/div[7]/div[2]/div[9]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/div[3]/div[1]/div[1]/div[3]",
              "domain": "www.sprint.com",
              "title": "Apple iPhone 11 - 64 GB - Purple - Sprint - CDMA/GSM",
              "description": "iPhone 11. Just the right amount of everything. A new dual-camera system captures more of what you see and love. The fastest chip ever in a smartphone and all-day battery life ...",
              "url": "https://www.sprint.com/en/shop/cell-phones/apple-iphone-11.html?ensembleId=190199220218&duration=18&contractType=lease&isDeepLinked=true",
              "shopping_url": "https://www.google.com/shopping/product/417852268187640834?q=iphone&num=100&ie=UTF-8&oe=UTF-8&hl=en&gl=US&gws_rd=cr&uule=a+cm9sZToxIHByb2R1Y2VyOjEyIHByb3ZlbmFuY2U6NiB0aW1lc3RhbXA6MTU4ODE1MjI0NjAwMDAwMCBsYXRsbmd7IGxhdGl0dWRlX2U3OjQyMzM2NTYyMCBsb25naXR1ZGVfZTc6LTcxMDQ4OTMwMCB9IHJhZGl1czoyMDA%3D&prds=epd:2660153800919274426,prmr:1&sa=X&ved=0ahUKEwj9q6qVqI3pAhVmQt8KHZj4ATYQ8gIIthI",
              "tags": [
                "Apple",
                "iPhone",
                "iPhone 11",
                "iOS",
                "6.1″",
                "Facial Recognition",
                "12 MP front camera",
                "12 MP rear camera",
                "4G LTE",
                "6.84 oz"
              ],
              "price": 15,
              "currency": "USD",
              "product_id": "417852268187640834",
              "reviews_count": "12315",
              "is_best_match": false,
              "product_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.61",
                "votes_count": 12315,
                "rating_max": null
              },
              "shop_rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Percents",
                "value": "90",
                "votes_count": null,
                "rating_max": 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.

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
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 array 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 format: “year-month-date:minutes:UTC_difference_hours:UTC_difference_minutes”
example:
2019-11-15 12:57:46 +00:00
            spell array 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
            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_serp, google_shopping_sponsored_carousel
            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 product title
                tags array tags assigned to the product
                price integer product price
example:
384.99
                currency string currency in the ISO format
example:
USD
                product_rating array product rating
the product popularity rate based on product reviews
            ‘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 integer product price
example:
384.99
                currency string currency in the ISO format
example:
USD
                product_id integer 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
                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 array 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 integer 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 array 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 integer 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

‌‌