UNPKG

@pgprojectx/bazaarvoice-sdk

Version:
93 lines (68 loc) 2.14 kB
# @pgprojectx/bazaarvoice-sdk > API wrapper for BazaarVoice ## Table of Contents - [Install](#install) - [Usage](#usage) - [Notes](#notes) ## Install ``` # For JavaScript usage npm install --save-exact @pgprojectx/bazaarvoice-sdk # For CLI usage npm install --global @pgprojectx/bazaarvoice-sdk ``` ## Usage ```javascript const bazaarvoice = require('@pgprojectx/bazaarvoice-sdk'); const client = bazaarvoice({ host: 'https://api.bazaarvoice.com', apiVersion: '5.4', apiKey: 'apiKey' }); // Get Product Reviews const reviews = await client.getProductReviews('000123645678901'); console.log(reviews); // { // "reviewCount": Number, // "reviews": Array, // "rating": Number // } ``` ### Configuration Files Create [an rc file][rc] to set defaults, so you don't have to pass a `host`, `apiKey`, and `apiVersion` flag to every command. ``` # ~/.bazaarvoicerc host = https://api.bazaarvoice.com apiKey = your-api-key apiVersion = 5.4 ``` `@pgprojectx/bazaarvoice-sdk` will walk the directory tree looking for rc files, so you can create one in the root of your project's directory to make the CLI context aware. ### Commands #### Get Product Reviews Retrieve product review information for a specified product. The results are written to `stdout` ``` > bazaarvoice-sdk get-product-reviews -h bazaarvoice-sdk get-product-reviews [productId] Get product reviews for a product ID Options: --version Show version number [boolean] --host, --apiHost BazaarVoice API hostname [required] --apiKey API key for BazaarVoice [required] --apiVersion BazaarVoice API version [required] --productId Product ID --raw Return full response data -h Show help [boolean] ``` ## Notes BazaarVoice does not return 404s for non-existing products. So default responses will result in the following object ```json { "reviewCount": 0, "reviews": [], "rating": false } ``` [rc]: https://www.npmjs.com/package/rc