NAVNavbar
Logo
php python csharp java

Get Amazon 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/amazon/products/tasks_ready
   $tasks_ready = $client->get('/v3/merchant/amazon/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/amazon/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/amazon/products/task_get/advanced/$id
               /*
               if (isset($task_ready['id'])) {
                  $result[] = $client->get('/v3/merchant/amazon/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.1688 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "04170913-0696-0179-0000-707d6a06f64b",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.0685 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "merchant",
        "amazon",
        "products",
        "task_get",
        "advanced",
        "04170913-0696-0179-0000-707d6a06f64b"
      ],
      "data": {
        "se_type": "organic",
        "api": "merchant",
        "function": "products",
        "se": "amazon",
        "location_name": "United States",
        "language_name": "English (United States)",
        "keyword": "shoes",
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "keyword": "shoes",
          "type": "organic",
          "se_domain": "amazon.com",
          "location_code": 2840,
          "language_code": "en_US",
          "check_url": "https://www.amazon.com/s/?field-keywords=shoes&page=1&language=en_US",
          "datetime": "2020-04-17 06:16:58 +00:00",
          "spell": null,
          "item_types": [
            "amazon_serp",
            "amazon_paid"
          ],
          "se_results_count": 26176,
          "items_count": 121,
          "items": [
            {
              "type": "amazon_serp",
              "rank_group": 1,
              "rank_absolute": 1,
              "xpath": "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/span[4]/div[1]/div[1]",
              "domain": "www.amazon.com",
              "title": "Men's Gel-Venture 6 Running Shoe",
              "url": "https://www.amazon.com/ASICS-Gel-Venture-Running-Phantom-Medium/dp/B01MTKZF4M/ref=sxin_0?ascsubtag=amzn1.osa.3c553e88-eee2-4983-9752-5ae9e6a9eecc.ATVPDKIKX0DER.en_US&creativeASIN=B01MTKZF4M&cv_ct_cx=shoes&cv_ct_id=amzn1.osa.3c553e88-eee2-4983-9752-5ae9e6a9eecc.ATVPDKIKX0DER.en_US&cv_ct_pg=search&cv_ct_wn=osp-single-source&dchild=1&keywords=shoes&linkCode=oas&pd_rd_i=B01MTKZF4M&pd_rd_r=e9f604f2-48c1-407e-ad2f-cef18df347f0&pd_rd_w=UU54x&pd_rd_wg=PzhSz&pf_rd_p=b9bea1c2-6981-439e-9086-1a31b4eafe7d&pf_rd_r=B18RERC2QAMZ2D5HC9YN&psc=1&qid=1587104205&sr=1-1-72d6bf18-a4db-4490-a794-9cd9552ac58d&tag=the-angle-20",
              "price_from": 54.95,
              "price_to": 45,
              "currency": "USD",
              "data_asin": "B01MTKZF4M",
              "rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.6",
                "votes_count": 536,
                "rating_max": "5"
              },
              "is_amazon_choice": false
            },
            {
              "type": "amazon_serp",
              "rank_group": 2,
              "rank_absolute": 2,
              "xpath": "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/span[4]/div[1]/div[2]",
              "domain": "www.amazon.com",
              "title": "Men's Charged Assert 8 Running Shoe",
              "url": "https://www.amazon.com/Under-Armour-Charged-Assert-Running/dp/B07G82D89J/ref=sr_1_1?dchild=1&keywords=shoes&qid=1587104205&sr=8-1",
              "price_from": 49.96,
              "price_to": null,
              "currency": "USD",
              "data_asin": "B07G82D89J",
              "rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.6",
                "votes_count": 2854,
                "rating_max": "5"
              },
              "is_amazon_choice": false
            },
            {
              "type": "amazon_serp",
              "rank_group": 3,
              "rank_absolute": 3,
              "xpath": "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/span[4]/div[1]/div[3]",
              "domain": "www.amazon.com",
              "title": "Women's Cloudfoam Pure Running Shoe",
              "url": "https://www.amazon.com/adidas-Performance-Womens-Cloudfoam-Running/dp/B071LF9R6G/ref=sr_1_2?dchild=1&keywords=shoes&qid=1587104205&sr=8-2",
              "price_from": 45,
              "price_to": null,
              "currency": "USD",
              "data_asin": "B071LF9R6G",
              "rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.7",
                "votes_count": 7318,
                "rating_max": "5"
              },
              "is_amazon_choice": false
            },
            {
              "type": "amazon_serp",
              "rank_group": 4,
              "rank_absolute": 4,
              "xpath": "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/span[4]/div[1]/div[4]",
              "domain": "www.amazon.com",
              "title": "Men's Seeley Running Shoe",
              "url": "https://www.amazon.com/adidas-Originals-Seeley-Running-White/dp/B0106J7SJU/ref=sr_1_3?dchild=1&keywords=shoes&qid=1587104205&sr=8-3",
              "price_from": null,
              "price_to": null,
              "currency": null,
              "data_asin": "B0106J7SJU",
              "rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.5",
                "votes_count": 3386,
                "rating_max": "5"
              },
              "is_amazon_choice": false
            },
            {
              "type": "amazon_serp",
              "rank_group": 5,
              "rank_absolute": 5,
              "xpath": "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/span[4]/div[1]/div[5]",
              "domain": "www.amazon.com",
              "title": "Men's Gel-Venture 6 Running Shoe",
              "url": "https://www.amazon.com/ASICS-Gel-Venture-Running-Phantom-Medium/dp/B01N02WUM3/ref=sr_1_4?dchild=1&keywords=shoes&qid=1587104205&sr=8-4",
              "price_from": 54.95,
              "price_to": null,
              "currency": "USD",
              "data_asin": "B01N02WUM3",
              "rating": {
                "type": "rating_element",
                "position": "left",
                "rating_type": "Max5",
                "value": "4.6",
                "votes_count": 9006,
                "rating_max": "5"
              },
              "is_amazon_choice": false
            }
          ]
        }
      ]
    }
  ]
}

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 Amazon 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 Amazon SERP
contains types of all search results (items) found in the returned SERP
possible item types:
amazon_serp, amazon_paid, editorial_recommendations
            items_count integer the number of results returned in the items array
            items array Amazon product items
            ‘editorial_recommendations’ element
                type string type of element = ‘editorial_recommendations’
                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 Amazon SERP
                xpath string the XPath of the element
                domain string Amazon domain
                title string product title
                url string the URL of the product page
                price_from float the regular price of a product
example:
49.98
                price_to float the upper limit of the product price range
example:
384.99
                currency string currency in the ISO format
example:
USD
                data_asin string unique product identifier on Amazon
note that there is no full list of possible values as the data_asin is a dynamic value assigned by Amazon
example:
B07G82D89J
                rating array product rating info
                    type string type of element = ‘rating_element’
                    position string the alignment of the element in Amazon SERP
possible values:
left, right
                    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 given to a product
                    rating_max string the maximum value for a rating_type
                is_amazon_choice boolean “Amazon’s choice” label
if the value is true, the product is marked with the “Amazon’s choice” label
            ‘amazon_serp’ element
                type string type of element = ‘amazon_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 Amazon SERP
                xpath string the XPath of the element
                domain string Amazon domain
                title string product title
                url string the URL of the product page
                price_from float the regular price of a product
example:
49.98
                price_to float the upper limit of the product price range
example:
384.99
                currency string currency in the ISO format
example:
USD
                data_asin string unique product identifier on Amazon
note that there is no full list of possible values as the data_asin is a dynamic value assigned by Amazon
example:
B07G82D89J
                rating array product rating info
                    type string type of element = ‘rating_element’
                    position string the alignment of the element in Amazon SERP
possible values:
left, right
                    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 given to a product
                    rating_max string the maximum value for a rating_type
                is_amazon_choice boolean “Amazon’s choice” label
if the value is true, the product is marked with the “Amazon’s choice” label
            ‘amazon_paid’ element
                type string type of element = ‘amazon_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 Amazon SERP
                xpath string the XPath of the element
                domain string Amazon domain
                title string product title
                url string the URL of the product page
                price_from float the regular price of a product
example:
49.98
                price_to float the upper limit of the product price range
example:
384.99
                currency string currency in the ISO format
example:
USD
                data_asin string unique product identifier on Amazon
note that there is no full list of possible values as the data_asin is a dynamic value assigned by Amazon
example:
B07G82D89J
                rating array product rating info
                    type string type of element = ‘rating_element’
                    position string the alignment of the element in Amazon SERP
possible values:
left, right
                    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 given to a product
                    rating_max string the maximum value for a rating_type
                is_amazon_choice boolean “Amazon’s choice” label
if the value is true, the product is marked with the “Amazon’s choice” label

‌‌