Giter Site home page Giter Site logo

magento-api-rest-legacy's Introduction

Magento API REST (Legacy)

A Node.js client wrapper to work with the Magento 1.X REST API.

npm version dependencies Status

Installation

npm i magento-api-rest-legacy

Getting started

Generate API credentials by following these instructions.

Make sure to check the resource access is as per your requirements to prevent misuse of the API Keys.

  • This library is compatible only with Magento 1.X REST Endpoints for Magento 2.X based stores, use the sister package.

Setup

Setup for the Magento REST API integration:

const MagentoAPI = require('magento-api-rest-legacy');

const client = new MagentoAPI({
    'url': 'http://www.your-store.dev',
    'consumerKey': '<OAuth 1.0a consumer key>',
    'consumerSecret': '<OAuth 1.0a consumer secret>',
    'accessToken': '<OAuth 1.0a access token>',
    'tokenSecret': '<OAuth 1.0a access token secret>'
});

Options

Option Type Required Description
url String yes Your Store URL
consumerKey String yes Your API consumer key
consumerSecret String yes Your API consumer secret
accessToken String yes Your API Access Token
tokenSecret String yes Your API Access Token Secret
timeout Number no Request Timeout
axiosConfig Object no Reference

Methods

GET

  • .get(endpoint)
  • .get(endpoint, params)
Params Type Description
endpoint String Magento API endpoint, example: orders
params Object JSON object to be sent as params.
  • Note: In case no params are specified or required, you can leave params as empty. That will result in "?searchCriteria=all" in the URL.

POST

  • .post(endpoint, data)
Params Type Description
endpoint String Magento API endpoint, example: shipments
data Object JSON object to be sent as body.

PUT

  • .put(endpoint, data)
Params Type Description
endpoint String Magento API endpoint, example: shipments/12
data Object JSON object to be sent as body.

DELETE

  • .delete(endpoint, data)
Params Type Description
endpoint String Magento API endpoint, example: orders/12
data Object JSON object to be sent as body.

API

Requests are made with Axios library with support to promises.

let params = {
    "filter": [
        {
            "attribute": "entity_id",
            "neq": 3,
            "in": [1,2,3],
            "nin": [1,2,3],
            "gt": 3,
            "lt": 3,
            "from": "Date",
            "to": "Date"
        }
    ],
    "page": 1,
    "order": "name",
    "dir": "dsc", // Or asc
    "limit": 100
}

If you want to use the above object in a request,

async function getOrders () {
    try {
        let response = await client.get('orders', params);
        // Response Handling
    } catch (error) {
        // Error Handling
    }
}

magento-api-rest-legacy's People

Watchers

 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.