Skip to content

adamj88/node-magento2

Repository files navigation

Consume Magento 2 REST API

Build Status

Currently a work in progress.

Wrapper for connecting to Magento 2 REST API.

Installation

npm install magento2 --save

Example Usage

This uses restler as a HTTP Client library, please see their documentation for more examples/sample usage.

var Magento2 = require('magento2');

var opt = {
  url: 'http://example.com', // without trailing slash
  username: 'username',
  password: 'password',
  isAdmin: true
};

var magento = new Magento2(opt);

// Create a Token
magento.Api.token = magento.Integration.getToken().on('complete', function(result) {
  if (result instanceof Error) {
    console.log('Error:', result.message);
    this.retry(5000); // try again after 5 sec
  } else {
    return result;
  }
});

// Get Category list
categories = magento.Catalog.getCategories.on('complete', function(result) {
  if (result instanceof Error) {
    console.log('Error:', result.message);
    this.retry(5000); // try again after 5 sec
  } else {
    return result;
  }
});

Options

Option Type Required Description
url String yes Your Store URL, example: http://example.com (without trailing slash)
username String yes Your API username
password String yes Your API password
version Interger no API version, default is 1
encoding String no Encoding, default is 'utf-8'
isAdmin Boolean no Is user admin or customer, default is false (custoemr)

End points

For a complete list of endpoints see:

Those implemented in this module:

  • Backend #1
  • Bundle #2
  • Catalog #3
  • CatalogInventory #4
  • Checkout #5
  • CheckoutAgreements #6
  • ConfigurableProduct #20
  • Cms #7
  • Customer #8
  • Directory #9
  • Downloadable #10
  • Eav #11
  • GiftMessage #12
  • Integration #13
  • Quote #14
  • Sales #15
  • SalesRule #16
  • Search #19
  • Store #17
  • Tax #18

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published