Socket
Socket
Sign inDemoInstall

magento-api-rest-legacy

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    magento-api-rest-legacy

A NodeJS wrapper to work with Magento V1 REST APIs.


Version published
Maintainers
1
Created

Readme

Source

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

OptionTypeRequiredDescription
urlStringyesYour Store URL
consumerKeyStringyesYour API consumer key
consumerSecretStringyesYour API consumer secret
accessTokenStringyesYour API Access Token
tokenSecretStringyesYour API Access Token Secret
timeoutNumbernoRequest Timeout
axiosConfigObjectnoReference

Methods

GET

  • .get(endpoint)
  • .get(endpoint, params)
ParamsTypeDescription
endpointStringMagento API endpoint, example: orders
paramsObjectJSON 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)
ParamsTypeDescription
endpointStringMagento API endpoint, example: shipments
dataObjectJSON object to be sent as body.

PUT

  • .put(endpoint, data)
ParamsTypeDescription
endpointStringMagento API endpoint, example: shipments/12
dataObjectJSON object to be sent as body.

DELETE

  • .delete(endpoint, data)
ParamsTypeDescription
endpointStringMagento API endpoint, example: orders/12
dataObjectJSON 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
    }
}

Keywords

FAQs

Last updated on 03 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc