{"_id":"57b33b018d94953200fd31c4","__v":34,"category":{"_id":"579639964913990e001a5911","version":"568af725176a6c0d00a29ec7","project":"568af724176a6c0d00a29ec4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-25T16:08:54.650Z","from_sync":false,"order":3,"slug":"offers","title":"Products"},"version":{"_id":"568af725176a6c0d00a29ec7","project":"568af724176a6c0d00a29ec4","__v":11,"createdAt":"2016-01-04T22:50:13.289Z","releaseDate":"2016-01-04T22:50:13.289Z","categories":["568af725176a6c0d00a29ec8","56d9d397337fd11300d6a3e3","56d9d4287222d50b0070160b","56f424307ea0091700f63ac5","56f45babcb0dce29005a8e85","5739e5836c5ba134007a197d","57717aee3dd24019004c9122","5771b5d8c755ca0e00617d7d","579639964913990e001a5911","57e57e7df3d7fc0e009c5119","587569b6f4483a0f00d2e6b8"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"project":"568af724176a6c0d00a29ec4","user":"568af6d197d8960d0012ab7d","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-08-16T16:10:41.758Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{\n    queryProfile: {\n        apiKey: \"e3b0bcb2925a1a09503e21df441af8aa\",\n        query: \"nike running shoes\",\n        category: \"Fashion\",\n        country: \"us\",\n        page: 1,\n        itemsPerPage: 3\n    },\n    items: [\n        {\n            name: \"Nike Downshifter Womens Running Shoes\",\n            merchant: \"JCPenney\",\n            brand: \"Nike\",\n            category: \"Fashion\",\n            country: \"US\",\n            upc: null,\n            price: \"39.99\",\n            url: \"http://redirect.viglink.com?key=e3b0bcb2925a1a09503e21df441af8aa&type=FE&u=http%3A%2F%2Fwww.jcpenney.com[...]\",\n            imageUrl: \"https://images.viglink.com/250x250/www.jcpenney.com/[...].jpg\"\n        },\n        {\n            name: \"Nike Tanjun Womens Running Shoes\",\n            merchant: \"JCPenney\",\n            brand: \"Nike\",\n            category: \"Fashion\",\n            country: \"US\",\n            upc: null,\n            price: \"52.50\",\n            url: \"http://redirect.viglink.com?key=e3b0bcb2925a1a09503e21df441af8aa&type=FE&u=http%3A%2F%2Fwww.jcpenney.com[...]\",\n            imageUrl: \"https://images.viglink.com/250x250/www.jcpenney.com/[...].jpg\"\n        },\n        {\n            name: \"Nike Tanjun Womens Running Shoes\",\n            merchant: \"JCPenney\",\n            brand: \"Nike\",\n            category: \"Fashion\",\n            country: \"US\",\n            upc: null,\n            price: \"65.00\",\n            url: \"http://redirect.viglink.com?key=e3b0bcb2925a1a09503e21df441af8aa&type=FE&u=http%3A%2F%2Fwww.jcpenney.com[...]\",\n            imageUrl: \"https://images.viglink.com/250x250/www.jcpenney.com/[...].jpg\"\n        }\n    ],\n    facet: [ ],\n    totalItems: 100,\n    warnings: [ ],\n    hasWarnings: false\n}","name":""},{"name":"","status":400,"language":"json","code":"{\n    error: {\n        errors: {\n            reason: \"invalidParameter\",\n            message: \"Your request must contain a query or a filter\",\n            locationType: \"parameter\",\n            location: \"query\"\n        }\n    },\n    code: 400,\n    message: \"Your request must contain a query or a filter\"\n}"},{"language":"json","status":401,"code":"{\n    error: {\n        errors: [\n            {\n                reason: \"invalidCredentials\",\n                message: \"Authorization secret is missing or invalid. This can be found at https://publishers.viglink.com/account and can be sent as a parameter or Authorization header\",\n                locationType: \"parameter\",\n                location: \"secret\"\n            }\n        ]\n    },\n    code: 401,\n    message: \"Authorization secret is missing or invalid. This can be found at https://publishers.viglink.com/account and can be sent as a parameter or Authorization header\"\n}"},{"status":403,"language":"json","code":"{\n    error: {\n        errors: {\n            reason: \"rateLimitExceeded\",\n            message: \"You need to slow down the rate at which you are sending the requests. You are only allowed 1 query per second for this endpoint\"\n        }\n    },\n    code: 403,\n    message: \"You need to slow down the rate at which you are sending the requests. You are only allowed 1 query per second for this endpoint\"\n}"},{"name":null,"code":"{\n    error: {\n        errors: [\n            {\n                reason: \"internalServerError\",\n                message: \"An unexpected error occurred, but we are looking into it\"\n            }\n        ]\n    },\n    code: 500,\n    message: \"An unexpected error occurred, but we are looking into it\"\n}","language":"json","status":500}]},"settings":"57717d5327a5c20e00030dbd","examples":{"codes":[{"language":"php","code":"<?php\n$ch = curl_init(\"https://rest.viglink.com/api/product/search?apiKey=e3b0bcb2925a1a09503e21df441af8aa&query=nike+running+shoes&country=us&category=Fashion&itemsPerPage=3\");\n\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: secret YOUR SECRET KEY'));\n\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\n$response = curl_exec($ch);\n\ncurl_close($ch);"},{"code":"require 'httparty'\n\nurl = \"https://rest.viglink.com/api/product/search?apiKey=e3b0bcb2925a1a09503e21df441af8aa&query=nike+running+shoes&country=us&category=Fashion&itemsPerPage=3\"\n\nheaders = {Authorization: \"secret {SECRET KEY}\"}\n\nresponse = HTTParty.get(url, headers: headers)","language":"ruby"},{"code":"curl -i -X GET -H \"Authorization: secret {SECRET KEY}\" 'https://rest.viglink.com/api/product/search?apiKey=e3b0bcb2925a1a09503e21df441af8aa&query=nike+running+shoes&country=us&category=Fashion&itemsPerPage=3'","language":"curl"}]},"method":"get","auth":"required","params":[{"_id":"57b33d1f5800cc0e00b3c047","ref":"","in":"query","required":true,"desc":"To track clicks by campaign, use your campaign-specific API Key","default":"","type":"string","name":"apiKey"},{"_id":"57b33de11085171900794f0d","ref":"","in":"query","required":false,"desc":"Search by product title, merchant, brand, category, upc or a combination of these fields","default":"","type":"string","name":"query"},{"_id":"57b351ad6e0cb319005b3aff","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> results to only include offers from a specific country. Please use ISO Alpha-2 country codes like \"us\" for United States or \"ca\" for Canada. <b>By default, products from all countries are returned.</b>","default":"all","type":"array_string","name":"country"},{"_id":"57b349a2c9a4551700b969cc","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> your query by a specific merchant. Currently this filter is <b>case-sensitive</b>. The best way to ensure that it will return accurate results is to filter with a value already discovered.","default":"","type":"array_string","name":"merchant"},{"_id":"57b34215eeec08220094eaa0","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> your query by a specific brand. Currently this filter is <b>case-sensitive</b>. The best way to ensure that it will return accurate results is to filter with a value already discovered.","default":"","type":"array_string","name":"brand"},{"_id":"57b348cf9d021b170063d66a","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> your query by a specific category. See the <a href=\"#section-category-taxonomy\">full category taxonomy below.</a>","default":"","type":"array_string","name":"category"},{"_id":"57b34a831085171900794f76","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> your query by a specific UPC code","default":"","type":"array_string","name":"upc"},{"_id":"58f0f2cc4b233c0f00f573c5","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-filters-work\">Filter</a> your query by a specific ASIN","default":"","type":"array_string","name":"asin"},{"_id":"57b349a2c9a4551700b969cb","ref":"","in":"query","required":false,"desc":"<a href=\"#section-how-the-price-filter-works\">Filter</a> your query by a specific price, or <a href=\"#section-how-the-price-filter-works\">range</a> of prices. Note: Do not use a comma when providing a price above $999.","default":"","type":"float","name":"price"},{"_id":"57b350a41085171900794f7c","ref":"","in":"query","required":false,"desc":"By default, the most relevant results will be returned, but you may sort by price high to low, or low to high. Sorting direction for price defaults to ascending and can be changed to descending by using a minus sign (-) prefix: sortBy=-price","default":"","type":"string","name":"sortBy"},{"_id":"57cec505065d9a0e00d47cac","ref":"","in":"query","required":false,"desc":"To group fields together and return their counts, use a facet like: merchants,category for both merchants and root categories. Learn about how <a href=\"#section-faceting\">facets</a> work below","default":"","type":"string","name":"facet"},{"_id":"57b34df76e0cb319005b3af2","ref":"","in":"query","required":false,"desc":"Page may not be 0 or a negative number, and may not exceed the total number of items available in a response. If not supplied, the starting page is 1","default":"1","type":"int","name":"page"},{"_id":"57b34df76e0cb319005b3af1","ref":"","in":"query","required":false,"desc":"Maximum number of items to include in this response. The default is 100","default":"100","type":"int","name":"itemsPerPage"},{"_id":"57d1d4be5284c90e00cc0689","ref":"","in":"query","required":false,"desc":"Some merchants do not supply an image in their feeds. As such, you have the option here to filter out items that do not have a merchant-supplied image, or correctly structured image URL, by setting filterImages to true","default":"false","type":"boolean","name":"filterImages"},{"_id":"57c0acc6d796900e0024ffff","ref":"","in":"query","required":false,"desc":"Lowercase format of response: json, xml or csv","default":"json","type":"string","name":"format"},{"_id":"57c0acc6d796900e0024fffe","ref":"","in":"query","required":false,"desc":"JSON-P callback method name for JSON format requests","default":"NULL","type":"string","name":"callback"}],"url":"/product/search"},"isReference":false,"order":1,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Authorization Header\",\n  \"body\": \"You must add authorization headers to this request.\\n```Authorization: secret {SECRET KEY}```\\n\\n<b>Replace {SECRET KEY} above with any secret key from any campaign in your account.</b> You can find a secret key in your [VigLink account](https://publishers.viglink.com/account). When logged into your dashboard, go to Manage > Account. Under the My Campaign sub-heading, copy a Secret Key. If you don’t have one, click “Get a Secret Key\\\" on any of your campaigns.\"\n}\n[/block]\n#How Filters Work\n\nYou may enter a query, use a filter, or use both. For example, requesting `query=nike+running+shoes` with the filter `category=Fashion` will return nike running shoes in the Fashion category. You can also pass an array for all parameters designated as an \"array of strings.\" For example, `country[]=US&country[]=CA` for United States and Canada.\n\nAdditionally, if you want to **exclude** terms from your search, you can pass a `!` in front of your value. For example: `query=running+shoes&country=!CA` to exclude products from Canadian merchants in your search.\n\n#How the Price Filter Works\n\nThe price filter allows you to match products at a specific price, above a price, below a price or between two price points. This is achieved by defining the lower and upper limit:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`price=10.00`\",\n    \"0-1\": \"Match products that have a specific price.\",\n    \"0-2\": \"\",\n    \"1-0\": \"`price=10.00,`\",\n    \"1-1\": \"Match products that are equal to $10 or above.\",\n    \"2-0\": \"`price=,10.00`\",\n    \"2-1\": \"Match products that are less than or equal to $10.\",\n    \"3-0\": \"`price=10,25`\",\n    \"3-1\": \"Match products between and equal to $10 and $25. Notice that a decimal format is not required.\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n#Category Taxonomy\n\nCategories go three levels deep from 35 root categories. You may filter your searches with any depth of these categories. While not case-sensitive, filtering by category is character and phrase sensitive. Filtering by `category=Cameras & Photo` will not work, but `category=Cameras and Photo` will.\n\n```\nAdult and Gambling\nAdult and Gambling > Adult\nAdult and Gambling > Gambling\nAdult and Gambling > Other Adult and Gambling\nArt and Entertainment\nArt and Entertainment > DVDs and Videos\nArt and Entertainment > Music\nArt and Entertainment > Art\nArt and Entertainment > Event Tickets\nArt and Entertainment > Other Art and Entertainment\nAutomotive\nAutomotive > Automotive Vehicles\nAutomotive > Auto Electronics\nAutomotive > Auto Parts and Tools\nAutomotive > Other Auto\nCameras and Photo\nCameras and Photo > Camera Hardware and Accessories\nCameras and Photo > Video Hardware and Accessories\nCameras and Photo > Other Camera\nCareer and Employment\nCell Phones and Mobile\nCell Phones and Mobile > Mobile Devices\nCell Phones and Mobile > Mobile Device Accessories\nCell Phones and Mobile > Mobile Device Software\nCell Phones and Mobile > Other Mobile\nCollectibles\nCollectibles > Sports Memorabilia\nCollectibles > Stamps\nCollectibles > Coins and Paper Money\nCollectibles > Other Collectibles\nComputing\nComputing > Computing, Hardware and Accessories\nComputing > Computing Software\nComputing > Other Computing\nConsumer Electronics\nConsumer Electronics > Home Electronics\nConsumer Electronics > Portable Electronics\nConsumer Electronics > Other Electronics\nDating\nEducation\nFamily and Baby\nFamily and Baby > Baby and Maternity Clothing\nFamily and Baby > Baby Other\nFashion\nFashion > Clothing\nFashion > Clothing > Men's Clothing\nFashion > Clothing > Women's Clothing\nFashion > Clothing > Kid's Clothing\nFashion > Clothing > Other Clothing\nFashion > Shoes\nFashion > Shoes > Men's Shoes\nFashion > Shoes > Women's Shoes\nFashion > Shoes > Kid's Shoes\nFashion > Shoes > Other Shoes\nFashion > Luggage and Bags\nFashion > Luggage and Bags > Women's Luggage and Bags\nFashion > Luggage and Bags > Other Luggage\nFashion > Fashion Accessories\nFashion > Fashion Accessories > Men's Fashion Accessories\nFashion > Fashion Accessories > Women's Fashion Accessories\nFashion > Fashion Accessories > Kid's Fashion Accessories\nFashion > Fashion Accessories > Other Fashion Accessories\nFashion > Other Fashion\nFinancial Services\nFirearms and Hunting\nFirearms and Hunting > Firearms\nFirearms and Hunting > Knives\nFirearms and Hunting > Fishing\nFirearms and Hunting > Bow Hunting\nFirearms and Hunting > Survival Gear\nFirearms and Hunting > Other Hunting\nFood and Drink\nFood and Drink > Standard Food\nFood and Drink > Gourmet Food\nFood and Drink > Other Food and Drink\nHealth and Beauty\nHealth and Beauty > Health\nHealth and Beauty > Beauty\nHealth and Beauty > Other Health and Beauty\nHome and Garden\nHome and Garden > Home Decor\nHome and Garden > Appliances\nHome and Garden > Home Improvement\nHome and Garden > Kitchen, Dining and Bar\nHome and Garden > Gardening\nHome and Garden > Gift\nHome and Garden > Flowers\nHome and Garden > Cleaning Supplies\nHome and Garden > Other Home and Garden\nIndustrial and Supply\nIndustrial and Supply > Office Supplies\nIndustrial and Supply > Office Electronics\nIndustrial and Supply > Industrial\nIndustrial and Supply > Other Industrial and Supply\nJewelry and Watches\nJewelry and Watches > Jewelry\nJewelry and Watches > Watches\nJewelry and Watches > Other Jewelry\nLifestyle\nMotorcycles and Powersports\nMotorcycles and Powersports > Motorcycling\nMotorcycles and Powersports > ATVs\nMotorcycles and Powersports > Boating\nMotorcycles and Powersports > Other Motorcycles and Powersports\nMusic and Musicians\nMusic and Musicians > Musical Instruments\nMusic and Musicians > Musical Accessories\nMusic and Musicians > Other Musical\nNews, Books and Magazines\nNews, Books and Magazines > Books and eBooks \nNews, Books and Magazines > Magazines and Newspaper\nNews, Books and Magazines > Other Books\nOnline Services\nOther\nPets\nPets > Dogs\nPets > Fish\nPets > Cat\nPets > Birds\nPets > Other Pets\nReal Estate\nReligious and Ceremonial\nSelf-Help\nShopping and Coupons\nSports and Fitness\nSports and Fitness > Bicycling\nSports and Fitness > Water Sports\nSports and Fitness > Golfing\nSports and Fitness > Winter Sports\nSports and Fitness > Outdoor Apparel\nSports and Fitness > Camping\nSports and Fitness > Other Sports and Fitness\nToys and Hobbies\nToys and Hobbies > Toys\nToys and Hobbies > Games\nToys and Hobbies > Crafts\nToys and Hobbies > Hobbies\nToys and Hobbies > Costumes\nToys and Hobbies > Other Toys and Hobbies\nTravel\nTravel > Other Travel\nVideo Gaming\nVideo Gaming > Video Games\nVideo Gaming > Gaming Hardware\nVideo Gaming > Other Gaming\n```\n\n#Faceting\n\nFaceting is often used to create a navigation menu for product results. You can facet on merchant, brand, category1, category2, and category3. You may also nest your facets: If you want the full nested heirarchy of categories for a query, simply request `facet=category1>category2>category3` separating each nested level with a `>`.\n\nA common request for facets includes merchants, brands and the full depth of categories. This can be achieved in the same request by separating each facet with a `,`. For example: `facet=merchant,brand,category1>category2>category3`.\n\nNow the facet index response will include \"merchant\", \"brand\" and \"category1>category2>category3\":\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\\"facet\\\":{\\n    \\\"merchant\\\":{\\n        \\\"branch\\\":\\\"merchant\\\",\\n        \\\"buckets\\\":{\\n            \\\"Amazon\\\":{\\n                \\\"count\\\":2008877\\n            },\\n            \\\"Walmart.com\\\":{\\n                \\\"count\\\":439688\\n            },\\n            [...]\\n        }\\n    },\\n    \\\"brand\\\":{\\n        \\\"branch\\\":\\\"brand\\\",\\n        \\\"buckets\\\":{\\n            \\\"HP\\\":{\\n                \\\"count\\\":98931\\n            },\\n            \\\"Ford\\\":{\\n                \\\"count\\\":42523\\n            },\\n            [...]\\n        }\\n    },\\n    \\\"category1>category2>category3\\\":{\\n        \\\"branch\\\":\\\"category1\\\",\\n        \\\"buckets\\\":{\\n            \\\"Automotive\\\":{\\n                \\\"count\\\":2278172,\\n                \\\"category1>category2>category3\\\":{\\n                    \\\"branch\\\":\\\"category2\\\",\\n                    \\\"buckets\\\":{\\n                        \\\"Automotive > Auto Parts and Tools\\\":{\\n                            \\\"count\\\":1435385\\n                        },\\n                        \\\"Automotive > Auto Electronics\\\":{\\n                            \\\"count\\\":2061\\n                        },\\n                        \\\"Automotive > Other Auto\\\":{\\n                            \\\"count\\\":243\\n                        }\\n                    }\\n                }\\n            },\\n            \\\"Fashion\\\":{\\n                \\\"count\\\":468039,\\n                \\\"category1>category2>category3\\\":{\\n                    \\\"branch\\\":\\\"category2\\\",\\n                    \\\"buckets\\\":{\\n                        \\\"Fashion > Clothing\\\":{\\n                            \\\"count\\\":5372,\\n                            \\\"category1>category2>category3\\\":{\\n                                \\\"branch\\\":\\\"category3\\\",\\n                                \\\"buckets\\\":{\\n                                    \\\"Fashion > Clothing > Men's Clothing\\\":{\\n                                        \\\"count\\\":3142\\n                                    },\\n                                    \\\"Fashion > Clothing > Women's Clothing\\\":{\\n                                        \\\"count\\\":67\\n                                    }\\n                                }\\n                            }\\n                        },\\n                        \\\"Fashion > Shoes\\\":{\\n                            \\\"count\\\":543,\\n                            \\\"category1>category2>category3\\\":{\\n                                \\\"branch\\\":\\\"category3\\\",\\n                                \\\"buckets\\\":{\\n                                    \\\"Fashion > Shoes > Women's Shoes\\\":{\\n                                        \\\"count\\\":409\\n                                    },\\n                                    \\\"Fashion > Shoes > Men's Shoes\\\":{\\n                                        \\\"count\\\":132\\n                                    }\\n                                }\\n                            }\\n                        },\\n                        \\\"Fashion > Fashion Accessories\\\":{\\n                            \\\"count\\\":316,\\n                            \\\"category1>category2>category3\\\":{\\n                                \\\"branch\\\":\\\"category3\\\",\\n                                \\\"buckets\\\":{\\n                                    \\\"Fashion > Fashion Accessories > Men's Fashion Accessories\\\":{\\n                                        \\\"count\\\":291\\n                                    },\\n                                    \\\"Fashion > Fashion Accessories > Women's Fashion Accessories\\\":{\\n                                        \\\"count\\\":25\\n                                    }\\n                                }\\n                            }\\n                        },\\n                        \\\"Fashion > Luggage and Bags\\\":{\\n                            \\\"count\\\":20\\n                        },\\n                        \\\"Fashion > Other Fashion\\\":{\\n                            \\\"count\\\":9\\n                        }\\n                    }\\n                }\\n            },\\n            [...]\\n        }\\n    }\\n}\\n\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n## How can I create a navigation menu from this?\n\nGlad you asked! Try using this recursive function in PHP to iterate through the facets to make a nested HTML list:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\nfunction buildFacetNavigation($branch, $baseUri = '/', $level = 0, $facet = null)\\n{\\n    if ($level > 0)\\n    {\\n        $return = null;\\n        foreach ($branch as $label => $row)\\n        {\\n            $l = $label;\\n            if (strstr($label, '>'))\\n            {\\n                $label = explode('>', $label);\\n\\n                for ($i=1;$i<=3;$i++)\\n                {\\n                    if (key_exists($level-$i, $label))\\n                    {\\n                        $ll = $label[$level-$i];\\n                        break;\\n                    }\\n                }\\n\\n                $label = trim($ll);\\n            }\\n\\n            $f = explode('>', $facet);\\n            $urlFacet = $f[$level-1];\\n            $urlFacet = stristr($urlFacet, 'category') ? 'category' : $urlFacet;\\n\\n            $return .= '<li>';\\n            $slug = ($urlFacet . '=' . urlencode($l));\\n            $return .= '<a href=\\\"' . $baseUri . (strstr($baseUri, '?') ? '&' : '?') . $slug . '\\\">';\\n            $return .= $label . ' (' . number_format($row['count']) . ')';\\n            $return .= '</a>';\\n\\n            if (!stristr($f[0], 'category'))\\n            {\\n                $appendBaseUri = '&' . $slug;\\n            }\\n\\n            if (key_exists($facet, $row) && key_exists('buckets', $row[$facet]))\\n            {\\n                $return .= '<ul class=\\\"navigation level' . ($level + 1) . '\\\">';\\n                $return .= buildFacetNavigation($row[$facet]['buckets'], $baseUri . $appendBaseUri, $level + 1, $facet);\\n                $return .= '</ul>';\\n            }\\n\\n            $return .= '</li>';\\n        }\\n        return $return;\\n    }\\n\\n    $navigation = null;\\n    foreach ($branch as $facetName => $row)\\n    {\\n        $facetLabel = ucfirst(preg_replace('/[0-9]/', '', $row['branch']));\\n        $navigation .= '<h4>' . $facetLabel . '</h4>';\\n\\n        if (key_exists('buckets', $row))\\n        {\\n            $navigation .= '<ul class=\\\"navigation level' . ($level + 1) . '\\\">';\\n            $navigation .= buildFacetNavigation($row['buckets'], $baseUri, $level + 1, $facetName);\\n            $navigation .= '</ul>';\\n        }\\n    }\\n\\n    return $navigation;\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nWe can now pass the `facet` index from the API response to the function `buildFacetNavigation` to get back HTML.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$ch = curl_init(\\\"https://rest.viglink.com/api/product/search?apiKey=e3b0bcb2925a1a09503e21df441af8aa&query=nike+running+shoes&country=us&facet=merchant,brand,category1>category2>category3\\\");\\ncurl_setopt($ch, CURLOPT_HTTPHEADER, 'Authorization: secret {SECRET KEY}');\\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\\n$response = curl_exec($ch);\\ncurl_close($ch);\\n$json = json_decode($response, true);\\n$navigation = buildFacetNavigation($response['facet'], '/index?query=' . $_GET['query']);\\necho $navigation;\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n`$navigation` would now contain the HTML for a navigable menu:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<h4>Merchant</h4>\\n<ul class=\\\"navigation level1\\\">\\n    <li><a href=\\\"/index?query=nike+running+shoes&merchant=Amazon\\\">Amazon (2,008,877)</a></li>\\n    <li><a href=\\\"/index?query=nike+running+shoes&merchant=Walmart.com\\\">Walmart.com (439,688)</a></li>\\n    [...]\\n</ul>\\n\\n<h4>Brand</h4>\\n<ul class=\\\"navigation level1\\\">\\n    <li><a href=\\\"/index?query=nike+running+shoes&brand=HP\\\">HP (98,931)</a></li>\\n    <li><a href=\\\"/index?query=nike+running+shoes&brand=Ford\\\">Ford (42,523)</a></li>\\n    [...]\\n</ul>\\n\\n<h4>Category</h4>\\n<ul class=\\\"navigation level1\\\">\\n    <li><a href=\\\"/index?query=nike+running+shoes&category=Automotive\\\">Automotive (2,278,172)</a>\\n    <ul class=\\\"navigation level2\\\">\\n        <li><a href=\\\"/index?query=nike+running+shoes&category=Automotive+%3E+Auto+Parts+and+Tools\\\">Automotive > Auto Parts and Tools (1,435,385)</a></li>\\n        <li><a href=\\\"/index?query=nike+running+shoes&category=Automotive+%3E+Auto+Electronics\\\">Automotive > Auto Electronics (2,061)</a></li>\\n        <li><a href=\\\"/index?query=nike+running+shoes&category=Automotive+%3E+Other+Auto\\\">Automotive > Other Auto (243)</a></li>\\n    </ul>\\n    </li>\\n    <li><a href=\\\"/index?query=nike+running+shoes&category=Fashion\\\">Fashion (468,039)</a></li>\\n    [...]\\n</ul>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]","excerpt":"Search for specific products from a vast catalog of over 350 million products, and get back the product price, brand, merchant, category price, an image URL and an affiliate URL.","slug":"product-search","type":"endpoint","title":"Product Search"}

getProduct Search

Search for specific products from a vast catalog of over 350 million products, and get back the product price, brand, merchant, category price, an image URL and an affiliate URL.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Query Params

apiKey:
required
string
To track clicks by campaign, use your campaign-specific API Key
query:
string
Search by product title, merchant, brand, category, upc or a combination of these fields
country:
array of stringsall
<a href="#section-how-filters-work">Filter</a> results to only include offers from a specific country. Please use ISO Alpha-2 country codes like "us" for United States or "ca" for Canada. <b>By default, products from all countries are returned.</b>
merchant:
array of strings
<a href="#section-how-filters-work">Filter</a> your query by a specific merchant. Currently this filter is <b>case-sensitive</b>. The best way to ensure that it will return accurate results is to filter with a value already discovered.
brand:
array of strings
<a href="#section-how-filters-work">Filter</a> your query by a specific brand. Currently this filter is <b>case-sensitive</b>. The best way to ensure that it will return accurate results is to filter with a value already discovered.
category:
array of strings
<a href="#section-how-filters-work">Filter</a> your query by a specific category. See the <a href="#section-category-taxonomy">full category taxonomy below.</a>
upc:
array of strings
<a href="#section-how-filters-work">Filter</a> your query by a specific UPC code
asin:
array of strings
<a href="#section-how-filters-work">Filter</a> your query by a specific ASIN
price:
float
<a href="#section-how-the-price-filter-works">Filter</a> your query by a specific price, or <a href="#section-how-the-price-filter-works">range</a> of prices. Note: Do not use a comma when providing a price above $999.
sortBy:
string
By default, the most relevant results will be returned, but you may sort by price high to low, or low to high. Sorting direction for price defaults to ascending and can be changed to descending by using a minus sign (-) prefix: sortBy=-price
facet:
string
To group fields together and return their counts, use a facet like: merchants,category for both merchants and root categories. Learn about how <a href="#section-faceting">facets</a> work below
page:
integer1
Page may not be 0 or a negative number, and may not exceed the total number of items available in a response. If not supplied, the starting page is 1
itemsPerPage:
integer100
Maximum number of items to include in this response. The default is 100
filterImages:
booleanfalse
Some merchants do not supply an image in their feeds. As such, you have the option here to filter out items that do not have a merchant-supplied image, or correctly structured image URL, by setting filterImages to true
format:
stringjson
Lowercase format of response: json, xml or csv
callback:
stringNULL
JSON-P callback method name for JSON format requests

Examples


Result Format


Documentation

[block:callout] { "type": "warning", "title": "Authorization Header", "body": "You must add authorization headers to this request.\n```Authorization: secret {SECRET KEY}```\n\n<b>Replace {SECRET KEY} above with any secret key from any campaign in your account.</b> You can find a secret key in your [VigLink account](https://publishers.viglink.com/account). When logged into your dashboard, go to Manage > Account. Under the My Campaign sub-heading, copy a Secret Key. If you don’t have one, click “Get a Secret Key\" on any of your campaigns." } [/block] #How Filters Work You may enter a query, use a filter, or use both. For example, requesting `query=nike+running+shoes` with the filter `category=Fashion` will return nike running shoes in the Fashion category. You can also pass an array for all parameters designated as an "array of strings." For example, `country[]=US&country[]=CA` for United States and Canada. Additionally, if you want to **exclude** terms from your search, you can pass a `!` in front of your value. For example: `query=running+shoes&country=!CA` to exclude products from Canadian merchants in your search. #How the Price Filter Works The price filter allows you to match products at a specific price, above a price, below a price or between two price points. This is achieved by defining the lower and upper limit: [block:parameters] { "data": { "0-0": "`price=10.00`", "0-1": "Match products that have a specific price.", "0-2": "", "1-0": "`price=10.00,`", "1-1": "Match products that are equal to $10 or above.", "2-0": "`price=,10.00`", "2-1": "Match products that are less than or equal to $10.", "3-0": "`price=10,25`", "3-1": "Match products between and equal to $10 and $25. Notice that a decimal format is not required." }, "cols": 2, "rows": 4 } [/block] #Category Taxonomy Categories go three levels deep from 35 root categories. You may filter your searches with any depth of these categories. While not case-sensitive, filtering by category is character and phrase sensitive. Filtering by `category=Cameras & Photo` will not work, but `category=Cameras and Photo` will. ``` Adult and Gambling Adult and Gambling > Adult Adult and Gambling > Gambling Adult and Gambling > Other Adult and Gambling Art and Entertainment Art and Entertainment > DVDs and Videos Art and Entertainment > Music Art and Entertainment > Art Art and Entertainment > Event Tickets Art and Entertainment > Other Art and Entertainment Automotive Automotive > Automotive Vehicles Automotive > Auto Electronics Automotive > Auto Parts and Tools Automotive > Other Auto Cameras and Photo Cameras and Photo > Camera Hardware and Accessories Cameras and Photo > Video Hardware and Accessories Cameras and Photo > Other Camera Career and Employment Cell Phones and Mobile Cell Phones and Mobile > Mobile Devices Cell Phones and Mobile > Mobile Device Accessories Cell Phones and Mobile > Mobile Device Software Cell Phones and Mobile > Other Mobile Collectibles Collectibles > Sports Memorabilia Collectibles > Stamps Collectibles > Coins and Paper Money Collectibles > Other Collectibles Computing Computing > Computing, Hardware and Accessories Computing > Computing Software Computing > Other Computing Consumer Electronics Consumer Electronics > Home Electronics Consumer Electronics > Portable Electronics Consumer Electronics > Other Electronics Dating Education Family and Baby Family and Baby > Baby and Maternity Clothing Family and Baby > Baby Other Fashion Fashion > Clothing Fashion > Clothing > Men's Clothing Fashion > Clothing > Women's Clothing Fashion > Clothing > Kid's Clothing Fashion > Clothing > Other Clothing Fashion > Shoes Fashion > Shoes > Men's Shoes Fashion > Shoes > Women's Shoes Fashion > Shoes > Kid's Shoes Fashion > Shoes > Other Shoes Fashion > Luggage and Bags Fashion > Luggage and Bags > Women's Luggage and Bags Fashion > Luggage and Bags > Other Luggage Fashion > Fashion Accessories Fashion > Fashion Accessories > Men's Fashion Accessories Fashion > Fashion Accessories > Women's Fashion Accessories Fashion > Fashion Accessories > Kid's Fashion Accessories Fashion > Fashion Accessories > Other Fashion Accessories Fashion > Other Fashion Financial Services Firearms and Hunting Firearms and Hunting > Firearms Firearms and Hunting > Knives Firearms and Hunting > Fishing Firearms and Hunting > Bow Hunting Firearms and Hunting > Survival Gear Firearms and Hunting > Other Hunting Food and Drink Food and Drink > Standard Food Food and Drink > Gourmet Food Food and Drink > Other Food and Drink Health and Beauty Health and Beauty > Health Health and Beauty > Beauty Health and Beauty > Other Health and Beauty Home and Garden Home and Garden > Home Decor Home and Garden > Appliances Home and Garden > Home Improvement Home and Garden > Kitchen, Dining and Bar Home and Garden > Gardening Home and Garden > Gift Home and Garden > Flowers Home and Garden > Cleaning Supplies Home and Garden > Other Home and Garden Industrial and Supply Industrial and Supply > Office Supplies Industrial and Supply > Office Electronics Industrial and Supply > Industrial Industrial and Supply > Other Industrial and Supply Jewelry and Watches Jewelry and Watches > Jewelry Jewelry and Watches > Watches Jewelry and Watches > Other Jewelry Lifestyle Motorcycles and Powersports Motorcycles and Powersports > Motorcycling Motorcycles and Powersports > ATVs Motorcycles and Powersports > Boating Motorcycles and Powersports > Other Motorcycles and Powersports Music and Musicians Music and Musicians > Musical Instruments Music and Musicians > Musical Accessories Music and Musicians > Other Musical News, Books and Magazines News, Books and Magazines > Books and eBooks News, Books and Magazines > Magazines and Newspaper News, Books and Magazines > Other Books Online Services Other Pets Pets > Dogs Pets > Fish Pets > Cat Pets > Birds Pets > Other Pets Real Estate Religious and Ceremonial Self-Help Shopping and Coupons Sports and Fitness Sports and Fitness > Bicycling Sports and Fitness > Water Sports Sports and Fitness > Golfing Sports and Fitness > Winter Sports Sports and Fitness > Outdoor Apparel Sports and Fitness > Camping Sports and Fitness > Other Sports and Fitness Toys and Hobbies Toys and Hobbies > Toys Toys and Hobbies > Games Toys and Hobbies > Crafts Toys and Hobbies > Hobbies Toys and Hobbies > Costumes Toys and Hobbies > Other Toys and Hobbies Travel Travel > Other Travel Video Gaming Video Gaming > Video Games Video Gaming > Gaming Hardware Video Gaming > Other Gaming ``` #Faceting Faceting is often used to create a navigation menu for product results. You can facet on merchant, brand, category1, category2, and category3. You may also nest your facets: If you want the full nested heirarchy of categories for a query, simply request `facet=category1>category2>category3` separating each nested level with a `>`. A common request for facets includes merchants, brands and the full depth of categories. This can be achieved in the same request by separating each facet with a `,`. For example: `facet=merchant,brand,category1>category2>category3`. Now the facet index response will include "merchant", "brand" and "category1>category2>category3": [block:code] { "codes": [ { "code": "\"facet\":{\n \"merchant\":{\n \"branch\":\"merchant\",\n \"buckets\":{\n \"Amazon\":{\n \"count\":2008877\n },\n \"Walmart.com\":{\n \"count\":439688\n },\n [...]\n }\n },\n \"brand\":{\n \"branch\":\"brand\",\n \"buckets\":{\n \"HP\":{\n \"count\":98931\n },\n \"Ford\":{\n \"count\":42523\n },\n [...]\n }\n },\n \"category1>category2>category3\":{\n \"branch\":\"category1\",\n \"buckets\":{\n \"Automotive\":{\n \"count\":2278172,\n \"category1>category2>category3\":{\n \"branch\":\"category2\",\n \"buckets\":{\n \"Automotive > Auto Parts and Tools\":{\n \"count\":1435385\n },\n \"Automotive > Auto Electronics\":{\n \"count\":2061\n },\n \"Automotive > Other Auto\":{\n \"count\":243\n }\n }\n }\n },\n \"Fashion\":{\n \"count\":468039,\n \"category1>category2>category3\":{\n \"branch\":\"category2\",\n \"buckets\":{\n \"Fashion > Clothing\":{\n \"count\":5372,\n \"category1>category2>category3\":{\n \"branch\":\"category3\",\n \"buckets\":{\n \"Fashion > Clothing > Men's Clothing\":{\n \"count\":3142\n },\n \"Fashion > Clothing > Women's Clothing\":{\n \"count\":67\n }\n }\n }\n },\n \"Fashion > Shoes\":{\n \"count\":543,\n \"category1>category2>category3\":{\n \"branch\":\"category3\",\n \"buckets\":{\n \"Fashion > Shoes > Women's Shoes\":{\n \"count\":409\n },\n \"Fashion > Shoes > Men's Shoes\":{\n \"count\":132\n }\n }\n }\n },\n \"Fashion > Fashion Accessories\":{\n \"count\":316,\n \"category1>category2>category3\":{\n \"branch\":\"category3\",\n \"buckets\":{\n \"Fashion > Fashion Accessories > Men's Fashion Accessories\":{\n \"count\":291\n },\n \"Fashion > Fashion Accessories > Women's Fashion Accessories\":{\n \"count\":25\n }\n }\n }\n },\n \"Fashion > Luggage and Bags\":{\n \"count\":20\n },\n \"Fashion > Other Fashion\":{\n \"count\":9\n }\n }\n }\n },\n [...]\n }\n }\n}\n", "language": "json" } ] } [/block] ## How can I create a navigation menu from this? Glad you asked! Try using this recursive function in PHP to iterate through the facets to make a nested HTML list: [block:code] { "codes": [ { "code": "<?php\nfunction buildFacetNavigation($branch, $baseUri = '/', $level = 0, $facet = null)\n{\n if ($level > 0)\n {\n $return = null;\n foreach ($branch as $label => $row)\n {\n $l = $label;\n if (strstr($label, '>'))\n {\n $label = explode('>', $label);\n\n for ($i=1;$i<=3;$i++)\n {\n if (key_exists($level-$i, $label))\n {\n $ll = $label[$level-$i];\n break;\n }\n }\n\n $label = trim($ll);\n }\n\n $f = explode('>', $facet);\n $urlFacet = $f[$level-1];\n $urlFacet = stristr($urlFacet, 'category') ? 'category' : $urlFacet;\n\n $return .= '<li>';\n $slug = ($urlFacet . '=' . urlencode($l));\n $return .= '<a href=\"' . $baseUri . (strstr($baseUri, '?') ? '&' : '?') . $slug . '\">';\n $return .= $label . ' (' . number_format($row['count']) . ')';\n $return .= '</a>';\n\n if (!stristr($f[0], 'category'))\n {\n $appendBaseUri = '&' . $slug;\n }\n\n if (key_exists($facet, $row) && key_exists('buckets', $row[$facet]))\n {\n $return .= '<ul class=\"navigation level' . ($level + 1) . '\">';\n $return .= buildFacetNavigation($row[$facet]['buckets'], $baseUri . $appendBaseUri, $level + 1, $facet);\n $return .= '</ul>';\n }\n\n $return .= '</li>';\n }\n return $return;\n }\n\n $navigation = null;\n foreach ($branch as $facetName => $row)\n {\n $facetLabel = ucfirst(preg_replace('/[0-9]/', '', $row['branch']));\n $navigation .= '<h4>' . $facetLabel . '</h4>';\n\n if (key_exists('buckets', $row))\n {\n $navigation .= '<ul class=\"navigation level' . ($level + 1) . '\">';\n $navigation .= buildFacetNavigation($row['buckets'], $baseUri, $level + 1, $facetName);\n $navigation .= '</ul>';\n }\n }\n\n return $navigation;\n}", "language": "php" } ] } [/block] We can now pass the `facet` index from the API response to the function `buildFacetNavigation` to get back HTML. [block:code] { "codes": [ { "code": "<?php\n$ch = curl_init(\"https://rest.viglink.com/api/product/search?apiKey=e3b0bcb2925a1a09503e21df441af8aa&query=nike+running+shoes&country=us&facet=merchant,brand,category1>category2>category3\");\ncurl_setopt($ch, CURLOPT_HTTPHEADER, 'Authorization: secret {SECRET KEY}');\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n$response = curl_exec($ch);\ncurl_close($ch);\n$json = json_decode($response, true);\n$navigation = buildFacetNavigation($response['facet'], '/index?query=' . $_GET['query']);\necho $navigation;", "language": "php" } ] } [/block] `$navigation` would now contain the HTML for a navigable menu: [block:code] { "codes": [ { "code": "<h4>Merchant</h4>\n<ul class=\"navigation level1\">\n <li><a href=\"/index?query=nike+running+shoes&merchant=Amazon\">Amazon (2,008,877)</a></li>\n <li><a href=\"/index?query=nike+running+shoes&merchant=Walmart.com\">Walmart.com (439,688)</a></li>\n [...]\n</ul>\n\n<h4>Brand</h4>\n<ul class=\"navigation level1\">\n <li><a href=\"/index?query=nike+running+shoes&brand=HP\">HP (98,931)</a></li>\n <li><a href=\"/index?query=nike+running+shoes&brand=Ford\">Ford (42,523)</a></li>\n [...]\n</ul>\n\n<h4>Category</h4>\n<ul class=\"navigation level1\">\n <li><a href=\"/index?query=nike+running+shoes&category=Automotive\">Automotive (2,278,172)</a>\n <ul class=\"navigation level2\">\n <li><a href=\"/index?query=nike+running+shoes&category=Automotive+%3E+Auto+Parts+and+Tools\">Automotive > Auto Parts and Tools (1,435,385)</a></li>\n <li><a href=\"/index?query=nike+running+shoes&category=Automotive+%3E+Auto+Electronics\">Automotive > Auto Electronics (2,061)</a></li>\n <li><a href=\"/index?query=nike+running+shoes&category=Automotive+%3E+Other+Auto\">Automotive > Other Auto (243)</a></li>\n </ul>\n </li>\n <li><a href=\"/index?query=nike+running+shoes&category=Fashion\">Fashion (468,039)</a></li>\n [...]\n</ul>", "language": "html" } ] } [/block]

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}