GithubHelp home page GithubHelp logo

isabella232 / magento2-rest-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vuestorefront/magento2-rest-client

0.0 0.0 0.0 46 KB

Magento2 Node.js Rest client

License: MIT License

JavaScript 100.00%

magento2-rest-client's Introduction

Magento2 REST client

This Node.js library enables JavaScript applications to communicate with Magento2 sites using their REST API. This module based on the magento2-rest-client module created by Marko Novak (2016).

This module is used by the Vue Storefront - first Progressive Web App for eCommerce.

NOTE: the library is not finished yet! Only a subset of Magento2 API is currently implemented.

Installation

The library can be installed using the Npm package manager:

    npm install --save github:DivanteLtd/magento2-rest-client

Usage

The code sample below shows the usage of the library:

    var Magento2Client = require('magento2-rest-client').Magento2Client;

    var options = {
          'url': 'http://www.test.com/index.php/rest',
          'consumerKey': '<OAuth 1.0a consumer key>',
          'consumerSecret': '<OAuth 1.0a consumer secret>',
          'accessToken': '<OAuth 1.0a access token>',
          'accessTokenSecret': '<OAuth 1.0a access token secret>'
    };
    var client = Magento2Client(options);
    client.categories.list()
        .then(function (categories) {
            assert.equal(categories.parentId, 1);
        })

You can extend the API by adding Your own modules or adding methods to the existing modules!

    var Magento2Client = require('magento2-rest-client').Magento2Client;

    var options = {
          'url': 'http://www.test.com/index.php/rest',
          'consumerKey': '<OAuth 1.0a consumer key>',
          'consumerSecret': '<OAuth 1.0a consumer secret>',
          'accessToken': '<OAuth 1.0a access token>',
          'accessTokenSecret': '<OAuth 1.0a access token secret>'
    };
    var client = Magento2Client(options);

    client.addMethods('categories', function (restClient) {
            var module = {};
            module.listEx = function () {
                return restClient.get('/categories');
            }
            return module;
        }
    )

    client.addMethods('newModule', function (restClient) {
            var module = {};
            module.newMethod = function () {
                return restClient.post('/custom_magento_api_endpoint');
            }
            return module;
        }
    )

    client.categories.listEx()
        .then(function (categories) {
            assert.equal(categories.parentId, 1);
        })
    client.newModule.newMethod()
        .then(function (resultJson) {
        })

Contributing

usefull resources

Magento API with Swagger: https://devdocs.magento.com/swagger/

Entry Page of REST API Documentation of Magento: https://devdocs.magento.com/guides/v2.3/rest/bk-rest.html filter response: https://devdocs.magento.com/guides/v2.3/rest/retrieve-filtered-responses.html

Credit

This Repository is an independent fork of https://github.com/nouvak/magento2-rest-client created by Marko Novak.

magento2-rest-client's People

Contributors

afirlejczyk avatar aleron75 avatar fifciu avatar flyingmana avatar jakubmakielkowski avatar mdesmet avatar pablogiralt avatar pkarw avatar qiqqq avatar rain2o 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.