Skip to content
This repository has been archived by the owner on Mar 17, 2019. It is now read-only.
/ amazon-costs Public archive

A module for retrieving Amazon product information and calculating costs for fulfillment and merchant channels

License

Notifications You must be signed in to change notification settings

devfacet/amazon-costs

Repository files navigation

Amazon Costs

NPM Build Status

Amazon Costs is a module for retrieving Amazon product information and calculating costs for fulfillment and merchant channels.

Installation

npm install amazon-costs

Usage

Search

var amzCosts = require('amazon-costs');

amzCosts.productSearch('The Hobbit DVD', function(err, data) {
  if(!err) {
    console.log(data);
  } else {
    console.log(err);
  }
});

// Output
/*
{ items:
   [ { link: 'http://www.amazon.com/gp/product/B00BEZTMFY/ref=xx_xx_cont_xx/176-0515210-4045758',
       dimUnits: 'inches',
       thumbnail: 'https://images-na.ssl-images-amazon.com/images/I/51oyx9TCjVL._SL80_.jpg',
       subCategory: null,
       dimensions: [Object],
       gl: 'gl_dvd',
       image: 'https://images-na.ssl-images-amazon.com/images/I/51oyx9TCjVL._SL120_.jpg',
       weightUnits: 'pounds',
       productGroup: '74',
       weight: 0.2,
       asin: 'B00BEZTMFY',
       whiteGlovesRequired: 'N',
       title: 'The Hobbit: An Unexpected Journey (Two-Disc Special Edition) (DVD + UltraViolet Digital Copy) [DVD]' },
     { link: 'http://www.amazon.com/gp/product/B00HWWUQWQ/ref=xx_xx_cont_xx/176-0515210-4045758',
       dimUnits: 'inches',
       thumbnail: 'https://images-na.ssl-images-amazon.com/images/I/51AcQosPxyL._SL80_.jpg',
       subCategory: null,
       dimensions: [Object],
       gl: 'gl_dvd',
       image: 'https://images-na.ssl-images-amazon.com/images/I/51AcQosPxyL._SL120_.jpg',
       weightUnits: 'pounds',
       productGroup: '74',
       weight: 0.1,
       asin: 'B00HWWUQWQ',
       whiteGlovesRequired: 'N',
       title: 'The Hobbit: The Desolation of Smaug (Special Edition) (DVD + UltraViolet Combo Pack) [DVD]' } ],
  errors: null }
*/

Cost

var amzCosts  = require('amazon-costs');
var asin      = 'B00BEZTMQ8';

amzCosts.productSearch(asin, function(err, data) {
  if(err) {
    console.log(err);
    return;
  }

  console.log(data);

  if(!data || !(data.items instanceof Array) || data.items[0] && data.items[0].asin != asin) {
    console.log("Error: Product (" + asin + ") could not be found.");
    return;
  }

  // FBA costs
  amzCosts.productCosts({
    product: data.items[0],
    cost: {
      costType: 'FBA',
      productPrice: 25.00,
      inboundDelivery: 1.00,
      prepService: 1.00
    }
  }, function(err, data) {
    if(!err) {
      console.log(JSON.stringify(data, null, 2));
    } else {
      console.log(err);
    }
  });

  // FBM costs
  amzCosts.productCosts({
    product: data.items[0],
    cost: {
      costType: 'FBM',
      productPrice: 25.00,
      shipping: 1.00,
      orderHandling: 1.00,
      pickPack: 1.00,
      outboundDelivery: 1.00,
      storage: 1.00,
      inboundDelivery: 1.00,
      customerService: 1.00,
      prepService: 1.00
    }
  }, function(err, data) {
    if(!err) {
      console.log(JSON.stringify(data, null, 2));
    } else {
      console.log(err);
    }
  });
});

// Output
/*
{ items:
   [ { link: 'http://www.amazon.com/gp/product/B00BEZTMQ8/ref=xx_xx_cont_xx/186-8065886-6900841',
       dimUnits: 'inches',
       thumbnail: 'https://images-na.ssl-images-amazon.com/images/I/51nZpnQgUwL._SL80_.jpg',
       subCategory: null,
       dimensions: [Object],
       gl: 'gl_dvd',
       image: 'https://images-na.ssl-images-amazon.com/images/I/51nZpnQgUwL._SL120_.jpg',
       weightUnits: 'pounds',
       productGroup: '74',
       weight: 0.1,
       asin: 'B00BEZTMQ8',
       whiteGlovesRequired: 'N',
       title: 'The Hobbit: An Unexpected Journey (Blu-ray) [Blu-ray]' } ],
  errors: null }
{
  "items": [
    {
      "asin": "B00BEZTMQ8",
      "cost": {
        "merchant": {
          "price": 25,
          "revenueTotal": 25,
          "inbound-delivery": 1,
          "prep-service": 1,
          "fulfillmentTotal": 2
        },
        "amazon": {
          "weightHandlingFee": "0.46",
          "orderHandlingFee": 0,
          "fbaDeliveryServicesFee": 0,
          "commissionFee": "3.75",
          "pickAndPackFee": "1.02",
          "storageFee": 0,
          "variableClosingFee": "0.8"
        }
      }
    }
  ],
  "errors": null
}
{
  "items": [
    {
      "asin": "B00BEZTMQ8",
      "cost": {
        "merchant": {
          "price": 25,
          "shipping": 1,
          "order-handling": 1,
          "pick-pack": 1,
          "outbound-delivery": 1,
          "storage": 1,
          "inbound-delivery": 1,
          "customer-service": 1,
          "prep-service": 1,
          "revenueTotal": 26,
          "fulfillmentTotal": 7
        },
        "amazon": {
          "commissionFee": 3.75,
          "variableClosingFee": "1.35"
        }
      }
    }
  ],
  "errors": null
}
*/

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

About

A module for retrieving Amazon product information and calculating costs for fulfillment and merchant channels

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published