npm

Need private packages and team management tools?Check out npm Orgs. »

bolcom

1.2.3 • Public • Published

bolcom

Access the Bol.com Partner Open API with Node.js (unofficial)

npm Build Status Coverage Status bitHound Dependencies bitHound Code Greenkeeper

Usage

const bol = require ('bolcom') ('apikey');
 
bol.catalog.search ({ q: 'node.js' }, (err, data) => {
  if (err) {
    console.error ('Search failed');
    console.error (err);
    return;
  }
 
  for (let p in data.products) {
    let product = data.products[p];
    console.log (product.title + ' - €' + product.offerData.offers[0].price);
  }
});

Requirements

Installation

npm install bolcom

Methods

For readability error handling is not included in the following examples. See the Usage section above for an example with proper error handling.

utils.ping

( callback )

Simple API access test. The result data should be an object with only one property named message with the exact value Hello world!!.

param type required description
callback function yes (err, data)
bol.utils.ping ((err, data) => {
  if (data.message === 'Hello world!!') {
    console.log ('pong');
  } else {
    console.log ('ouch');
  }
});

account.sessions

( callback )

Request a new anonymous session ID.

param type required description
callback function yes (err, data)
bol.acocunt.sessions ((err, data) => {
  console.log (data.sessionId);
});

catalog.search

( props, callback )

Search products in the catalog.

The result data is modified to remove a few xml-style annoyances.

param type required description
prope object yes search paramaters
callback function yes (err, data)
bol.catalog.search ({ q: 'node.js' }, (err, data) => {
  for (let i in data.products) {
    let product = data.products[p];
    console.log (product.title + ' - ' + product.summary);
  }
});

catalog.lists

( [props], callback )

Product lists, based on list type and category.

param type required description
props object no Arguments, see API documentation
callback function yes (err, data)

catalog.products

( productId, [props], callback )

Get details information for one or more products.

param type required description
productId string yes Product ID
props object no Arguments, see API documentation
callback function yes (err, data)
bol.catalog.products ('9200000023292527', {includeattributes: true}, (err, data) => {
  for (let p in data.products) {
    let product = data.products[p];
    console.log (product.title + ' - €' + product.offerData.offers[0].price);
  }
});

catalog.offers

( productId, [props], callback )

Get available offers for a given product.

param type required description
productId string yes Product ID
props object no Arguments, see API documentation
callback function yes (err, data)
bol.catalog.offers ('9200000023292527', (err, data) => {
  for (let i in data.offers) {
    let offer = data.offers[i];
    console.log (offer.price + ' - ' + offer.availabilityDescription);
  }
});

catalog.recommendations

( productId, [props], callback )

Get recommended products for a given product.

param type required description
productId string yes Product ID
props object no Arguments, see API documentation
callback function yes (err, data)
bol.catalog.recommendations ('9200000023292527', (err, data) => {
  for (let i in data) {
    let product = data[i];
    console.log (product.title + ' - ' + product.rating);
  }
});

catalog.relatedproducts

( productId, [props], callback )

Get related products for a given product.

param type required description
productId string yes Product ID
props object no Arguments, see API documentation
bol.catalog.relatedproducts ('9200000010839998', (err, data) => {
  if (data.BINDINGCODE && data.BINDINGCODE.productFamilyMembers) {
    for (let m in data.BINDINGCODE.productFamilyMembers) {
      let mem = data.BINDINGCODE.productFamilyMembers[m];
 
      console.log (mem.label + ' - ' + mem.productId);
    }
  }
});

Errors

message description
missing apikey Credentials are not set
api error The API returned an error, see err.code and err.api
request failed The request can not be build
invalid response The API response cannot be processed

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Author

Franklin van de Meent

Buy me a coffee

install

npm i bolcom

Downloadsweekly downloads

7

version

1.2.3

license

Unlicense

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability