### Start Collection via HTTP GET Source: https://docs.trajectdata.com/backyardapi/collections-api/collections/start Initiate a collection by making an HTTP GET request to the /collections/COLLECTION_ID/start endpoint. Requires sufficient request credits. Use for manual schedule types or any collection not currently running. ```HTTP https://api.backyardapi.com/collections/123456/start?api_key=demo ``` ```curl $ curl "https://api.backyardapi.com/collections/123456/start?api_key=demo" ``` ```nodejs const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/start', { params }) .then(response => { const apiResponse = response.data; console.log('Collection started.'); }).catch(error => { console.log(error); }); ``` ```python import requests params = { 'api_key': 'demo' } api_result = requests.get('https://api.backyardapi.com/collections/123456/start', params) api_response = api_result.json() print "Collection started." ``` ```php 'demo', ]); $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/collections/123456/start', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $json = curl_exec($ch); curl_close($ch); $api_result = json_decode($json, true); print_r($api_result); echo "Collection started.", PHP_EOL; ?> ``` -------------------------------- ### Request Product Reviews via HTTP Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/reviews Example of a direct HTTP GET request to retrieve reviews for a specific product. ```HTTP https://api.backyardapi.com/request?api_key=demo&engine=homedepot&type=reviews&item_id=317061059&sort_by=most_helpful ``` -------------------------------- ### Search Request Examples Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/search Examples of how to perform a search request for 'lawn mower' sorted by 'best_seller' using various programming languages and tools. ```HTTP https://api.backyardapi.com/request?api_key=demo&engine=homedepot&type=search&search_term=lawn+mower&sort_by=best_seller ``` ```curl curl -L --get https://api.backyardapi.com/request -d api_key="demo" -d engine="homedepot" -d type="search" -d search_term="lawn mower" -d sort_by="best_seller" ``` ```nodejs const axios = require('axios'); // set up the request parameters const params = { api_key: "demo", engine: "homedepot", type: "search", search_term: "lawn mower", sort_by: "best_seller" } // make the http GET request to Backyard API axios.get('https://api.backyardapi.com/request', { params }) .then(response => { // print the JSON response from Backyard API console.log(JSON.stringify(response.data, 0, 2)); }).catch(error => { // catch and print the error console.log(error); }) ``` ```python import requests import json # set up the request parameters params = { 'api_key': 'demo', 'engine': 'homedepot', 'type': 'search', 'search_term': 'lawn mower', 'sort_by': 'best_seller' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/request', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ``` ```php 'demo', 'engine': 'homedepot', 'type': 'search', 'search_term': 'lawn mower', 'sort_by': 'best_seller' ]); # make the http GET request to Backyard API $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/request', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $api_result = curl_exec($ch); curl_close($ch); # print the JSON response from Backyard API echo $api_result; ?> ``` -------------------------------- ### List Result Sets for a Collection (PHP) Source: https://docs.trajectdata.com/backyardapi/collections-api/results/list This PHP example uses cURL to make a GET request to the Backyard API to list Result Sets for a collection. It handles SSL verification options and decodes the JSON response. ```php 'demo', ]); $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/collections/123456/results', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $json = curl_exec($ch); curl_close($ch); $api_result = json_decode($json, true); print_r($api_result); ?> ``` -------------------------------- ### List Result Sets for a Collection (Node.js) Source: https://docs.trajectdata.com/backyardapi/collections-api/results/list This Node.js example uses the axios library to make a GET request to list Result Sets for a collection. It includes basic error handling. ```javascript const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/results', { params }) .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` -------------------------------- ### List Root Categories using Node.js Source: https://docs.trajectdata.com/backyardapi/categories-api/list-and-search This Node.js script fetches and logs all top-level categories. It uses the 'axios' library for making HTTP requests. Make sure to install axios: npm install axios. ```javascript const axios = require('axios'); axios.get('https://api.backyardapi.com/categories?api_key=demo') .then(response => { const apiResponse = response.data; console.log("Categories: ", JSON.stringify(apiResponse, 0, 2); }).catch(error => { console.error(error); }); ``` -------------------------------- ### GET /websites/trajectdata_backyardapi?type=reviews Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/reviews Retrieve reviews for a specific Home Improvement item. ```APIDOC ## GET /websites/trajectdata_backyardapi?type=reviews ### Description Retrieves reviews for Home Improvement items. You can specify the item using `item_id`, `gtin`, or a `url`. ### Method GET ### Endpoint /websites/trajectdata_backyardapi ### Query Parameters - **type** (string) - Required - Must be set to `reviews`. - **item_id** (string) - Required - The Home Improvement Item ID to retrieve Reviews for. If supplied, the `url` parameter is ignored. - **gtin** (string) - Optional - The GTIN/ISBN/UPC code to look up a matching product on Home Improvement for to retrieve reviews for. If supplied, the `item_id` parameter is ignored. - **url** (string) - Optional - The Home Improvement reviews-page URL to retrieve Reviews from. - **sort_by** (string) - Optional - Determines the sort order of reviews. Valid values include `photo_reviews`, `most_helpful`, `newest_to_oldest`, `oldest_to_newest`, `high_to_low_rating`, `low_to_high_rating`. - **search_term** (string) - Optional - A search term to use to search reviews. ### Response #### Success Response (200) - **reviews** (array) - A list of review objects. - **rating** (number) - The rating given by the reviewer. - **title** (string) - The title of the review. - **text** (string) - The content of the review. - **author** (string) - The name of the reviewer. - **date** (string) - The date the review was posted. - **images** (array) - A list of image URLs associated with the review. #### Error Response (400) - **error** (string) - A message describing the error. ### Request Example ``` GET /websites/trajectdata_backyardapi?type=reviews&item_id=12345&sort_by=most_helpful ``` ### Response Example (Success) ```json { "reviews": [ { "rating": 5, "title": "Great product!", "text": "I love this item, it works perfectly.", "author": "John Doe", "date": "2023-10-27", "images": ["http://example.com/image1.jpg"] } ] } ``` ### Response Example (Error) ```json { "error": "Invalid item_id provided." } ``` ``` -------------------------------- ### Example JSON Response for Root Categories Source: https://docs.trajectdata.com/backyardapi/categories-api/list-and-search This is an example of the JSON structure returned when requesting root categories. It includes a 'request_info' object and a 'categories' array containing category details. ```json { "request_info": { "success": true }, "categories": [ { "id": "N-5yc1vZbv1w", "name": "Appliances", "has_children": true, "is_root": true, "path": "Appliances", "link": "https://www.homedepot.com/b/Appliances/N-5yc1vZbv1w", "type": "standard", "domain": "homedepot.com" }, { "id": "N-5yc1vZbqsi", "name": "Cleaning", "has_children": true, "is_root": true, "path": "Cleaning", "link": "https://www.homedepot.com/b/Cleaning/N-5yc1vZbqsi", "type": "standard", "domain": "homedepot.com" }, { "id": "N-5yc1vZc1jw", "name": "Smart Home", "has_children": true, "is_root": true, "path": "Smart Home", "link": "https://www.homedepot.com/b/Smart-Home/N-5yc1vZc1jw", "type": "standard", "domain": "homedepot.com" } ] } ``` -------------------------------- ### GET /reviews Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/common Request customer reviews for a specific item_id or product URL. ```APIDOC ## GET /reviews ### Description Request customer reviews for an item_id or Home Improvement product page url. ### Method GET ### Parameters #### Query Parameters - **customer_zipcode** (string) - Optional - Determines the specific customer zipcode location of the request. Requires setup in the Dashboard. - **output** (string) - Optional - Determines the format in which results are returned (json, html, or csv). ``` -------------------------------- ### GET /questions Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/common Request customer questions and answers for a specific item_id or product URL. ```APIDOC ## GET /questions ### Description Request customer questions & answers for an item_id or Home Improvement product page url. ### Method GET ### Parameters #### Query Parameters - **customer_zipcode** (string) - Optional - Determines the specific customer zipcode location of the request. Requires setup in the Dashboard. - **output** (string) - Optional - Determines the format in which results are returned (json, html, or csv). ``` -------------------------------- ### GET /products Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/product Retrieves product details from a specified home improvement engine based on provided identifiers. ```APIDOC ## GET /products ### Description Retrieves product details for a specific item from a home improvement engine. The request requires the `type=product` parameter. ### Method GET ### Endpoint /products ### Parameters #### Query Parameters - **engine** (string) - Required - The engine of Home Improvement data to retrieve (e.g., homedepot). - **item_id** (string) - Optional - The Home Improvement Item ID to retrieve product details for. - **gtin** (string) - Optional - The GTIN/ISBN/UPC code to look up a matching product. If supplied, `item_id` is ignored. - **url** (string) - Optional - The Home Improvement product-page URL. If supplied, `item_id` and `gtin` are ignored. - **include_html** (boolean) - Optional - Determines whether raw HTML is included in the response. Defaults to false. ``` -------------------------------- ### Request Product Reviews via cURL Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/reviews Example of using cURL to fetch product reviews from the Backyard API. ```curl curl -L --get https://api.backyardapi.com/request -d api_key="demo" -d engine="homedepot" -d type="reviews" -d item_id="317061059" -d sort_by="most_helpful" ``` -------------------------------- ### Retrieve Account Information Source: https://docs.trajectdata.com/backyardapi/account-api Examples for querying the account endpoint using various tools and programming languages. ```HTTP https://api.backyardapi.com/account?api_key=demo ``` ```curl $ curl --get https://api.backyardapi.com/account \ -d api_key="demo" ``` ```nodejs const axios = require('axios'); // set up the request parameters const params = { api_key: "demo" } // make the http GET request to Backyard API axios.get('https://api.backyardapi.com/account', { params }) .then(response => { // print the JSON response from Backyard API console.log(JSON.stringify(response.data, 0, 2)); }).catch(error => { // catch and print the error console.log(error); }) ``` ```python import requests import json # set up the request parameters params = { 'api_key': 'demo' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/account', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ``` ```php 'demo' ]); # make the http GET request to Backyard API $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/account', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $api_result = curl_exec($ch); curl_close($ch); # print the JSON response from Backyard API echo $api_result; ?> ``` -------------------------------- ### JSON Response for Reviews Request Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/results/reviews Example of the JSON structure returned by the API when requesting product reviews. ```json { "request_info": { "success": true, "credits_used": 1, "credits_remaining": 999 }, "request_metadata": { "created_at": "2020-01-01T00:00:00.000Z", "processed_at": "2020-01-01T00:00:00.001Z", "total_time_taken": 0.1, "homedepot_url": "https://www.homedepot.com/p/317061059" }, "request_parameters": { "engine": "homedepot", "type": "reviews", "item_id": "317061059", "sort_by": "most_helpful" }, "reviews": [ { "position": 1, "id": "257606120", "item_id": "317061059", "title": "Great mower", "body": "I always wanted a lithium powered lawn mower and this fit the bill", "campaign_id": "20220519_PPC_PR1_OUT_4034447_", "rating": 5, "positive_feedback": 0, "negative_feedback": 0, "date": "2022-05-19T14:27:36.000+00:00", "is_recommended": true, "is_early_reviewer_incentive": false, "is_incentivized_review": false, "is_top_1000_contributor": false, "is_top_250_contributor": false, "images": [ { "id": "8151927", "link": "https://photos-us.bazaarvoice.com/photo/2/cGhvdG86aG9tZWRlcG90/7604b51f-ed3b-5aeb-9432-827200805aef" } ], "source": { "is_external_source": true, "external_source": false, "author_name": "IanLynPhotography", "author_id": "243961987", "author_location": "Valley Stream", "verified_purchase": false } }, { "position": 2, "id": "257555766", "item_id": "317061059", "title": "After one day of use, so far so good.", "body": "I picked up the mower this morning at my local HD.\r\nIt assembled way easier than I expected.\r\nAnd the battery charged completely after about 30 minutes.\r\n\r\nSome minor quality things.\r\nOne:\r\nWhen I ordered the mower on the HD web site, I saw Model RY401170VNM\r\nAnd that is the model numer on the sticker affixed to the mower.\r\nBut, the manuals (booklets really) all reference model number RY401017\r\nI thought that was kinda odd.\r\n\r\nTwo:\r\nOn the front of the battery that came with the mower, there is a button that, when pressed, should illuminate a number of green lights indicating how much charge is currently in the battery. (Charge level indicator button.)\r\nWell, nothing happens when I press my batteries Charge level indicator button.\r\nThe light DO light up when I insert the battery into the charger while it is being charged.\r\nBut not when that button is pressed.\r\nSo, for now, I have no way of telling how much charge is in the battery unless I plug it into the charger.\r\nThe Ryobi customer support rep told me I should pack up the mower and battery and take it back to HD for a replacement.\r\nThe HD online chat support person told me the same thing.\r\nI'm unsure is that is really worth it but I just wanted others to know of my experience.", "campaign_id": "BV_REVIEW_DISPLAY", "rating": 5, "positive_feedback": 2, "negative_feedback": 0, "date": "2022-05-17T23:20:06.000+00:00", "is_recommended": true, "is_early_reviewer_incentive": false, "is_incentivized_review": false, "is_top_1000_contributor": false, "is_top_250_contributor": false, "images": [ { "id": "8146005", "link": "https://photos-us.bazaarvoice.com/photo/2/cGhvdG86aG9tZWRlcG90/e5991de2-86f8-5e14-9784-151b382780f0" } ], "source": { "is_external_source": true, "external_source": false, "author_name": "JustRay", "author_id": "9jq3gh1wmsfdaufmd437w22fo", "verified_purchase": false } }, { "position": 3, "id": "257554616", "item_id": "317061059", "title": "Alot of power", "body": "[This review was collected as part of a promotion.] I bought this mower, my grass was incredibly high so to procrastinating. And it powered right through it didn't big down. I have .25 acres and it got the job done very quickly", "rating": 5, "positive_feedback": 0, "negative_feedback": 0, "date": "2022-05-17T22:24:52.000+00:00" ``` -------------------------------- ### Retrieve CSV Download Links Source: https://docs.trajectdata.com/backyardapi/collections-api/requests/list Examples for retrieving CSV download links for a collection using various methods. ```HTTP https://api.backyardapi.com/collections/123456/requests/csv?api_key=demo ``` ```curl $ curl "https://api.backyardapi.com/collections/123456/requests/csv?api_key=demo" ``` ```nodejs const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/requests/csv', { params }) .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` ```python import requests params = { 'api_key': 'demo' } api_result = requests.get('https://api.backyardapi.com/collections/123456/requests/csv', params) api_response = api_result.json() ``` ```php 'demo', ]); $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/collections/123456/requests/csv', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $json = curl_exec($ch); curl_close($ch); $api_result = json_decode($json, true); print_r($api_result); ?> ``` -------------------------------- ### GET /collections/{COLLECTION_ID}/start Source: https://docs.trajectdata.com/backyardapi/collections-api/collections/start Initiates a data collection process for a specific collection ID. ```APIDOC ## GET /collections/{COLLECTION_ID}/start ### Description Starts a specific collection by its ID. This is typically used for collections with a manual schedule type, provided they are not currently running and the account has sufficient credits. ### Method GET ### Endpoint https://api.backyardapi.com/collections/{COLLECTION_ID}/start ### Parameters #### Path Parameters - **COLLECTION_ID** (string) - Required - The unique identifier of the collection to start. #### Query Parameters - **api_key** (string) - Required - Your API authentication key. ### Request Example GET https://api.backyardapi.com/collections/123456/start?api_key=demo ### Response #### Success Response (200) - **status** (string) - Confirmation that the collection has been started. ``` -------------------------------- ### Retrieve Result Set as JSON Lines Source: https://docs.trajectdata.com/backyardapi/collections-api/results/get Examples for fetching a result set in JSON Lines format. ```HTTP https://api.backyardapi.com/collections/123456/results/1/jsonlines?api_key=demo ``` ```curl $ curl "https://api.backyardapi.com/collections/123456/results/1/jsonlines?api_key=demo" ``` ```nodejs const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/results/1/jsonlines', { params }) .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` ```python import requests params = { 'api_key': 'demo' } api_result = requests.get('https://api.backyardapi.com/collections/123456/results/1/jsonlines', params) api_response = api_result.json() ``` ```php $queryString = http_build_query([ 'api_key' => 'demo', ]); $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/collections/123456/results/1/jsonlines', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version ``` -------------------------------- ### Find Requests by Search Term Source: https://docs.trajectdata.com/backyardapi/collections-api/requests/find Examples for searching requests in a collection using a query string parameter. ```HTTP https://api.backyardapi.com/collections/123456/requests/1?api_key=demo&q=test ``` ```curl $ curl "https://api.backyardapi.com/collections/123456/requests/1?api_key=demo&q=test" ``` ```nodejs const axios = require('axios'); axios.get('https://api.backyardapi.com/collections/123456/requests/1?api_key=demo&q=test') .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` ```python import requests api_result = requests.get('https://api.backyardapi.com/collections/123456/requests/1?api_key=demo&q=test'') api_response = api_result.json() ``` ```php ``` -------------------------------- ### Retrieve Result Set as JSON Source: https://docs.trajectdata.com/backyardapi/collections-api/results/get Examples for fetching a result set in JSON format using various clients. ```HTTP https://api.backyardapi.com/collections/123456/results/1?api_key=demo ``` ```curl $ curl "https://api.backyardapi.com/collections/123456/results/1?api_key=demo" ``` ```nodejs const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/results/1', { params }) .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` ```python import requests params = { 'api_key': 'demo' } api_result = requests.get('https://api.backyardapi.com/collections/123456/results/1', params) api_response = api_result.json() ``` ```php 'demo', ]); $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/collections/123456/results/1', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $json = curl_exec($ch); curl_close($ch); $api_result = json_decode($json, true); print_r($api_result); ?> ``` -------------------------------- ### Request Product Reviews via Python and PHP Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/reviews Example of using Python or PHP to fetch product reviews from the Backyard API. ```python import requests import json # set up the request parameters params = { 'api_key': 'demo', 'engine': 'homedepot', 'type': 'reviews', 'item_id': '317061059', 'sort_by': 'most_helpful' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/request', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ``` ```php import requests import json # set up the request parameters params = { 'api_key': 'demo', 'engine': 'homedepot', 'type': 'reviews', 'item_id': '317061059', 'sort_by': 'most_helpful' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/request', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ``` -------------------------------- ### Update Destination using Node.js (Axios) Source: https://docs.trajectdata.com/backyardapi/destinations-api/update This Node.js example uses the Axios library to send a PUT request to update a destination. The request body is sent as a JSON object. Make sure to install Axios and replace placeholders with your actual values. ```javascript const axios = require('axios'); const body = { enabled: false, } axios.put('https://api.backyardapi.com/destinations/ABCDEFG?api_key=demo', body) .then(response => { const apiResponse = response.data; console.log('Destination Updated: ' + JSON.stringify(apiResponse, 0, 2)); }).catch(error => { console.log(error); }); ``` -------------------------------- ### Product Lookup by GTIN Parameter Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/reference/gtin-upc-to-home-improvement-item-id Example of the query string format used to perform a product lookup using a GTIN identifier. ```text type=product>in=046396037169 ``` -------------------------------- ### Retrieve Search Results from Home Improvement Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/overview Examples of how to query the Backyard API for search results using various programming languages and tools. ```HTTP https://api.backyardapi.com/request?api_key=demo&engine=homedepot&type=search&search_term=lawn+mower&sort_by=best_seller ``` ```curl $ curl -L --get https://api.backyardapi.com/request \ -d api_key="demo" \ -d engine="homedepot" \ -d type="search" \ -d sort_by="best_seller" \ -d search_term="lawn mower" ``` ```nodejs const axios = require('axios'); // set up the request parameters const params = { api_key: "demo", engine: "homedepot", type: "search", search_term: "lawn mower", sort_by: "best_seller" } // make the http GET request to Backyard API axios.get('https://api.backyardapi.com/request', { params }) .then(response => { // print the JSON response from Backyard API console.log(JSON.stringify(response.data, 0, 2)); }).catch(error => { // catch and print the error console.log(error); }) ``` ```python import requests import json # set up the request parameters params = { 'api_key': 'demo', 'engine': 'homedepot', 'type': 'search', 'search_term': 'lawn mower', 'sort_by': 'best_seller' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/request', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ``` ```php 'demo', 'engine': 'homedepot', 'type': 'search', 'search_term': 'lawn mower', 'sort_by': 'best_seller' ]); # make the http GET request to Backyard API $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/request', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $api_result = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### List Destinations (Node.js) Source: https://docs.trajectdata.com/backyardapi/destinations-api/list Use the axios library in Node.js to fetch destinations. This example logs the total number of destinations and their names. Requires the axios package. ```javascript const axios = require('axios'); axios.get('https://api.backyardapi.com/destinations?api_key=demo') .then(response => { const apiResponse = response.data; console.log("Total Destinations: ", apiResponse.usage.used); apiResponse.destinations.map((destination, number) => console.log((number + 1) + '. ' + destination.name); }).catch(error => { console.error(error); }); ``` -------------------------------- ### Get JSON Download Link (Node.js) Source: https://docs.trajectdata.com/backyardapi/collections-api/requests/list This Node.js snippet uses axios to get a download link for all requests in a collection in JSON format. Ensure COLLECTION_ID is correctly specified. ```javascript const axios = require('axios'); const params = { api_key: 'demo' } axios.get('https://api.backyardapi.com/collections/123456/requests/json', { params }) .then(response => { const apiResponse = response.data; }).catch(error => { console.log(error); }); ``` -------------------------------- ### Create a Daily Collection with Notifications Source: https://docs.trajectdata.com/backyardapi/collections-api/collections/create Use this example to create a new Collection that runs daily at specified hours. It includes options for email notifications and CSV output for results. Ensure your API key is correctly appended to the URL. ```curl $ curl "https://api.backyardapi.com/collections?api_key=demo" \ -d name="My First Collection" \ -d enabled=true \ -d schedule_type="daily" \ -d priority="normal" \ -d schedule_hours="9,17" \ -d destination_ids="ABCDEFG" \ -d notification_email="john.smith@example.com" \ -d notification_as_csv=true ``` -------------------------------- ### Create S3 Destination using PHP Source: https://docs.trajectdata.com/backyardapi/destinations-api/create This PHP example illustrates creating an S3 destination. Note the options for handling SSL verification, which may be necessary with older OpenSSL versions. The API verifies connectivity after creation. ```php "My First S3 Destination", "type" => "s3", "enabled" => false, "s3_access_key_id" => "my_access_key_id", "s3_secret_access_key" => "my_secret_access_key", "s3_bucket_name" => "s3_bucket_name", "s3_path_prefix" => "my_path_prefix" ]); $ch = curl_init('https://api.backyardapi.com/destinations?api_key=demo'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); $json = curl_exec($ch); curl_close($ch); $api_result = json_decode($json, true); print_r($api_result); echo "Destination Created", PHP_EOL; ?> ``` -------------------------------- ### List Child Categories using Python Source: https://docs.trajectdata.com/backyardapi/categories-api/list-and-search This Python script retrieves and prints child categories for a specified parent ID. It uses the 'requests' library. Install it with: pip install requests. ```python import requests import json params = { 'api_key': 'demo', 'parent_id': 'N-5yc1vZbv1w' } api_result = requests.get('https://api.backyardapi.com/categories', { params }) api_response = api_result.json() print "Categories: ", json.dumps(api_response) ``` -------------------------------- ### Request Individual Product Data (PHP) Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/overview This PHP script constructs a query string and uses cURL to make a GET request to the Backyard API for product information. It's set up to return the response and follow redirects. ```php 'demo', 'engine': 'homedepot', 'type': 'product', 'item_id': '317061059' ]); # make the http GET request to Backyard API $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/request', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version ``` -------------------------------- ### List Child Categories using Node.js Source: https://docs.trajectdata.com/backyardapi/categories-api/list-and-search This Node.js script fetches and logs child categories for a given parent ID. It requires the 'axios' library. Install it using: npm install axios. ```javascript const axios = require('axios'); axios.get('https://api.backyardapi.com/categories?api_key=demo&parent_id=N-5yc1vZbv1w') .then(response => { const apiResponse = response.data; console.log("Categories: ", JSON.stringify(apiResponse, 0, 2); }).catch(error => { console.error(error); }); ``` -------------------------------- ### Request Product Details by Item ID (PHP) Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/product A PHP script demonstrating how to fetch product details using cURL and `http_build_query`. It handles SSL verification options and prints the raw API response. ```php 'demo', 'engine': 'homedepot', 'type': 'product', 'item_id': '317061059' ]); # make the http GET request to Backyard API $ch = curl_init(sprintf('%s?%s', 'https://api.backyardapi.com/request', $queryString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); # the following options are required if you're using an outdated OpenSSL version # more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $api_result = curl_exec($ch); curl_close($ch); # print the JSON response from Backyard API echo $api_result; ?> ``` -------------------------------- ### List Root Categories using Python Source: https://docs.trajectdata.com/backyardapi/categories-api/list-and-search This Python script retrieves and prints all top-level categories. It utilizes the 'requests' library for HTTP communication. Ensure 'requests' is installed: pip install requests. ```python import requests import json params = { 'api_key': 'demo' } api_result = requests.get('https://api.backyardapi.com/categories', { params }) api_response = api_result.json() print "Categories: ", json.dumps(api_response) ``` -------------------------------- ### Make a Search Request using Python Source: https://docs.trajectdata.com/backyardapi/home-improvement-product-data-api/parameters/common Execute a search request to the API using Python's requests library. This example demonstrates setting up parameters and printing the JSON response. ```python import requests import json # set up the request parameters params = { 'api_key': 'demo', 'engine': 'homedepot', 'type': 'search', 'search_term': 'lawn mower', 'sort_by': 'best_seller' } # make the http GET request to Backyard API api_result = requests.get('https://api.backyardapi.com/request', params) # print the JSON response from Backyard API print(json.dumps(api_result.json())) ```