Giter Club home page Giter Club logo

mws-api's Introduction

mws-api

Amazon MWS Node.js modules are a mess. This project is based on multiple projects from this.

Promise based. Only compatible with Node ^4.0.0. (unless someone adds a babel precompilation step)

Supports throttling and pagification. (NextToken stuff)

Examples

Installation:

npm i mws-api -S

Initialization:

const MWSClient = require('mws-api');
const mws = new MWSClient({
  accessKeyId: 'lol',
  secretAccessKey: 'kek',
  merchantId: 'hue',
  meta: {
    retry: true, // retry requests when throttled
    next: true, // auto-paginate
    limit: Infinity // only get this number of items (NOT the same as MaxRequestsPerPage)
  }
});

For other countries, also set the host parameter, according to the MarketPlaceId you are using, otherwise it leads to AccessDenied error. For example:

...
const mws = new MWSClient({
  host: 'mws.amazonservices.co.uk', // .de, .es, .fr, .it, etc
  ...
}

Usage:

mws.Orders.ListOrders({
  MarketplaceId: 'lel',
  MaxResultsPerPage: 10,
  CreatedAfter: new Date(1,1,2015),
  CreatedBefore: new Date(1,2,2015)
})
.then(({ result, metadata }) => {
  // result
});

Flat files:

When working with a flat-file response from Amazon, a parseCSVResult function is provided as an option to conviniently post-process the result. Returning a Promise will result in the Promise being resolved.

// An example to change the encoding of the raw response
const iconv = require('iconv-lite');
const MWSClient = require('mws-api');
const mws = new MWSClient({
  accessKeyId: 'lol',
  secretAccessKey: 'kek',
  merchantId: 'hue',
  meta: {
    parseCSVResult: (data) => iconv.encode(data, 'utf-8').toString()
  }
});

mws-api's People

Contributors

tyscorp avatar greenkeeperio-bot avatar dciccale avatar dakk avatar barrycarlyon avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.